You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/06/02 17:39:16 UTC
airavata-php-gateway git commit: Adding new Airavata Security models
Repository: airavata-php-gateway
Updated Branches:
refs/heads/master 6a96bf70b -> f61ca5e5e
Adding new Airavata Security models
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/f61ca5e5
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f61ca5e5
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f61ca5e5
Branch: refs/heads/master
Commit: f61ca5e5e1b6bed0dc23dbbaff9dc5d392759e4d
Parents: 6a96bf7
Author: Supun Nakandala <sc...@apache.org>
Authored: Tue Jun 2 21:08:49 2015 +0530
Committer: Supun Nakandala <sc...@apache.org>
Committed: Tue Jun 2 21:08:49 2015 +0530
----------------------------------------------------------------------
app/filters.php | 4 +-
app/libraries/Airavata/API/Airavata.php | 63 +++++++-
app/libraries/Airavata/Model/Security/Types.php | 146 +++++++++++++++++++
app/libraries/Utilities.php | 2 +
4 files changed, 209 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f61ca5e5/app/filters.php
----------------------------------------------------------------------
diff --git a/app/filters.php b/app/filters.php
index d89a087..409e642 100755
--- a/app/filters.php
+++ b/app/filters.php
@@ -13,7 +13,9 @@
App::before(function($request)
{
- $apiVersion = Airavata::getAPIVersion();
+ $authzToken = new Airavata\Model\Security\AuthzToken();
+ $authzToken->accessToken = "emptyToken";
+ $apiVersion = Airavata::getAPIVersion($authzToken);
if(empty($apiVersion))
return View::make("server-down");
});
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f61ca5e5/app/libraries/Airavata/API/Airavata.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/API/Airavata.php b/app/libraries/Airavata/API/Airavata.php
index 4a509b2..2532766 100644
--- a/app/libraries/Airavata/API/Airavata.php
+++ b/app/libraries/Airavata/API/Airavata.php
@@ -17,7 +17,7 @@ use Thrift\Exception\TApplicationException;
interface AiravataIf {
- public function getAPIVersion();
+ public function getAPIVersion(\Airavata\Model\Security\AuthzToken $authzToken);
public function addGateway(\Airavata\Model\Workspace\Gateway $gateway);
public function updateGateway($gatewayId, \Airavata\Model\Workspace\Gateway $updatedGateway);
public function getGateway($gatewayId);
@@ -157,15 +157,16 @@ class AiravataClient implements \Airavata\API\AiravataIf {
$this->output_ = $output ? $output : $input;
}
- public function getAPIVersion()
+ public function getAPIVersion(\Airavata\Model\Security\AuthzToken $authzToken)
{
- $this->send_getAPIVersion();
+ $this->send_getAPIVersion($authzToken);
return $this->recv_getAPIVersion();
}
- public function send_getAPIVersion()
+ public function send_getAPIVersion(\Airavata\Model\Security\AuthzToken $authzToken)
{
$args = new \Airavata\API\Airavata_getAPIVersion_args();
+ $args->authzToken = $authzToken;
$bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
if ($bin_accel)
{
@@ -213,6 +214,9 @@ class AiravataClient implements \Airavata\API\AiravataIf {
if ($result->ase !== null) {
throw $result->ase;
}
+ if ($result->ae !== null) {
+ throw $result->ae;
+ }
throw new \Exception("getAPIVersion failed: unknown result");
}
@@ -7904,12 +7908,23 @@ class AiravataClient implements \Airavata\API\AiravataIf {
class Airavata_getAPIVersion_args {
static $_TSPEC;
+ public $authzToken = null;
- public function __construct() {
+ public function __construct($vals=null) {
if (!isset(self::$_TSPEC)) {
self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'authzToken',
+ 'type' => TType::STRUCT,
+ 'class' => '\Airavata\Model\Security\AuthzToken',
+ ),
);
}
+ if (is_array($vals)) {
+ if (isset($vals['authzToken'])) {
+ $this->authzToken = $vals['authzToken'];
+ }
+ }
}
public function getName() {
@@ -7931,6 +7946,14 @@ class Airavata_getAPIVersion_args {
}
switch ($fid)
{
+ case 1:
+ if ($ftype == TType::STRUCT) {
+ $this->authzToken = new \Airavata\Model\Security\AuthzToken();
+ $xfer += $this->authzToken->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
default:
$xfer += $input->skip($ftype);
break;
@@ -7944,6 +7967,14 @@ class Airavata_getAPIVersion_args {
public function write($output) {
$xfer = 0;
$xfer += $output->writeStructBegin('Airavata_getAPIVersion_args');
+ if ($this->authzToken !== null) {
+ if (!is_object($this->authzToken)) {
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+ }
+ $xfer += $output->writeFieldBegin('authzToken', TType::STRUCT, 1);
+ $xfer += $this->authzToken->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
@@ -7958,6 +7989,7 @@ class Airavata_getAPIVersion_result {
public $ire = null;
public $ace = null;
public $ase = null;
+ public $ae = null;
public function __construct($vals=null) {
if (!isset(self::$_TSPEC)) {
@@ -7981,6 +8013,11 @@ class Airavata_getAPIVersion_result {
'type' => TType::STRUCT,
'class' => '\Airavata\API\Error\AiravataSystemException',
),
+ 4 => array(
+ 'var' => 'ae',
+ 'type' => TType::STRUCT,
+ 'class' => '\Airavata\API\Error\AuthorizationException',
+ ),
);
}
if (is_array($vals)) {
@@ -7996,6 +8033,9 @@ class Airavata_getAPIVersion_result {
if (isset($vals['ase'])) {
$this->ase = $vals['ase'];
}
+ if (isset($vals['ae'])) {
+ $this->ae = $vals['ae'];
+ }
}
}
@@ -8049,6 +8089,14 @@ class Airavata_getAPIVersion_result {
$xfer += $input->skip($ftype);
}
break;
+ case 4:
+ if ($ftype == TType::STRUCT) {
+ $this->ae = new \Airavata\API\Error\AuthorizationException();
+ $xfer += $this->ae->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
default:
$xfer += $input->skip($ftype);
break;
@@ -8082,6 +8130,11 @@ class Airavata_getAPIVersion_result {
$xfer += $this->ase->write($output);
$xfer += $output->writeFieldEnd();
}
+ if ($this->ae !== null) {
+ $xfer += $output->writeFieldBegin('ae', TType::STRUCT, 4);
+ $xfer += $this->ae->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f61ca5e5/app/libraries/Airavata/Model/Security/Types.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/Model/Security/Types.php b/app/libraries/Airavata/Model/Security/Types.php
new file mode 100644
index 0000000..3a263d3
--- /dev/null
+++ b/app/libraries/Airavata/Model/Security/Types.php
@@ -0,0 +1,146 @@
+<?php
+namespace Airavata\Model\Security;
+
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+use Thrift\Base\TBase;
+use Thrift\Type\TType;
+use Thrift\Type\TMessageType;
+use Thrift\Exception\TException;
+use Thrift\Exception\TProtocolException;
+use Thrift\Protocol\TProtocol;
+use Thrift\Protocol\TBinaryProtocolAccelerated;
+use Thrift\Exception\TApplicationException;
+
+
+class AuthzToken {
+ static $_TSPEC;
+
+ public $accessToken = null;
+ public $claimsMap = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'accessToken',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'claimsMap',
+ 'type' => TType::MAP,
+ 'ktype' => TType::STRING,
+ 'vtype' => TType::STRING,
+ 'key' => array(
+ 'type' => TType::STRING,
+ ),
+ 'val' => array(
+ 'type' => TType::STRING,
+ ),
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['accessToken'])) {
+ $this->accessToken = $vals['accessToken'];
+ }
+ if (isset($vals['claimsMap'])) {
+ $this->claimsMap = $vals['claimsMap'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'AuthzToken';
+ }
+
+ public function read($input)
+ {
+ $xfer = 0;
+ $fname = null;
+ $ftype = 0;
+ $fid = 0;
+ $xfer += $input->readStructBegin($fname);
+ while (true)
+ {
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+ if ($ftype == TType::STOP) {
+ break;
+ }
+ switch ($fid)
+ {
+ case 1:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->accessToken);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::MAP) {
+ $this->claimsMap = array();
+ $_size0 = 0;
+ $_ktype1 = 0;
+ $_vtype2 = 0;
+ $xfer += $input->readMapBegin($_ktype1, $_vtype2, $_size0);
+ for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
+ {
+ $key5 = '';
+ $val6 = '';
+ $xfer += $input->readString($key5);
+ $xfer += $input->readString($val6);
+ $this->claimsMap[$key5] = $val6;
+ }
+ $xfer += $input->readMapEnd();
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('AuthzToken');
+ if ($this->accessToken !== null) {
+ $xfer += $output->writeFieldBegin('accessToken', TType::STRING, 1);
+ $xfer += $output->writeString($this->accessToken);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->claimsMap !== null) {
+ if (!is_array($this->claimsMap)) {
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+ }
+ $xfer += $output->writeFieldBegin('claimsMap', TType::MAP, 2);
+ {
+ $output->writeMapBegin(TType::STRING, TType::STRING, count($this->claimsMap));
+ {
+ foreach ($this->claimsMap as $kiter7 => $viter8)
+ {
+ $xfer += $output->writeString($kiter7);
+ $xfer += $output->writeString($viter8);
+ }
+ }
+ $output->writeMapEnd();
+ }
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f61ca5e5/app/libraries/Utilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/Utilities.php b/app/libraries/Utilities.php
index cdceb25..ba6aea0 100644
--- a/app/libraries/Utilities.php
+++ b/app/libraries/Utilities.php
@@ -1550,6 +1550,8 @@ public static function create_experiment()
{
$experiment = Utilities::assemble_experiment();
+ var_dump($experiment);
+ exit;
$expId = null;
try