You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2015/06/02 14:01:20 UTC

[1/8] airavata git commit: initial version of the client sample.

Repository: airavata
Updated Branches:
  refs/heads/master c8a70e9b4 -> 1149810ca


initial version of the client sample.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/5c3c9bdb
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/5c3c9bdb
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/5c3c9bdb

Branch: refs/heads/master
Commit: 5c3c9bdb5ebabc2d0aca737f4bcba454e435afd7
Parents: 8ae827d
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Thu May 21 17:52:05 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Thu May 21 17:52:05 2015 +0530

----------------------------------------------------------------------
 pom.xml                                         |   1 +
 samples/java-client/experiment/pom.xml          |   2 +-
 samples/java-client/pom.xml                     |   7 +-
 samples/java-client/secure-client/pom.xml       | 100 +++++++++++++++++++
 .../airavata/secure/sample/Constants.java       |  26 +++++
 .../airavata/secure/sample/SecureClient.java    |  73 ++++++++++++++
 6 files changed, 205 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/5c3c9bdb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7655b49..511cdec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -626,6 +626,7 @@
 				<module>modules/orchestrator</module>
 				<module>tools</module>
 				<module>modules/server</module>
+                <module>samples/java-client</module>
 				<module>modules/distribution</module>
 				<module>modules/test-suite</module>
 				<module>modules/integration-tests</module>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c3c9bdb/samples/java-client/experiment/pom.xml
----------------------------------------------------------------------
diff --git a/samples/java-client/experiment/pom.xml b/samples/java-client/experiment/pom.xml
index bde6090..e0bf817 100644
--- a/samples/java-client/experiment/pom.xml
+++ b/samples/java-client/experiment/pom.xml
@@ -12,7 +12,7 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <parent>
         <groupId>org.apache.airavata</groupId>
-        <artifactId>airavata-client-sample</artifactId>
+        <artifactId>samples</artifactId>
         <version>0.12-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c3c9bdb/samples/java-client/pom.xml
----------------------------------------------------------------------
diff --git a/samples/java-client/pom.xml b/samples/java-client/pom.xml
index 198a3dc..7adc314 100644
--- a/samples/java-client/pom.xml
+++ b/samples/java-client/pom.xml
@@ -12,17 +12,18 @@
     <parent>
         <groupId>org.apache.airavata</groupId>
         <artifactId>airavata</artifactId>
-        <version>0.12-SNAPSHOT</version>
+        <version>0.15-SNAPSHOT</version>
         <relativePath>../../pom.xml</relativePath>
     </parent>
 
     <modelVersion>4.0.0</modelVersion>
-    <artifactId>airavata-client-sample</artifactId>
+    <artifactId>samples</artifactId>
     <name>Samples - Airavata Client Samples</name>
     <packaging>pom</packaging>
     <url>http://airavata.apache.org/</url>
 
     <modules>
-        <module>experiment</module>
+        <!--module>experiment</module-->
+        <module>secure-client</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c3c9bdb/samples/java-client/secure-client/pom.xml
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/pom.xml b/samples/java-client/secure-client/pom.xml
new file mode 100644
index 0000000..5197cc7
--- /dev/null
+++ b/samples/java-client/secure-client/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>samples</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.15-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>secure-client</artifactId>
+    <packaging>jar</packaging>
+
+    <repositories>
+        <repository>
+            <id>wso2-nexus</id>
+            <name>WSO2 internal Repository</name>
+            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>ignore</checksumPolicy>
+            </releases>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-api-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>${thrift.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-model-utils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
+            <version>4.2.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.utils</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+            <version>1.6.1.wso2v4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <classpathPrefix>${user.home}/.m2/repository</classpathPrefix>
+                            <classpathLayoutType>repository</classpathLayoutType>
+                            <mainClass>org.apache.airavata.secure.sample.SecureClient</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c3c9bdb/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java
new file mode 100644
index 0000000..0c2c518
--- /dev/null
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.secure.sample;
+
+public class Constants {
+    public static final String SERVER_HOST = "localhost";
+    public static final int SERVER_PORT = 8930;
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5c3c9bdb/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
new file mode 100644
index 0000000..f94f2ff
--- /dev/null
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.secure.sample;
+
+import org.apache.airavata.api.client.AiravataClientFactory;
+import org.apache.airavata.model.error.AiravataClientConnectException;
+import org.apache.airavata.model.error.AiravataClientException;
+import org.apache.airavata.model.error.AiravataSystemException;
+import org.apache.airavata.model.error.InvalidRequestException;
+import org.apache.airavata.api.Airavata;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SecureClient {
+    private static Logger logger = LoggerFactory.getLogger(SecureClient.class);
+
+    public static void main(String[] args) throws AiravataClientConnectException, TException {
+        Airavata.Client client = createAiravataClient(Constants.SERVER_HOST, Constants.SERVER_PORT);
+        String version = client.getAPIVersion();
+        System.out.println("Airavata API version: " + version);
+    }
+
+    public static Airavata.Client createAiravataClient(String serverHost, int serverPort) throws
+            AiravataClientConnectException {
+        try {
+            Airavata.Client client = AiravataClientFactory.createAiravataClient(serverHost, serverPort);
+            return client;
+
+        } catch (AiravataClientConnectException e) {
+            logger.error("Error while creating Airavata Client.");
+            throw e;
+        }
+    }
+
+    public static String getAPIVersion(Airavata.Client client) throws TException {
+        try {
+            return client.getAPIVersion();
+        } catch (InvalidRequestException e) {
+            logger.error("Error in retrieving API version.");
+            throw new InvalidRequestException(e);
+        } catch (AiravataClientException e) {
+            logger.error("Error in retrieving API version.");
+            throw new AiravataClientException(e);
+        } catch (AiravataSystemException e) {
+            logger.error("Error in retrieving API version.");
+            throw new AiravataSystemException(e);
+        } catch (TException e) {
+            logger.error("Error in retrieving API version.");
+            throw new TException(e);
+        }
+    }
+
+
+}


[2/8] airavata git commit: modified Airavata server side to secure the API.

Posted by sm...@apache.org.
modified Airavata server side to secure the API.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/14a1621a
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/14a1621a
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/14a1621a

Branch: refs/heads/master
Commit: 14a1621a8218d49e8b1fc775d62c1fe63e4b3983
Parents: 5c3c9bd
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Sat May 23 13:24:54 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Sat May 23 13:24:54 2015 +0530

----------------------------------------------------------------------
 .../security/AiravataSecurityManager.java       |  27 +
 .../DefaultAiravataSecurityManager.java         |  55 ++
 .../api/server/security/DefaultOAuthClient.java | 124 +++++
 .../api/server/security/Properties.java         |  27 +
 .../api/server/security/SecurityException.java  |  11 +
 .../server/security/SecurityManagerFactory.java |  32 ++
 .../airavata/model/security/AuthzToken.java     | 553 +++++++++++++++++++
 .../securityModel.thrift                        |  35 ++
 8 files changed, 864 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/AiravataSecurityManager.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/AiravataSecurityManager.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/AiravataSecurityManager.java
new file mode 100644
index 0000000..b39c951
--- /dev/null
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/AiravataSecurityManager.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.api.server.security;
+
+import org.apache.airavata.model.security.AuthzToken;
+
+public interface AiravataSecurityManager {
+    public boolean isUserAuthenticatedAndAuthorized(AuthzToken authzToken) throws SecurityException;
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java
new file mode 100644
index 0000000..c8aca68
--- /dev/null
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultAiravataSecurityManager.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.api.server.security;
+
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.model.security.AuthzToken;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO;
+
+/**
+ * This enforces authentication and authorization on Airavata API calls.
+ */
+public class DefaultAiravataSecurityManager implements AiravataSecurityManager {
+    private final static Logger logger = LoggerFactory.getLogger(DefaultAiravataSecurityManager.class);
+
+    public boolean isUserAuthenticatedAndAuthorized(AuthzToken authzToken) throws SecurityException {
+        try {
+            ConfigurationContext configContext =
+                    ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
+            //TODO:read following properties from server-settings.properties file.
+            DefaultOAuthClient oauthClient = new DefaultOAuthClient(ServerSettings.getRemoteOauthServerUrl(),
+                    ServerSettings.getAdminUsername(), ServerSettings.getAdminPassword(), configContext);
+            OAuth2TokenValidationResponseDTO validationResponse = oauthClient.validateAccessToken(
+                    authzToken.getAccessToken());
+            return validationResponse.getValid();
+        } catch (AxisFault axisFault) {
+            throw new SecurityException(axisFault.getMessage());
+        } catch (Exception exception) {
+            logger.error(exception.getCause().toString());
+            throw new SecurityException(exception.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java
new file mode 100644
index 0000000..d85f2bc
--- /dev/null
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java
@@ -0,0 +1,124 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.api.server.security;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
+import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO;
+import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken;
+import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.net.ssl.*;
+import java.rmi.RemoteException;
+
+/**
+ * This is the default OAuth Client that talks to WSO2 IS's OAuth Authentication Server
+ * to get the OAuth token validated.
+ */
+public class DefaultOAuthClient {
+    private OAuth2TokenValidationServiceStub stub;
+    private final static Logger logger = LoggerFactory.getLogger(DefaultOAuthClient.class);
+    public static final String BEARER_TOKEN_TYPE = "bearer";
+
+    /**
+     * OAuth2TokenValidationService Admin Service Client
+     *
+     * @param auhorizationServerURL
+     * @param username
+     * @param password
+     * @param configCtx
+     * @throws Exception
+     */
+    public DefaultOAuthClient(String auhorizationServerURL, String username, String password,
+                              ConfigurationContext configCtx) throws Exception {
+        String serviceURL = auhorizationServerURL + "OAuth2TokenValidationService";
+        try {
+            stub = new OAuth2TokenValidationServiceStub(configCtx, serviceURL);
+            CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, stub._getServiceClient());
+        } catch (AxisFault e) {
+            logger.error("Error initializing OAuth2 Client");
+            throw new Exception("Error initializing OAuth Client", e);
+        }
+
+        try {
+            // Get SSL context
+            SSLContext sc = SSLContext.getInstance("SSL");
+
+            // Create empty HostnameVerifier
+            HostnameVerifier hv = new HostnameVerifier() {
+                public boolean verify(String urlHostName, SSLSession session) {
+                    return true;
+                }
+            };
+            HttpsURLConnection.setDefaultHostnameVerifier(hv);
+
+            // Create a trust manager that does not validate certificate chains
+            TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+                public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+
+                public void checkClientTrusted(java.security.cert.X509Certificate[] certs,
+                                               String authType) {
+                }
+
+                public void checkServerTrusted(java.security.cert.X509Certificate[] certs,
+                                               String authType) {
+                }
+            }};
+
+            sc.init(null, trustAllCerts, new java.security.SecureRandom());
+            SSLContext.setDefault(sc);
+        } catch (Exception e) {
+            e.printStackTrace();
+            //ignore
+        }
+    }
+
+    /**
+     * Validates the OAuth 2.0 access token
+     *
+     * @param accessToken
+     * @return
+     * @throws Exception
+     */
+    public OAuth2TokenValidationResponseDTO validateAccessToken(String accessToken)
+            throws Exception {
+        OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
+        OAuth2TokenValidationRequestDTO_OAuth2AccessToken token =
+                new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
+        token.setIdentifier(accessToken);
+        token.setTokenType(BEARER_TOKEN_TYPE);
+        oauthReq.setAccessToken(token);
+        try {
+            return stub.validate(oauthReq);
+        } catch (RemoteException e) {
+            logger.error("Error while validating OAuth2 request");
+            throw new Exception("Error while validating OAuth2 request", e);
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java
new file mode 100644
index 0000000..b6e5a39
--- /dev/null
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.api.server.security;
+
+public class Properties {
+    public static String oauthAuthzServerURL = "https://localhost:9443/services/";
+    public static String userName = "admin";
+    public static String password = "admin";
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityException.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityException.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityException.java
new file mode 100644
index 0000000..8d22658
--- /dev/null
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityException.java
@@ -0,0 +1,11 @@
+package org.apache.airavata.api.server.security;
+
+public class SecurityException extends Exception {
+    public SecurityException(String message) {
+        super(message);
+    }
+
+    public SecurityException() {
+        super();
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityManagerFactory.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityManagerFactory.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityManagerFactory.java
new file mode 100644
index 0000000..9e71b93
--- /dev/null
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/SecurityManagerFactory.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.api.server.security;
+
+/**
+ * This initializes an instance of the appropriate security manager according to the
+ * configuration.
+ */
+public class SecurityManagerFactory {
+    public static AiravataSecurityManager getSecurityManager(){
+        //TODO:read from configuration and create the appropriate security manager.
+        return new DefaultAiravataSecurityManager();
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/security/AuthzToken.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/security/AuthzToken.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/security/AuthzToken.java
new file mode 100644
index 0000000..cf05dd8
--- /dev/null
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/security/AuthzToken.java
@@ -0,0 +1,553 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.airavata.model.security;
+
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all") public class AuthzToken implements org.apache.thrift.TBase<AuthzToken, AuthzToken._Fields>, java.io.Serializable, Cloneable, Comparable<AuthzToken> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthzToken");
+
+  private static final org.apache.thrift.protocol.TField ACCESS_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("accessToken", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField CLAIMS_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("claimsMap", org.apache.thrift.protocol.TType.MAP, (short)2);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new AuthzTokenStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new AuthzTokenTupleSchemeFactory());
+  }
+
+  private String accessToken; // required
+  private Map<String,String> claimsMap; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    ACCESS_TOKEN((short)1, "accessToken"),
+    CLAIMS_MAP((short)2, "claimsMap");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // ACCESS_TOKEN
+          return ACCESS_TOKEN;
+        case 2: // CLAIMS_MAP
+          return CLAIMS_MAP;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+  private _Fields optionals[] = {_Fields.CLAIMS_MAP};
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.ACCESS_TOKEN, new org.apache.thrift.meta_data.FieldMetaData("accessToken", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.CLAIMS_MAP, new org.apache.thrift.meta_data.FieldMetaData("claimsMap", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthzToken.class, metaDataMap);
+  }
+
+  public AuthzToken() {
+  }
+
+  public AuthzToken(
+    String accessToken)
+  {
+    this();
+    this.accessToken = accessToken;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public AuthzToken(AuthzToken other) {
+    if (other.isSetAccessToken()) {
+      this.accessToken = other.accessToken;
+    }
+    if (other.isSetClaimsMap()) {
+      Map<String,String> __this__claimsMap = new HashMap<String,String>(other.claimsMap);
+      this.claimsMap = __this__claimsMap;
+    }
+  }
+
+  public AuthzToken deepCopy() {
+    return new AuthzToken(this);
+  }
+
+  @Override
+  public void clear() {
+    this.accessToken = null;
+    this.claimsMap = null;
+  }
+
+  public String getAccessToken() {
+    return this.accessToken;
+  }
+
+  public void setAccessToken(String accessToken) {
+    this.accessToken = accessToken;
+  }
+
+  public void unsetAccessToken() {
+    this.accessToken = null;
+  }
+
+  /** Returns true if field accessToken is set (has been assigned a value) and false otherwise */
+  public boolean isSetAccessToken() {
+    return this.accessToken != null;
+  }
+
+  public void setAccessTokenIsSet(boolean value) {
+    if (!value) {
+      this.accessToken = null;
+    }
+  }
+
+  public int getClaimsMapSize() {
+    return (this.claimsMap == null) ? 0 : this.claimsMap.size();
+  }
+
+  public void putToClaimsMap(String key, String val) {
+    if (this.claimsMap == null) {
+      this.claimsMap = new HashMap<String,String>();
+    }
+    this.claimsMap.put(key, val);
+  }
+
+  public Map<String,String> getClaimsMap() {
+    return this.claimsMap;
+  }
+
+  public void setClaimsMap(Map<String,String> claimsMap) {
+    this.claimsMap = claimsMap;
+  }
+
+  public void unsetClaimsMap() {
+    this.claimsMap = null;
+  }
+
+  /** Returns true if field claimsMap is set (has been assigned a value) and false otherwise */
+  public boolean isSetClaimsMap() {
+    return this.claimsMap != null;
+  }
+
+  public void setClaimsMapIsSet(boolean value) {
+    if (!value) {
+      this.claimsMap = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case ACCESS_TOKEN:
+      if (value == null) {
+        unsetAccessToken();
+      } else {
+        setAccessToken((String)value);
+      }
+      break;
+
+    case CLAIMS_MAP:
+      if (value == null) {
+        unsetClaimsMap();
+      } else {
+        setClaimsMap((Map<String,String>)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case ACCESS_TOKEN:
+      return getAccessToken();
+
+    case CLAIMS_MAP:
+      return getClaimsMap();
+
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+    case ACCESS_TOKEN:
+      return isSetAccessToken();
+    case CLAIMS_MAP:
+      return isSetClaimsMap();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof AuthzToken)
+      return this.equals((AuthzToken)that);
+    return false;
+  }
+
+  public boolean equals(AuthzToken that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_accessToken = true && this.isSetAccessToken();
+    boolean that_present_accessToken = true && that.isSetAccessToken();
+    if (this_present_accessToken || that_present_accessToken) {
+      if (!(this_present_accessToken && that_present_accessToken))
+        return false;
+      if (!this.accessToken.equals(that.accessToken))
+        return false;
+    }
+
+    boolean this_present_claimsMap = true && this.isSetClaimsMap();
+    boolean that_present_claimsMap = true && that.isSetClaimsMap();
+    if (this_present_claimsMap || that_present_claimsMap) {
+      if (!(this_present_claimsMap && that_present_claimsMap))
+        return false;
+      if (!this.claimsMap.equals(that.claimsMap))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  @Override
+  public int compareTo(AuthzToken other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetAccessToken()).compareTo(other.isSetAccessToken());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetAccessToken()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.accessToken, other.accessToken);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetClaimsMap()).compareTo(other.isSetClaimsMap());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetClaimsMap()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.claimsMap, other.claimsMap);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("AuthzToken(");
+    boolean first = true;
+
+    sb.append("accessToken:");
+    if (this.accessToken == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.accessToken);
+    }
+    first = false;
+    if (isSetClaimsMap()) {
+      if (!first) sb.append(", ");
+      sb.append("claimsMap:");
+      if (this.claimsMap == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.claimsMap);
+      }
+      first = false;
+    }
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetAccessToken()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'accessToken' is unset! Struct:" + toString());
+    }
+
+    // check for sub-struct validity
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+    try {
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private static class AuthzTokenStandardSchemeFactory implements SchemeFactory {
+    public AuthzTokenStandardScheme getScheme() {
+      return new AuthzTokenStandardScheme();
+    }
+  }
+
+  private static class AuthzTokenStandardScheme extends StandardScheme<AuthzToken> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, AuthzToken struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TField schemeField;
+      iprot.readStructBegin();
+      while (true)
+      {
+        schemeField = iprot.readFieldBegin();
+        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          break;
+        }
+        switch (schemeField.id) {
+          case 1: // ACCESS_TOKEN
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.accessToken = iprot.readString();
+              struct.setAccessTokenIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // CLAIMS_MAP
+            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
+              {
+                org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin();
+                struct.claimsMap = new HashMap<String,String>(2*_map0.size);
+                for (int _i1 = 0; _i1 < _map0.size; ++_i1)
+                {
+                  String _key2;
+                  String _val3;
+                  _key2 = iprot.readString();
+                  _val3 = iprot.readString();
+                  struct.claimsMap.put(_key2, _val3);
+                }
+                iprot.readMapEnd();
+              }
+              struct.setClaimsMapIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          default:
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+        }
+        iprot.readFieldEnd();
+      }
+      iprot.readStructEnd();
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, AuthzToken struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.accessToken != null) {
+        oprot.writeFieldBegin(ACCESS_TOKEN_FIELD_DESC);
+        oprot.writeString(struct.accessToken);
+        oprot.writeFieldEnd();
+      }
+      if (struct.claimsMap != null) {
+        if (struct.isSetClaimsMap()) {
+          oprot.writeFieldBegin(CLAIMS_MAP_FIELD_DESC);
+          {
+            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.claimsMap.size()));
+            for (Map.Entry<String, String> _iter4 : struct.claimsMap.entrySet())
+            {
+              oprot.writeString(_iter4.getKey());
+              oprot.writeString(_iter4.getValue());
+            }
+            oprot.writeMapEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class AuthzTokenTupleSchemeFactory implements SchemeFactory {
+    public AuthzTokenTupleScheme getScheme() {
+      return new AuthzTokenTupleScheme();
+    }
+  }
+
+  private static class AuthzTokenTupleScheme extends TupleScheme<AuthzToken> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, AuthzToken struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      oprot.writeString(struct.accessToken);
+      BitSet optionals = new BitSet();
+      if (struct.isSetClaimsMap()) {
+        optionals.set(0);
+      }
+      oprot.writeBitSet(optionals, 1);
+      if (struct.isSetClaimsMap()) {
+        {
+          oprot.writeI32(struct.claimsMap.size());
+          for (Map.Entry<String, String> _iter5 : struct.claimsMap.entrySet())
+          {
+            oprot.writeString(_iter5.getKey());
+            oprot.writeString(_iter5.getValue());
+          }
+        }
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, AuthzToken struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      struct.accessToken = iprot.readString();
+      struct.setAccessTokenIsSet(true);
+      BitSet incoming = iprot.readBitSet(1);
+      if (incoming.get(0)) {
+        {
+          org.apache.thrift.protocol.TMap _map6 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+          struct.claimsMap = new HashMap<String,String>(2*_map6.size);
+          for (int _i7 = 0; _i7 < _map6.size; ++_i7)
+          {
+            String _key8;
+            String _val9;
+            _key8 = iprot.readString();
+            _val9 = iprot.readString();
+            struct.claimsMap.put(_key8, _val9);
+          }
+        }
+        struct.setClaimsMapIsSet(true);
+      }
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/airavata/blob/14a1621a/airavata-api/thrift-interface-descriptions/securityModel.thrift
----------------------------------------------------------------------
diff --git a/airavata-api/thrift-interface-descriptions/securityModel.thrift b/airavata-api/thrift-interface-descriptions/securityModel.thrift
new file mode 100644
index 0000000..bda9554
--- /dev/null
+++ b/airavata-api/thrift-interface-descriptions/securityModel.thrift
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+namespace java org.apache.airavata.model.security
+namespace php Airavata.Model.Security
+namespace cpp apache.airavata.model.security
+namespace py apache.airavata.model.security
+
+/*
+ * This file describes the definitions of the security model which encapsulates the information that needs to be passed
+  to the API methods in order to authenticate and authorize the users.
+ *
+*/
+
+struct AuthzToken {
+    1: required string accessToken,
+    2: optional map<string, string> claimsMap
+}
\ No newline at end of file


[5/8] airavata git commit: updated the master to 0.16 Airavata, and merged the branch sprint1

Posted by sm...@apache.org.
updated the master to 0.16 Airavata, and merged the branch sprint1


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/0c1ff519
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/0c1ff519
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/0c1ff519

Branch: refs/heads/master
Commit: 0c1ff519a03da0ae2125469eaedcd11009a8e6b4
Parents: b67b532 b62a56a
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Tue Jun 2 14:23:26 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Tue Jun 2 14:23:26 2015 +0530

----------------------------------------------------------------------
 airavata-api/airavata-api-server/pom.xml        |  20 +
 .../server/handler/AiravataServerHandler.java   |  29 +-
 .../security/AiravataSecurityManager.java       |  27 +
 .../DefaultAiravataSecurityManager.java         |  55 ++
 .../api/server/security/DefaultOAuthClient.java | 124 +++++
 .../api/server/security/Properties.java         |  27 +
 .../api/server/security/SecurityException.java  |  11 +
 .../server/security/SecurityManagerFactory.java |  32 ++
 .../java/org/apache/airavata/api/Airavata.java  | 258 ++++++++-
 .../client/samples/CreateLaunchBES.java         |   2 +-
 .../client/samples/CreateLaunchExperiment.java  |   4 +-
 .../samples/CreateLaunchExperimentUS3.java      |   2 +-
 .../samples/TestCreateLaunchExperiment.java     |   3 +-
 .../tools/RegisterOGCEUS3Application.java       |   2 +-
 .../tools/RegisterSampleApplications.java       |   2 +-
 .../client/tools/RegisterUS3Application.java    |   2 +-
 .../airavata/model/security/AuthzToken.java     | 553 +++++++++++++++++++
 .../airavataAPI.thrift                          |   6 +-
 .../airavataDataModel.thrift                    |   1 +
 .../securityModel.thrift                        |  35 ++
 .../apache/airavata/common/utils/Constants.java |   5 +
 .../airavata/common/utils/ServerSettings.java   |  15 +
 .../main/resources/airavata-server.properties   |   8 +
 .../apache/airavata/integration/BaseCaseIT.java |   2 +-
 .../WorkflowIntegrationTestBase.java            |   2 +
 pom.xml                                         |   1 +
 samples/java-client/experiment/pom.xml          |   2 +-
 samples/java-client/pom.xml                     |   7 +-
 samples/java-client/secure-client/pom.xml       | 110 ++++
 .../sample/AiravataSecurityException.java       |  31 ++
 .../sample/OAuthAppRegisteringClient.java       | 109 ++++
 .../sample/OAuthTokenRetrievalClient.java       |  87 +++
 .../airavata/secure/sample/Properties.java      |  42 ++
 .../airavata/secure/sample/SecureClient.java    | 152 +++++
 34 files changed, 1733 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/airavata-api/airavata-api-server/pom.xml
----------------------------------------------------------------------
diff --cc airavata-api/airavata-api-server/pom.xml
index e91f3fb,b4af842..64b436b
--- a/airavata-api/airavata-api-server/pom.xml
+++ b/airavata-api/airavata-api-server/pom.xml
@@@ -82,10 -82,25 +82,30 @@@
              <version>${org.slf4j.version}</version>
          </dependency>
          <dependency>
 +            <groupId>org.apache.curator</groupId>
 +            <artifactId>curator-framework</artifactId>
 +            <version>${curator.version}</version>
 +        </dependency>
++        <dependency>
+             <groupId>org.wso2.carbon</groupId>
+             <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
+             <version>4.2.3</version>
+         </dependency>
+         <dependency>
+             <groupId>org.apache.axis2.wso2</groupId>
+             <artifactId>axis2</artifactId>
+             <version>1.6.1.wso2v4</version>
+         </dependency>
+         <dependency>
+             <groupId>org.apache.httpcomponents</groupId>
+             <artifactId>httpclient</artifactId>
+             <version>4.4</version>
+         </dependency>
+         <dependency>
+             <groupId>org.wso2.carbon</groupId>
+             <artifactId>org.wso2.carbon.utils</artifactId>
+             <version>4.2.0</version>
+         </dependency>
      </dependencies>
  
  </project>

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java
----------------------------------------------------------------------
diff --cc airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java
index 0000000,d85f2bc..3f2e32f
mode 000000,100644..100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/DefaultOAuthClient.java
@@@ -1,0 -1,124 +1,124 @@@
+ /*
+  *
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  *
+  */
+ package org.apache.airavata.api.server.security;
+ 
+ import org.apache.axis2.AxisFault;
+ import org.apache.axis2.context.ConfigurationContext;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
+ import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO;
+ import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken;
+ import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO;
+ import org.wso2.carbon.utils.CarbonUtils;
+ 
+ import javax.net.ssl.*;
+ import java.rmi.RemoteException;
+ 
+ /**
+  * This is the default OAuth Client that talks to WSO2 IS's OAuth Authentication Server
+  * to get the OAuth token validated.
+  */
+ public class DefaultOAuthClient {
+     private OAuth2TokenValidationServiceStub stub;
+     private final static Logger logger = LoggerFactory.getLogger(DefaultOAuthClient.class);
+     public static final String BEARER_TOKEN_TYPE = "bearer";
+ 
+     /**
+      * OAuth2TokenValidationService Admin Service Client
+      *
+      * @param auhorizationServerURL
+      * @param username
+      * @param password
+      * @param configCtx
+      * @throws Exception
+      */
+     public DefaultOAuthClient(String auhorizationServerURL, String username, String password,
+                               ConfigurationContext configCtx) throws Exception {
+         String serviceURL = auhorizationServerURL + "OAuth2TokenValidationService";
+         try {
+             stub = new OAuth2TokenValidationServiceStub(configCtx, serviceURL);
+             CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, stub._getServiceClient());
+         } catch (AxisFault e) {
+             logger.error("Error initializing OAuth2 Client");
+             throw new Exception("Error initializing OAuth Client", e);
+         }
 -
++        //TODO:Import the WSO2 IS cert into Airavata trust store.
+         try {
+             // Get SSL context
+             SSLContext sc = SSLContext.getInstance("SSL");
+ 
+             // Create empty HostnameVerifier
+             HostnameVerifier hv = new HostnameVerifier() {
+                 public boolean verify(String urlHostName, SSLSession session) {
+                     return true;
+                 }
+             };
+             HttpsURLConnection.setDefaultHostnameVerifier(hv);
+ 
+             // Create a trust manager that does not validate certificate chains
+             TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+                 public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+                     return null;
+                 }
+ 
+                 public void checkClientTrusted(java.security.cert.X509Certificate[] certs,
+                                                String authType) {
+                 }
+ 
+                 public void checkServerTrusted(java.security.cert.X509Certificate[] certs,
+                                                String authType) {
+                 }
+             }};
+ 
+             sc.init(null, trustAllCerts, new java.security.SecureRandom());
+             SSLContext.setDefault(sc);
+         } catch (Exception e) {
+             e.printStackTrace();
+             //ignore
+         }
+     }
+ 
+     /**
+      * Validates the OAuth 2.0 access token
+      *
+      * @param accessToken
+      * @return
+      * @throws Exception
+      */
+     public OAuth2TokenValidationResponseDTO validateAccessToken(String accessToken)
+             throws Exception {
+         OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
+         OAuth2TokenValidationRequestDTO_OAuth2AccessToken token =
+                 new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
+         token.setIdentifier(accessToken);
+         token.setTokenType(BEARER_TOKEN_TYPE);
+         oauthReq.setAccessToken(token);
+         try {
+             return stub.validate(oauthReq);
+         } catch (RemoteException e) {
+             logger.error("Error while validating OAuth2 request");
+             throw new Exception("Error while validating OAuth2 request", e);
+         }
+     }
+ 
+ 
+ }

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
----------------------------------------------------------------------
diff --cc airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
index 7ffa368,6e70510..44b9230
--- a/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
+++ b/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
@@@ -23723,1018 -23688,9 +23890,1075 @@@ import org.slf4j.LoggerFactory
        case ASE:
          return getAse();
  
 -      case AE:
 -        return getAe();
 -
++      case AE:
++        return getAe();
++
 +      }
 +      throw new IllegalStateException();
 +    }
 +
 +    /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
 +    public boolean isSet(_Fields field) {
 +      if (field == null) {
 +        throw new IllegalArgumentException();
 +      }
 +
 +      switch (field) {
 +      case SUCCESS:
 +        return isSetSuccess();
 +      case IRE:
 +        return isSetIre();
 +      case ACE:
 +        return isSetAce();
 +      case ASE:
 +        return isSetAse();
++      case AE:
++        return isSetAe();
 +      }
 +      throw new IllegalStateException();
 +    }
 +
 +    @Override
 +    public boolean equals(Object that) {
 +      if (that == null)
 +        return false;
 +      if (that instanceof getAPIVersion_result)
 +        return this.equals((getAPIVersion_result)that);
 +      return false;
 +    }
 +
 +    public boolean equals(getAPIVersion_result that) {
 +      if (that == null)
 +        return false;
 +
 +      boolean this_present_success = true && this.isSetSuccess();
 +      boolean that_present_success = true && that.isSetSuccess();
 +      if (this_present_success || that_present_success) {
 +        if (!(this_present_success && that_present_success))
 +          return false;
 +        if (!this.success.equals(that.success))
 +          return false;
 +      }
 +
 +      boolean this_present_ire = true && this.isSetIre();
 +      boolean that_present_ire = true && that.isSetIre();
 +      if (this_present_ire || that_present_ire) {
 +        if (!(this_present_ire && that_present_ire))
 +          return false;
 +        if (!this.ire.equals(that.ire))
 +          return false;
 +      }
 +
 +      boolean this_present_ace = true && this.isSetAce();
 +      boolean that_present_ace = true && that.isSetAce();
 +      if (this_present_ace || that_present_ace) {
 +        if (!(this_present_ace && that_present_ace))
 +          return false;
 +        if (!this.ace.equals(that.ace))
 +          return false;
 +      }
 +
 +      boolean this_present_ase = true && this.isSetAse();
 +      boolean that_present_ase = true && that.isSetAse();
 +      if (this_present_ase || that_present_ase) {
 +        if (!(this_present_ase && that_present_ase))
 +          return false;
 +        if (!this.ase.equals(that.ase))
 +          return false;
 +      }
 +
++      boolean this_present_ae = true && this.isSetAe();
++      boolean that_present_ae = true && that.isSetAe();
++      if (this_present_ae || that_present_ae) {
++        if (!(this_present_ae && that_present_ae))
++          return false;
++        if (!this.ae.equals(that.ae))
++          return false;
++      }
++
 +      return true;
 +    }
 +
 +    @Override
 +    public int hashCode() {
 +      return 0;
 +    }
 +
 +    @Override
 +    public int compareTo(getAPIVersion_result other) {
 +      if (!getClass().equals(other.getClass())) {
 +        return getClass().getName().compareTo(other.getClass().getName());
 +      }
 +
 +      int lastComparison = 0;
 +
 +      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +      if (isSetSuccess()) {
 +        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
 +        if (lastComparison != 0) {
 +          return lastComparison;
 +        }
 +      }
 +      lastComparison = Boolean.valueOf(isSetIre()).compareTo(other.isSetIre());
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +      if (isSetIre()) {
 +        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ire, other.ire);
 +        if (lastComparison != 0) {
 +          return lastComparison;
 +        }
 +      }
 +      lastComparison = Boolean.valueOf(isSetAce()).compareTo(other.isSetAce());
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +      if (isSetAce()) {
 +        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ace, other.ace);
 +        if (lastComparison != 0) {
 +          return lastComparison;
 +        }
 +      }
 +      lastComparison = Boolean.valueOf(isSetAse()).compareTo(other.isSetAse());
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +      if (isSetAse()) {
 +        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ase, other.ase);
 +        if (lastComparison != 0) {
 +          return lastComparison;
 +        }
 +      }
++      lastComparison = Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
++      if (lastComparison != 0) {
++        return lastComparison;
++      }
++      if (isSetAe()) {
++        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
++        if (lastComparison != 0) {
++          return lastComparison;
++        }
++      }
 +      return 0;
 +    }
 +
 +    public _Fields fieldForId(int fieldId) {
 +      return _Fields.findByThriftId(fieldId);
 +    }
 +
 +    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
 +      schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
 +    }
 +
 +    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
 +      schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
 +      }
 +
 +    @Override
 +    public String toString() {
 +      StringBuilder sb = new StringBuilder("getAPIVersion_result(");
 +      boolean first = true;
 +
 +      sb.append("success:");
 +      if (this.success == null) {
 +        sb.append("null");
 +      } else {
 +        sb.append(this.success);
 +      }
 +      first = false;
 +      if (!first) sb.append(", ");
 +      sb.append("ire:");
 +      if (this.ire == null) {
 +        sb.append("null");
 +      } else {
 +        sb.append(this.ire);
 +      }
 +      first = false;
 +      if (!first) sb.append(", ");
 +      sb.append("ace:");
 +      if (this.ace == null) {
 +        sb.append("null");
 +      } else {
 +        sb.append(this.ace);
 +      }
 +      first = false;
 +      if (!first) sb.append(", ");
 +      sb.append("ase:");
 +      if (this.ase == null) {
 +        sb.append("null");
 +      } else {
 +        sb.append(this.ase);
 +      }
 +      first = false;
++      if (!first) sb.append(", ");
++      sb.append("ae:");
++      if (this.ae == null) {
++        sb.append("null");
++      } else {
++        sb.append(this.ae);
++      }
++      first = false;
 +      sb.append(")");
 +      return sb.toString();
 +    }
 +
 +    public void validate() throws org.apache.thrift.TException {
 +      // check for required fields
 +      // check for sub-struct validity
 +    }
 +
 +    private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
 +      try {
 +        write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
 +      } catch (org.apache.thrift.TException te) {
 +        throw new java.io.IOException(te);
 +      }
 +    }
 +
 +    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
 +      try {
 +        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
 +      } catch (org.apache.thrift.TException te) {
 +        throw new java.io.IOException(te);
 +      }
 +    }
 +
 +    private static class getAPIVersion_resultStandardSchemeFactory implements SchemeFactory {
 +      public getAPIVersion_resultStandardScheme getScheme() {
 +        return new getAPIVersion_resultStandardScheme();
 +      }
 +    }
 +
 +    private static class getAPIVersion_resultStandardScheme extends StandardScheme<getAPIVersion_result> {
 +
 +      public void read(org.apache.thrift.protocol.TProtocol iprot, getAPIVersion_result struct) throws org.apache.thrift.TException {
 +        org.apache.thrift.protocol.TField schemeField;
 +        iprot.readStructBegin();
 +        while (true)
 +        {
 +          schemeField = iprot.readFieldBegin();
 +          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
 +            break;
 +          }
 +          switch (schemeField.id) {
 +            case 0: // SUCCESS
 +              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +                struct.success = iprot.readString();
 +                struct.setSuccessIsSet(true);
 +              } else { 
 +                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +              }
 +              break;
 +            case 1: // IRE
 +              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
 +                struct.ire = new org.apache.airavata.model.error.InvalidRequestException();
 +                struct.ire.read(iprot);
 +                struct.setIreIsSet(true);
 +              } else { 
 +                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +              }
 +              break;
 +            case 2: // ACE
 +              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
 +                struct.ace = new org.apache.airavata.model.error.AiravataClientException();
 +                struct.ace.read(iprot);
 +                struct.setAceIsSet(true);
 +              } else { 
 +                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +              }
 +              break;
 +            case 3: // ASE
 +              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
 +                struct.ase = new org.apache.airavata.model.error.AiravataSystemException();
 +                struct.ase.read(iprot);
 +                struct.setAseIsSet(true);
 +              } else { 
 +                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +              }
 +              break;
++            case 4: // AE
++              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
++                struct.ae = new org.apache.airavata.model.error.AuthorizationException();
++                struct.ae.read(iprot);
++                struct.setAeIsSet(true);
++              } else { 
++                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
++              }
++              break;
 +            default:
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +          }
 +          iprot.readFieldEnd();
 +        }
 +        iprot.readStructEnd();
 +
 +        // check for required fields of primitive type, which can't be checked in the validate method
 +        struct.validate();
 +      }
 +
 +      public void write(org.apache.thrift.protocol.TProtocol oprot, getAPIVersion_result struct) throws org.apache.thrift.TException {
 +        struct.validate();
 +
 +        oprot.writeStructBegin(STRUCT_DESC);
 +        if (struct.success != null) {
 +          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
 +          oprot.writeString(struct.success);
 +          oprot.writeFieldEnd();
 +        }
 +        if (struct.ire != null) {
 +          oprot.writeFieldBegin(IRE_FIELD_DESC);
 +          struct.ire.write(oprot);
 +          oprot.writeFieldEnd();
 +        }
 +        if (struct.ace != null) {
 +          oprot.writeFieldBegin(ACE_FIELD_DESC);
 +          struct.ace.write(oprot);
 +          oprot.writeFieldEnd();
 +        }
 +        if (struct.ase != null) {
 +          oprot.writeFieldBegin(ASE_FIELD_DESC);
 +          struct.ase.write(oprot);
 +          oprot.writeFieldEnd();
 +        }
++        if (struct.ae != null) {
++          oprot.writeFieldBegin(AE_FIELD_DESC);
++          struct.ae.write(oprot);
++          oprot.writeFieldEnd();
++        }
 +        oprot.writeFieldStop();
 +        oprot.writeStructEnd();
 +      }
 +
 +    }
 +
 +    private static class getAPIVersion_resultTupleSchemeFactory implements SchemeFactory {
 +      public getAPIVersion_resultTupleScheme getScheme() {
 +        return new getAPIVersion_resultTupleScheme();
 +      }
 +    }
 +
 +    private static class getAPIVersion_resultTupleScheme extends TupleScheme<getAPIVersion_result> {
 +
 +      @Override
 +      public void write(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_result struct) throws org.apache.thrift.TException {
 +        TTupleProtocol oprot = (TTupleProtocol) prot;
 +        BitSet optionals = new BitSet();
 +        if (struct.isSetSuccess()) {
 +          optionals.set(0);
 +        }
 +        if (struct.isSetIre()) {
 +          optionals.set(1);
 +        }
 +        if (struct.isSetAce()) {
 +          optionals.set(2);
 +        }
 +        if (struct.isSetAse()) {
 +          optionals.set(3);
 +        }
-         oprot.writeBitSet(optionals, 4);
++        if (struct.isSetAe()) {
++          optionals.set(4);
++        }
++        oprot.writeBitSet(optionals, 5);
 +        if (struct.isSetSuccess()) {
 +          oprot.writeString(struct.success);
 +        }
 +        if (struct.isSetIre()) {
 +          struct.ire.write(oprot);
 +        }
 +        if (struct.isSetAce()) {
 +          struct.ace.write(oprot);
 +        }
 +        if (struct.isSetAse()) {
 +          struct.ase.write(oprot);
 +        }
++        if (struct.isSetAe()) {
++          struct.ae.write(oprot);
++        }
 +      }
 +
 +      @Override
 +      public void read(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_result struct) throws org.apache.thrift.TException {
 +        TTupleProtocol iprot = (TTupleProtocol) prot;
-         BitSet incoming = iprot.readBitSet(4);
++        BitSet incoming = iprot.readBitSet(5);
 +        if (incoming.get(0)) {
 +          struct.success = iprot.readString();
 +          struct.setSuccessIsSet(true);
 +        }
 +        if (incoming.get(1)) {
 +          struct.ire = new org.apache.airavata.model.error.InvalidRequestException();
 +          struct.ire.read(iprot);
 +          struct.setIreIsSet(true);
 +        }
 +        if (incoming.get(2)) {
 +          struct.ace = new org.apache.airavata.model.error.AiravataClientException();
 +          struct.ace.read(iprot);
 +          struct.setAceIsSet(true);
 +        }
 +        if (incoming.get(3)) {
 +          struct.ase = new org.apache.airavata.model.error.AiravataSystemException();
 +          struct.ase.read(iprot);
 +          struct.setAseIsSet(true);
 +        }
++        if (incoming.get(4)) {
++          struct.ae = new org.apache.airavata.model.error.AuthorizationException();
++          struct.ae.read(iprot);
++          struct.setAeIsSet(true);
++        }
 +      }
 +    }
 +
 +  }
 +
 +  public static class addGateway_args implements org.apache.thrift.TBase<addGateway_args, addGateway_args._Fields>, java.io.Serializable, Cloneable, Comparable<addGateway_args>   {
 +    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("addGateway_args");
 +
 +    private static final org.apache.thrift.protocol.TField GATEWAY_FIELD_DESC = new org.apache.thrift.protocol.TField("gateway", org.apache.thrift.protocol.TType.STRUCT, (short)1);
 +
 +    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
 +    static {
 +      schemes.put(StandardScheme.class, new addGateway_argsStandardSchemeFactory());
 +      schemes.put(TupleScheme.class, new addGateway_argsTupleSchemeFactory());
 +    }
 +
 +    public org.apache.airavata.model.workspace.Gateway gateway; // required
 +
 +    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
 +    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
 +      GATEWAY((short)1, "gateway");
 +
 +      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 +
 +      static {
 +        for (_Fields field : EnumSet.allOf(_Fields.class)) {
 +          byName.put(field.getFieldName(), field);
 +        }
 +      }
 +
 +      /**
 +       * Find the _Fields constant that matches fieldId, or null if its not found.
 +       */
 +      public static _Fields findByThriftId(int fieldId) {
 +        switch(fieldId) {
 +          case 1: // GATEWAY
 +            return GATEWAY;
 +          default:
 +            return null;
 +        }
 +      }
 +
 +      /**
 +       * Find the _Fields constant that matches fieldId, throwing an exception
 +       * if it is not found.
 +       */
 +      public static _Fields findByThriftIdOrThrow(int fieldId) {
 +        _Fields fields = findByThriftId(fieldId);
 +        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
 +        return fields;
 +      }
 +
 +      /**
 +       * Find the _Fields constant that matches name, or null if its not found.
 +       */
 +      public static _Fields findByName(String name) {
 +        return byName.get(name);
 +      }
 +
 +      private final short _thriftId;
 +      private final String _fieldName;
 +
 +      _Fields(short thriftId, String fieldName) {
 +        _thriftId = thriftId;
 +        _fieldName = fieldName;
 +      }
 +
 +      public short getThriftFieldId() {
 +        return _thriftId;
 +      }
 +
 +      public String getFieldName() {
 +        return _fieldName;
 +      }
 +    }
 +
 +    // isset id assignments
 +    public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
 +    static {
 +      Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
 +      tmpMap.put(_Fields.GATEWAY, new org.apache.thrift.meta_data.FieldMetaData("gateway", org.apache.thrift.TFieldRequirementType.REQUIRED, 
 +          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.workspace.Gateway.class)));
 +      metaDataMap = Collections.unmodifiableMap(tmpMap);
 +      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(addGateway_args.class, metaDataMap);
 +    }
 +
 +    public addGateway_args() {
 +    }
 +
 +    public addGateway_args(
 +      org.apache.airavata.model.workspace.Gateway gateway)
 +    {
 +      this();
 +      this.gateway = gateway;
 +    }
 +
 +    /**
 +     * Performs a deep copy on <i>other</i>.
 +     */
 +    public addGateway_args(addGateway_args other) {
 +      if (other.isSetGateway()) {
 +        this.gateway = new org.apache.airavata.model.workspace.Gateway(other.gateway);
 +      }
 +    }
 +
 +    public addGateway_args deepCopy() {
 +      return new addGateway_args(this);
 +    }
 +
 +    @Override
 +    public void clear() {
 +      this.gateway = null;
 +    }
 +
 +    public org.apache.airavata.model.workspace.Gateway getGateway() {
 +      return this.gateway;
 +    }
 +
 +    public addGateway_args setGateway(org.apache.airavata.model.workspace.Gateway gateway) {
 +      this.gateway = gateway;
 +      return this;
 +    }
 +
 +    public void unsetGateway() {
 +      this.gateway = null;
 +    }
 +
 +    /** Returns true if field gateway is set (has been assigned a value) and false otherwise */
 +    public boolean isSetGateway() {
 +      return this.gateway != null;
 +    }
 +
 +    public void setGatewayIsSet(boolean value) {
 +      if (!value) {
 +        this.gateway = null;
 +      }
 +    }
 +
 +    public void setFieldValue(_Fields field, Object value) {
 +      switch (field) {
 +      case GATEWAY:
 +        if (value == null) {
 +          unsetGateway();
 +        } else {
 +          setGateway((org.apache.airavata.model.workspace.Gateway)value);
 +        }
 +        break;
 +
 +      }
 +    }
 +
 +    public Object getFieldValue(_Fields field) {
 +      switch (field) {
 +      case GATEWAY:
 +        return getGateway();
 +
 +      }
 +      throw new IllegalStateException();
 +    }
 +
 +    /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
 +    public boolean isSet(_Fields field) {
 +      if (field == null) {
 +        throw new IllegalArgumentException();
 +      }
 +
 +      switch (field) {
 +      case GATEWAY:
 +        return isSetGateway();
 +      }
 +      throw new IllegalStateException();
 +    }
 +
 +    @Override
 +    public boolean equals(Object that) {
 +      if (that == null)
 +        return false;
 +      if (that instanceof addGateway_args)
 +        return this.equals((addGateway_args)that);
 +      return false;
 +    }
 +
 +    public boolean equals(addGateway_args that) {
 +      if (that == null)
 +        return false;
 +
 +      boolean this_present_gateway = true && this.isSetGateway();
 +      boolean that_present_gateway = true && that.isSetGateway();
 +      if (this_present_gateway || that_present_gateway) {
 +        if (!(this_present_gateway && that_present_gateway))
 +          return false;
 +        if (!this.gateway.equals(that.gateway))
 +          return false;
 +      }
 +
 +      return true;
 +    }
 +
 +    @Override
 +    public int hashCode() {
 +      return 0;
 +    }
 +
 +    @Override
 +    public int compareTo(addGateway_args other) {
 +      if (!getClass().equals(other.getClass())) {
 +        return getClass().getName().compareTo(other.getClass().getName());
 +      }
 +
 +      int lastComparison = 0;
 +
 +      lastComparison = Boolean.valueOf(isSetGateway()).compareTo(other.isSetGateway());
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +      if (isSetGateway()) {
 +        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.gateway, other.gateway);
 +        if (lastComparison != 0) {
 +          return lastComparison;
 +        }
 +      }
 +      return 0;
 +    }
 +
 +    public _Fields fieldForId(int fieldId) {
 +      return _Fields.findByThriftId(fieldId);
 +    }
 +
 +    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
 +      schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
 +    }
 +
 +    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
 +      schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
 +    }
 +
 +    @Override
 +    public String toString() {
 +      StringBuilder sb = new StringBuilder("addGateway_args(");
 +      boolean first = true;
 +
 +      sb.append("gateway:");
 +      if (this.gateway == null) {
 +        sb.append("null");
 +      } else {
 +        sb.append(this.gateway);
 +      }
 +      first = false;
 +      sb.append(")");
 +      return sb.toString();
 +    }
 +
 +    public void validate() throws org.apache.thrift.TException {
 +      // check for required fields
 +      if (gateway == null) {
 +        throw new org.apache.thrift.protocol.TProtocolException("Required field 'gateway' was not present! Struct: " + toString());
 +      }
 +      // check for sub-struct validity
 +      if (gateway != null) {
 +        gateway.validate();
 +      }
 +    }
 +
 +    private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
 +      try {
 +        write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
 +      } catch (org.apache.thrift.TException te) {
 +        throw new java.io.IOException(te);
 +      }
 +    }
 +
 +    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
 +      try {
 +        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
 +      } catch (org.apache.thrift.TException te) {
 +        throw new java.io.IOException(te);
 +      }
 +    }
 +
 +    private static class addGateway_argsStandardSchemeFactory implements SchemeFactory {
 +      public addGateway_argsStandardScheme getScheme() {
 +        return new addGateway_argsStandardScheme();
 +      }
 +    }
 +
 +    private static class addGateway_argsStandardScheme extends StandardScheme<addGateway_args> {
 +
 +      public void read(org.apache.thrift.protocol.TProtocol iprot, addGateway_args struct) throws org.apache.thrift.TException {
 +        org.apache.thrift.protocol.TField schemeField;
 +        iprot.readStructBegin();
 +        while (true)
 +        {
 +          schemeField = iprot.readFieldBegin();
 +          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
 +            break;
 +          }
 +          switch (schemeField.id) {
 +            case 1: // GATEWAY
 +              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
 +                struct.gateway = new org.apache.airavata.model.workspace.Gateway();
 +                struct.gateway.read(iprot);
 +                struct.setGatewayIsSet(true);
 +              } else { 
 +                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +              }
 +              break;
 +            default:
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +          }
 +          iprot.readFieldEnd();
 +        }
 +        iprot.readStructEnd();
 +
 +        // check for required fields of primitive type, which can't be checked in the validate method
 +        struct.validate();
 +      }
 +
 +      public void write(org.apache.thrift.protocol.TProtocol oprot, addGateway_args struct) throws org.apache.thrift.TException {
 +        struct.validate();
 +
 +        oprot.writeStructBegin(STRUCT_DESC);
 +        if (struct.gateway != null) {
 +          oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
 +          struct.gateway.write(oprot);
 +          oprot.writeFieldEnd();
 +        }
 +        oprot.writeFieldStop();
 +        oprot.writeStructEnd();
 +      }
 +
 +    }
 +
 +    private static class addGateway_argsTupleSchemeFactory implements SchemeFactory {
 +      public addGateway_argsTupleScheme getScheme() {
 +        return new addGateway_argsTupleScheme();
 +      }
 +    }
 +
 +    private static class addGateway_argsTupleScheme extends TupleScheme<addGateway_args> {
 +
 +      @Override
 +      public void write(org.apache.thrift.protocol.TProtocol prot, addGateway_args struct) throws org.apache.thrift.TException {
 +        TTupleProtocol oprot = (TTupleProtocol) prot;
 +        struct.gateway.write(oprot);
 +      }
 +
 +      @Override
 +      public void read(org.apache.thrift.protocol.TProtocol prot, addGateway_args struct) throws org.apache.thrift.TException {
 +        TTupleProtocol iprot = (TTupleProtocol) prot;
 +        struct.gateway = new org.apache.airavata.model.workspace.Gateway();
 +        struct.gateway.read(iprot);
 +        struct.setGatewayIsSet(true);
 +      }
 +    }
 +
 +  }
 +
 +  public static class addGateway_result implements org.apache.thrift.TBase<addGateway_result, addGateway_result._Fields>, java.io.Serializable, Cloneable, Comparable<addGateway_result>   {
 +    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("addGateway_result");
 +
 +    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0);
 +    private static final org.apache.thrift.protocol.TField IRE_FIELD_DESC = new org.apache.thrift.protocol.TField("ire", org.apache.thrift.protocol.TType.STRUCT, (short)1);
 +    private static final org.apache.thrift.protocol.TField ACE_FIELD_DESC = new org.apache.thrift.protocol.TField("ace", org.apache.thrift.protocol.TType.STRUCT, (short)2);
 +    private static final org.apache.thrift.protocol.TField ASE_FIELD_DESC = new org.apache.thrift.protocol.TField("ase", org.apache.thrift.protocol.TType.STRUCT, (short)3);
 +
 +    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
 +    static {
 +      schemes.put(StandardScheme.class, new addGateway_resultStandardSchemeFactory());
 +      schemes.put(TupleScheme.class, new addGateway_resultTupleSchemeFactory());
 +    }
 +
 +    public String success; // required
 +    public org.apache.airavata.model.error.InvalidRequestException ire; // required
 +    public org.apache.airavata.model.error.AiravataClientException ace; // required
 +    public org.apache.airavata.model.error.AiravataSystemException ase; // required
 +
 +    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
 +    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
 +      SUCCESS((short)0, "success"),
 +      IRE((short)1, "ire"),
 +      ACE((short)2, "ace"),
 +      ASE((short)3, "ase");
 +
 +      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 +
 +      static {
 +        for (_Fields field : EnumSet.allOf(_Fields.class)) {
 +          byName.put(field.getFieldName(), field);
 +        }
 +      }
 +
 +      /**
 +       * Find the _Fields constant that matches fieldId, or null if its not found.
 +       */
 +      public static _Fields findByThriftId(int fieldId) {
 +        switch(fieldId) {
 +          case 0: // SUCCESS
 +            return SUCCESS;
 +          case 1: // IRE
 +            return IRE;
 +          case 2: // ACE
 +            return ACE;
 +          case 3: // ASE
 +            return ASE;
 +          default:
 +            return null;
 +        }
 +      }
 +
 +      /**
 +       * Find the _Fields constant that matches fieldId, throwing an exception
 +       * if it is not found.
 +       */
 +      public static _Fields findByThriftIdOrThrow(int fieldId) {
 +        _Fields fields = findByThriftId(fieldId);
 +        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
 +        return fields;
 +      }
 +
 +      /**
 +       * Find the _Fields constant that matches name, or null if its not found.
 +       */
 +      public static _Fields findByName(String name) {
 +        return byName.get(name);
 +      }
 +
 +      private final short _thriftId;
 +      private final String _fieldName;
 +
 +      _Fields(short thriftId, String fieldName) {
 +        _thriftId = thriftId;
 +        _fieldName = fieldName;
 +      }
 +
 +      public short getThriftFieldId() {
 +        return _thriftId;
 +      }
 +
 +      public String getFieldName() {
 +        return _fieldName;
 +      }
 +    }
 +
 +    // isset id assignments
 +    public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
 +    static {
 +      Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
 +      tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
 +      tmpMap.put(_Fields.IRE, new org.apache.thrift.meta_data.FieldMetaData("ire", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
 +      tmpMap.put(_Fields.ACE, new org.apache.thrift.meta_data.FieldMetaData("ace", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
 +      tmpMap.put(_Fields.ASE, new org.apache.thrift.meta_data.FieldMetaData("ase", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
 +      metaDataMap = Collections.unmodifiableMap(tmpMap);
 +      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(addGateway_result.class, metaDataMap);
 +    }
 +
 +    public addGateway_result() {
 +    }
 +
 +    public addGateway_result(
 +      String success,
 +      org.apache.airavata.model.error.InvalidRequestException ire,
 +      org.apache.airavata.model.error.AiravataClientException ace,
 +      org.apache.airavata.model.error.AiravataSystemException ase)
 +    {
 +      this();
 +      this.success = success;
 +      this.ire = ire;
 +      this.ace = ace;
 +      this.ase = ase;
 +    }
 +
 +    /**
 +     * Performs a deep copy on <i>other</i>.
 +     */
 +    public addGateway_result(addGateway_result other) {
 +      if (other.isSetSuccess()) {
 +        this.success = other.success;
 +      }
 +      if (other.isSetIre()) {
 +        this.ire = new org.apache.airavata.model.error.InvalidRequestException(other.ire);
 +      }
 +      if (other.isSetAce()) {
 +        this.ace = new org.apache.airavata.model.error.AiravataClientException(other.ace);
 +      }
 +      if (other.isSetAse()) {
 +        this.ase = new org.apache.airavata.model.error.AiravataSystemException(other.ase);
 +      }
 +    }
 +
 +    public addGateway_result deepCopy() {
 +      return new addGateway_result(this);
 +    }
 +
 +    @Override
 +    public void clear() {
 +      this.success = null;
 +      this.ire = null;
 +      this.ace = null;
 +      this.ase = null;
 +    }
 +
 +    public String getSuccess() {
 +      return this.success;
 +    }
 +
 +    public addGateway_result setSuccess(String success) {
 +      this.success = success;
 +      return this;
 +    }
 +
 +    public void unsetSuccess() {
 +      this.success = null;
 +    }
 +
 +    /** Returns true if field success is set (has been assigned a value) and false otherwise */
 +    public boolean isSetSuccess() {
 +      return this.success != null;
 +    }
 +
 +    public void setSuccessIsSet(boolean value) {
 +      if (!value) {
 +        this.success = null;
 +      }
 +    }
 +
 +    public org.apache.airavata.model.error.InvalidRequestException getIre() {
 +      return this.ire;
 +    }
 +
 +    public addGateway_result setIre(org.apache.airavata.model.error.InvalidRequestException ire) {
 +      this.ire = ire;
 +      return this;
 +    }
 +
 +    public void unsetIre() {
 +      this.ire = null;
 +    }
 +
 +    /** Returns true if field ire is set (has been assigned a value) and false otherwise */
 +    public boolean isSetIre() {
 +      return this.ire != null;
 +    }
 +
 +    public void setIreIsSet(boolean value) {
 +      if (!value) {
 +        this.ire = null;
 +      }
 +    }
 +
 +    public org.apache.airavata.model.error.AiravataClientException getAce() {
 +      return this.ace;
 +    }
 +
 +    public addGateway_result setAce(org.apache.airavata.model.error.AiravataClientException ace) {
 +      this.ace = ace;
 +      return this;
 +    }
 +
 +    public void unsetAce() {
 +      this.ace = null;
 +    }
 +
 +    /** Returns true if field ace is set (has been assigned a value) and false otherwise */
 +    public boolean isSetAce() {
 +      return this.ace != null;
 +    }
 +
 +    public void setAceIsSet(boolean value) {
 +      if (!value) {
 +        this.ace = null;
 +      }
 +    }
 +
 +    public org.apache.airavata.model.error.AiravataSystemException getAse() {
 +      return this.ase;
 +    }
 +
 +    public addGateway_result setAse(org.apache.airavata.model.error.AiravataSystemException ase) {
 +      this.ase = ase;
 +      return this;
 +    }
 +
 +    public void unsetAse() {
 +      this.ase = null;
 +    }
 +
 +    /** Returns true if field ase is set (has been assigned a value) and false otherwise */
 +    public boolean isSetAse() {
 +      return this.ase != null;
 +    }
 +
 +    public void setAseIsSet(boolean value) {
 +      if (!value) {
 +        this.ase = null;
 +      }
 +    }
 +
 +    public void setFieldValue(_Fields field, Object value) {
 +      switch (field) {
 +      case SUCCESS:
 +        if (value == null) {
 +          unsetSuccess();
 +        } else {
 +          setSuccess((String)value);
 +        }
 +        break;
 +
 +      case IRE:
 +        if (value == null) {
 +          unsetIre();
 +        } else {
 +          setIre((org.apache.airavata.model.error.InvalidRequestException)value);
 +        }
 +        break;
 +
 +      case ACE:
 +        if (value == null) {
 +          unsetAce();
 +        } else {
 +          setAce((org.apache.airavata.model.error.AiravataClientException)value);
 +        }
 +        break;
 +
 +      case ASE:
 +        if (value == null) {
 +          unsetAse();
 +        } else {
 +          setAse((org.apache.airavata.model.error.AiravataSystemException)value);
 +        }
 +        break;
 +
 +      }
 +    }
 +
 +    public Object getFieldValue(_Fields field) {
 +      switch (field) {
 +      case SUCCESS:
 +        return getSuccess();
 +
 +      case IRE:
 +        return getIre();
 +
 +      case ACE:
 +        return getAce();
 +
 +      case ASE:
 +        return getAse();
 +
        }
        throw new IllegalStateException();
      }

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --cc airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index cd2fc7a,b78bd3d..794d826
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@@ -80,9 -86,17 +80,9 @@@ public class CreateLaunchExperiment 
  
      public static void main(String[] args) throws Exception {
          airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-         System.out.println("API version is " + airavataClient.getAPIVersion());
+         System.out.println("API version is " + airavataClient.getAPIVersion(null));
 -        Experiment experiment = airavataClient.getExperiment("echotest_fcc7127d-73e9-4e43-bc07-07399a7c5efc");
 -        long creationTime = experiment.getCreationTime();
 -        Date date = new Date(creationTime);
 -        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 -        String dateFormatted = formatter.format(date);
 -        System.out.println(dateFormatted);
 -//        createGateway();
 -//        getGateway("testGatewayId");
  //        registerApplications(); // run this only the first time
--//        createAndLaunchExp();
++        createAndLaunchExp();
      }
  
      private static String fsdResourceId;

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/airavata-api/thrift-interface-descriptions/airavataAPI.thrift
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/modules/configuration/server/src/main/resources/airavata-server.properties
----------------------------------------------------------------------
diff --cc modules/configuration/server/src/main/resources/airavata-server.properties
index 56a8bd1,baf4cd1..8bdc004
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@@ -279,3 -274,11 +279,11 @@@ gfac-experiments=/gfac-experiment
  gfac-server-name=gfac-node0
  orchestrator-server-name=orch-node0
  airavata-server-name=api-node0
+ 
+ ########################################################################
+ ## API Security Configuration
+ ########################################################################
+ api.secured=true
+ remote.oauth.authorization.server=https://localhost:9443/services/
+ admin.user.name=admin
 -admin.password=admin
++admin.password=admin

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java
----------------------------------------------------------------------
diff --cc samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java
index 0000000,f547e0d..5113c02
mode 000000,100644..100644
--- a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java
@@@ -1,0 -1,109 +1,109 @@@
+ /*
+  *
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  *
+  */
+ package org.apache.airavata.secure.sample;
+ 
+ import org.apache.axis2.AxisFault;
+ import org.apache.axis2.context.ConfigurationContext;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceException;
+ import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
+ import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
+ import org.wso2.carbon.utils.CarbonUtils;
+ 
+ import javax.net.ssl.*;
+ import java.rmi.RemoteException;
+ 
+ public class OAuthAppRegisteringClient {
+     private OAuthAdminServiceStub stub;
+     private final static Logger logger = LoggerFactory.getLogger(OAuthAppRegisteringClient.class);
+ 
+     public OAuthAppRegisteringClient(String auhorizationServerURL, String username, String password,
+                                      ConfigurationContext configCtx) throws Exception {
+         String serviceURL = auhorizationServerURL + "OAuthAdminService";
+         try {
+             stub = new OAuthAdminServiceStub(configCtx, serviceURL);
+             CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, stub._getServiceClient());
+         } catch (AxisFault e) {
+             logger.error("Error initializing OAuth2 Client");
+             throw new Exception("Error initializing OAuth Client", e);
+         }
 -        //TODO:enable proper SSL handshake
++        //TODO:enable proper SSL handshake with WSO2 IS.
+         try {
+             // Get SSL context
+             SSLContext sc = SSLContext.getInstance("SSL");
+ 
+             // Create empty HostnameVerifier
+             HostnameVerifier hv = new HostnameVerifier() {
+                 public boolean verify(String urlHostName, SSLSession session) {
+                     return true;
+                 }
+             };
+             HttpsURLConnection.setDefaultHostnameVerifier(hv);
+ 
+             // Create a trust manager that does not validate certificate chains
+             TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+                 public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+                     return null;
+                 }
+ 
+                 public void checkClientTrusted(java.security.cert.X509Certificate[] certs,
+                                                String authType) {
+                 }
+ 
+                 public void checkServerTrusted(java.security.cert.X509Certificate[] certs,
+                                                String authType) {
+                 }
+             }};
+ 
+             sc.init(null, trustAllCerts, new java.security.SecureRandom());
+             SSLContext.setDefault(sc);
+         } catch (Exception e) {
+             e.printStackTrace();
+         }
+ 
+     }
+ 
+     public OAuthConsumerAppDTO registerApplication(String appName, String consumerId, String consumerSecret)
+             throws AiravataSecurityException {
+ 
+         try {
+             OAuthConsumerAppDTO consumerAppDTO = new OAuthConsumerAppDTO();
+             consumerAppDTO.setApplicationName(appName);
+             // consumer key and secret is set by the application.
+             consumerAppDTO.setOauthConsumerKey(consumerId);
+             consumerAppDTO.setOauthConsumerSecret(consumerSecret);
+             //consumerAppDTO.setUsername(adminUserName);
+             stub.registerOAuthApplicationData(consumerAppDTO);
+             // After registration application is retrieve
 -            return stub.getOAuthApplicationDataByAppName(Properties.appName);
++            return stub.getOAuthApplicationDataByAppName(appName);
+         } catch (AxisFault axisFault) {
+             axisFault.printStackTrace();
+             throw new AiravataSecurityException("Error in registering the OAuth application.");
+         } catch (RemoteException e) {
+             e.printStackTrace();
+             throw new AiravataSecurityException("Error in registering the OAuth application.");
+         } catch (OAuthAdminServiceException e) {
+             e.printStackTrace();
+             throw new AiravataSecurityException("Error in registering the OAuth application.");
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/airavata/blob/0c1ff519/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java
----------------------------------------------------------------------
diff --cc samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java
index 0000000,10ac3db..7204e53
mode 000000,100644..100644
--- a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java
@@@ -1,0 -1,87 +1,87 @@@
+ package org.apache.airavata.secure.sample;
+ 
+ import org.apache.commons.codec.binary.Base64;
+ import org.apache.http.HttpResponse;
+ import org.apache.http.NameValuePair;
+ import org.apache.http.client.ClientProtocolException;
+ import org.apache.http.client.HttpClient;
+ import org.apache.http.client.entity.UrlEncodedFormEntity;
+ import org.apache.http.client.methods.HttpPost;
+ import org.apache.http.conn.scheme.Scheme;
+ import org.apache.http.impl.client.DefaultHttpClient;
+ import org.apache.http.message.BasicNameValuePair;
+ import org.json.simple.JSONObject;
+ import org.json.simple.parser.JSONParser;
+ import org.json.simple.parser.ParseException;
+ 
+ import javax.net.ssl.SSLContext;
+ import java.io.BufferedReader;
+ import java.io.IOException;
+ import java.io.InputStreamReader;
+ import java.io.UnsupportedEncodingException;
+ import java.security.NoSuchAlgorithmException;
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+ public class OAuthTokenRetrievalClient {
+ 
+     public String retrieveAccessToken(String consumerId, String consumerSecret, String userName, String password)
+             throws SecurityException {
+ 
+         HttpPost postMethod = null;
+         try {
 -            //TODO:handle SSL handshake properly.
++            //TODO:handle SSL handshake with WSO2 IS properly.
+             org.apache.http.conn.ssl.SSLSocketFactory sf = new org.apache.http.conn.ssl.SSLSocketFactory(
+                     SSLContext.getDefault());
+             sf.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+             Scheme httpsScheme = new Scheme("https", sf, Properties.authzServerPort);
+             HttpClient httpClient = new DefaultHttpClient();
+             httpClient.getConnectionManager().getSchemeRegistry().register(httpsScheme);
+ 
+             postMethod = new HttpPost(Properties.oauthTokenEndPointURL);
+             //build the HTTP request with relevant params for resource owner credential grant type
+             String authInfo = consumerId + ":" + consumerSecret;
+             String authHeader = new String(Base64.encodeBase64(authInfo.getBytes()));
+ 
+             postMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");
+             postMethod.setHeader("Authorization", "Basic " + authHeader);
+ 
+             List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
+             urlParameters.add(new BasicNameValuePair("grant_type", "password"));
+             urlParameters.add(new BasicNameValuePair("username", userName));
+             urlParameters.add(new BasicNameValuePair("password", password));
+ 
+             postMethod.setEntity(new UrlEncodedFormEntity(urlParameters));
+ 
+             HttpResponse response = httpClient.execute(postMethod);
+ 
+             BufferedReader rd = new BufferedReader(
+                     new InputStreamReader(response.getEntity().getContent()));
+ 
+             StringBuilder result = new StringBuilder();
+             String line = "";
+             while ((line = rd.readLine()) != null) {
+                 result.append(line);
+             }
+ 
+             JSONParser parser = new JSONParser();
+             JSONObject jsonObject = (JSONObject) parser.parse(result.toString());
+             return (String) jsonObject.get("access_token");
+         } catch (ClientProtocolException e) {
+             throw new SecurityException(e.getMessage());
+         } catch (UnsupportedEncodingException e) {
+             throw new SecurityException(e.getMessage());
+         } catch (IOException e) {
+             throw new SecurityException(e.getMessage());
+         } catch (NoSuchAlgorithmException e) {
+             throw new SecurityException(e.getMessage());
+         } catch (ParseException e) {
+             throw new SecurityException(e.getMessage());
+         } finally {
+             if (postMethod != null) {
+                 postMethod.releaseConnection();
+             }
+         }
+     }
+ 
+ }


[8/8] airavata git commit: deleting an unused file.

Posted by sm...@apache.org.
deleting an unused file.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/1149810c
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/1149810c
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/1149810c

Branch: refs/heads/master
Commit: 1149810ca460437831272bbeccab3688f5d0ec40
Parents: 7e11e95
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Tue Jun 2 17:22:15 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Tue Jun 2 17:22:15 2015 +0530

----------------------------------------------------------------------
 .../api/server/security/Properties.java         | 27 --------------------
 1 file changed, 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/1149810c/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java
deleted file mode 100644
index b6e5a39..0000000
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/security/Properties.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.airavata.api.server.security;
-
-public class Properties {
-    public static String oauthAuthzServerURL = "https://localhost:9443/services/";
-    public static String userName = "admin";
-    public static String password = "admin";
-}


[6/8] airavata git commit: Merge branch 'sprint1_update' into sprint1_updated

Posted by sm...@apache.org.
Merge branch 'sprint1_update' into sprint1_updated


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/85f613f8
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/85f613f8
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/85f613f8

Branch: refs/heads/master
Commit: 85f613f8a2ed810a5fdf91514e3f9b6af19d1b4f
Parents: 4476dfc 0c1ff51
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Tue Jun 2 14:47:30 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Tue Jun 2 14:47:30 2015 +0530

----------------------------------------------------------------------
 airavata-api/airavata-api-server/pom.xml        |  20 +
 .../server/handler/AiravataServerHandler.java   |  29 +-
 .../security/AiravataSecurityManager.java       |  27 +
 .../DefaultAiravataSecurityManager.java         |  55 ++
 .../api/server/security/DefaultOAuthClient.java | 124 +++++
 .../api/server/security/Properties.java         |  27 +
 .../api/server/security/SecurityException.java  |  11 +
 .../server/security/SecurityManagerFactory.java |  32 ++
 .../java/org/apache/airavata/api/Airavata.java  | 258 ++++++++-
 .../client/samples/CreateLaunchBES.java         |   2 +-
 .../client/samples/CreateLaunchExperiment.java  |   2 +-
 .../samples/CreateLaunchExperimentUS3.java      |   2 +-
 .../samples/TestCreateLaunchExperiment.java     |   3 +-
 .../tools/RegisterOGCEUS3Application.java       |   2 +-
 .../tools/RegisterSampleApplications.java       |   2 +-
 .../client/tools/RegisterUS3Application.java    |   2 +-
 .../airavata/model/security/AuthzToken.java     | 553 +++++++++++++++++++
 .../airavataAPI.thrift                          |   6 +-
 .../airavataDataModel.thrift                    |   1 +
 .../securityModel.thrift                        |  35 ++
 .../apache/airavata/common/utils/Constants.java |   5 +
 .../airavata/common/utils/ServerSettings.java   |  15 +
 .../main/resources/airavata-server.properties   |   8 +
 .../apache/airavata/integration/BaseCaseIT.java |   2 +-
 .../WorkflowIntegrationTestBase.java            |   2 +
 pom.xml                                         |   1 +
 samples/java-client/experiment/pom.xml          |   2 +-
 samples/java-client/pom.xml                     |   7 +-
 samples/java-client/secure-client/pom.xml       | 110 ++++
 .../sample/AiravataSecurityException.java       |  31 ++
 .../sample/OAuthAppRegisteringClient.java       | 109 ++++
 .../sample/OAuthTokenRetrievalClient.java       |  87 +++
 .../airavata/secure/sample/Properties.java      |  42 ++
 .../airavata/secure/sample/SecureClient.java    | 152 +++++
 34 files changed, 1732 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/85f613f8/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/airavata/blob/85f613f8/modules/configuration/server/src/main/resources/airavata-server.properties
----------------------------------------------------------------------


[7/8] airavata git commit: Merge branch 'sprint1_updated' into sprint1_update2

Posted by sm...@apache.org.
Merge branch 'sprint1_updated' into sprint1_update2


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/7e11e95c
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/7e11e95c
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/7e11e95c

Branch: refs/heads/master
Commit: 7e11e95c5b0105878df600907f66c8fb5d4ba59f
Parents: c8a70e9 85f613f
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Tue Jun 2 17:03:48 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Tue Jun 2 17:03:48 2015 +0530

----------------------------------------------------------------------
 airavata-api/airavata-api-server/pom.xml        |  20 +
 .../server/handler/AiravataServerHandler.java   |  29 +-
 .../security/AiravataSecurityManager.java       |  27 +
 .../DefaultAiravataSecurityManager.java         |  55 ++
 .../api/server/security/DefaultOAuthClient.java | 124 +++++
 .../api/server/security/Properties.java         |  27 +
 .../api/server/security/SecurityException.java  |  11 +
 .../server/security/SecurityManagerFactory.java |  32 ++
 .../java/org/apache/airavata/api/Airavata.java  | 258 ++++++++-
 .../client/samples/CreateLaunchBES.java         |   2 +-
 .../client/samples/CreateLaunchExperiment.java  |   2 +-
 .../samples/CreateLaunchExperimentUS3.java      |   2 +-
 .../samples/TestCreateLaunchExperiment.java     |   3 +-
 .../tools/RegisterOGCEUS3Application.java       |   2 +-
 .../tools/RegisterSampleApplications.java       |   2 +-
 .../client/tools/RegisterUS3Application.java    |   2 +-
 .../airavata/model/security/AuthzToken.java     | 553 +++++++++++++++++++
 .../airavataAPI.thrift                          |   6 +-
 .../airavataDataModel.thrift                    |   1 +
 .../securityModel.thrift                        |  35 ++
 .../apache/airavata/common/utils/Constants.java |   5 +
 .../airavata/common/utils/ServerSettings.java   |  15 +
 .../main/resources/airavata-server.properties   |   8 +
 .../apache/airavata/integration/BaseCaseIT.java |   2 +-
 .../WorkflowIntegrationTestBase.java            |   2 +
 pom.xml                                         |   1 +
 samples/java-client/experiment/pom.xml          |   2 +-
 samples/java-client/pom.xml                     |   7 +-
 samples/java-client/secure-client/pom.xml       | 110 ++++
 .../sample/AiravataSecurityException.java       |  31 ++
 .../sample/OAuthAppRegisteringClient.java       | 109 ++++
 .../sample/OAuthTokenRetrievalClient.java       |  87 +++
 .../airavata/secure/sample/Properties.java      |  42 ++
 .../airavata/secure/sample/SecureClient.java    | 152 +++++
 34 files changed, 1732 insertions(+), 34 deletions(-)
----------------------------------------------------------------------



[3/8] airavata git commit: completing the POC of securing Airavata API with a secure client sample.

Posted by sm...@apache.org.
completing the POC of securing Airavata API with a secure client sample.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/addb4be9
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/addb4be9
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/addb4be9

Branch: refs/heads/master
Commit: addb4be944acedce8efb089a1e85f86672aaa1c0
Parents: 14a1621
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Sat May 23 21:38:32 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Sat May 23 21:38:32 2015 +0530

----------------------------------------------------------------------
 airavata-api/airavata-api-server/pom.xml        |  21 +-
 .../server/handler/AiravataServerHandler.java   |  29 ++-
 .../java/org/apache/airavata/api/Airavata.java  | 258 +++++++++++++++++--
 .../client/samples/CreateLaunchBES.java         |   2 +-
 .../client/samples/CreateLaunchExperiment.java  |   2 +-
 .../samples/CreateLaunchExperimentUS3.java      |   2 +-
 .../samples/TestCreateLaunchExperiment.java     |   3 +-
 .../tools/RegisterOGCEUS3Application.java       |   2 +-
 .../tools/RegisterSampleApplications.java       |   2 +-
 .../client/tools/RegisterUS3Application.java    |   2 +-
 .../airavataAPI.thrift                          |   6 +-
 .../airavataDataModel.thrift                    |   1 +
 .../apache/airavata/common/utils/Constants.java |   5 +
 .../airavata/common/utils/ServerSettings.java   |  15 ++
 .../main/resources/airavata-server.properties   |   8 +
 .../apache/airavata/integration/BaseCaseIT.java |   2 +-
 .../WorkflowIntegrationTestBase.java            |   2 +
 samples/java-client/secure-client/pom.xml       |  10 +
 .../sample/AiravataSecurityException.java       |  31 +++
 .../airavata/secure/sample/Constants.java       |  26 --
 .../sample/OAuthAppRegisteringClient.java       | 109 ++++++++
 .../sample/OAuthTokenRetrievalClient.java       |  87 +++++++
 .../airavata/secure/sample/Properties.java      |  42 +++
 .../airavata/secure/sample/SecureClient.java    | 122 +++++++--
 24 files changed, 706 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-api-server/pom.xml
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/pom.xml b/airavata-api/airavata-api-server/pom.xml
index df87344..b4af842 100644
--- a/airavata-api/airavata-api-server/pom.xml
+++ b/airavata-api/airavata-api-server/pom.xml
@@ -81,7 +81,26 @@
             <artifactId>slf4j-log4j12</artifactId>
             <version>${org.slf4j.version}</version>
         </dependency>
-        
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
+            <version>4.2.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+            <version>1.6.1.wso2v4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.utils</artifactId>
+            <version>4.2.0</version>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index fff3810..275feff 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -27,6 +27,7 @@ import org.apache.aiaravata.application.catalog.data.resources.*;
 import org.apache.aiaravata.application.catalog.data.util.AppCatalogThriftConversion;
 import org.apache.airavata.api.Airavata;
 import org.apache.airavata.api.airavataAPIConstants;
+import org.apache.airavata.api.server.security.*;
 import org.apache.airavata.common.exception.AiravataException;
 import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.logger.AiravataLogger;
@@ -48,6 +49,7 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfil
 import org.apache.airavata.model.error.*;
 import org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent;
 import org.apache.airavata.model.messaging.event.MessageType;
+import org.apache.airavata.model.security.AuthzToken;
 import org.apache.airavata.model.workspace.Gateway;
 import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.model.workspace.experiment.*;
@@ -86,7 +88,9 @@ public class AiravataServerHandler implements Airavata.Iface {
      * Query Airavata to fetch the API version
      */
     @Override
-    public String getAPIVersion() throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+    public String getAPIVersion(AuthzToken authzToken) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+        //security check
+        authenticateNAuthorize(authzToken);
         return airavataAPIConstants.AIRAVATA_API_VERSION;
     }
 
@@ -1586,7 +1590,7 @@ public class AiravataServerHandler implements Airavata.Iface {
         }
     }
 
-       
+
     private OrchestratorService.Client getOrchestratorClient() throws TException{
 		final int serverPort = Integer.parseInt(ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ORCHESTRATOR_SERVER_PORT,"8940"));
         final String serverHost = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ORCHESTRATOR_SERVER_HOST, null);
@@ -2295,7 +2299,7 @@ public class AiravataServerHandler implements Airavata.Iface {
             throw exception;
         }
     }
-    
+
     /**
      * Add a Local Job Submission details to a compute resource
      * App catalog will return a jobSubmissionInterfaceId which will be added to the jobSubmissionInterfaces.
@@ -3422,4 +3426,23 @@ public class AiravataServerHandler implements Airavata.Iface {
         }
     }
 
+    public void authenticateNAuthorize(AuthzToken authzToken) throws AuthorizationException {
+        try {
+            boolean isAPISecured = ServerSettings.isAPISecured();
+            if (isAPISecured) {
+
+                AiravataSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
+                boolean isAuthz = securityManager.isUserAuthenticatedAndAuthorized(authzToken);
+                if (!isAuthz) {
+                    throw new AuthorizationException("User is not authenticated or authorized.");
+                }
+            }
+        } catch (org.apache.airavata.api.server.security.SecurityException e) {
+            throw new AuthorizationException(e.getMessage());
+        } catch (ApplicationSettingsException e) {
+            logger.error("Error in reading API security settings.");
+            throw new AuthorizationException(e.getMessage());
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java b/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
index dd73b61..6e70510 100644
--- a/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
+++ b/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java
@@ -55,8 +55,10 @@ import org.slf4j.LoggerFactory;
 
     /**
      * Fetch Apache Airavata API version
+     * 
+     * @param authzToken
      */
-    public String getAPIVersion() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException;
+    public String getAPIVersion(org.apache.airavata.model.security.AuthzToken authzToken) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
 
     public String addGateway(org.apache.airavata.model.workspace.Gateway gateway) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException;
 
@@ -1792,7 +1794,7 @@ import org.slf4j.LoggerFactory;
 
   public interface AsyncIface {
 
-    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+    public void getAPIVersion(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
 
     public void addGateway(org.apache.airavata.model.workspace.Gateway gateway, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
 
@@ -2066,19 +2068,20 @@ import org.slf4j.LoggerFactory;
       super(iprot, oprot);
     }
 
-    public String getAPIVersion() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException
+    public String getAPIVersion(org.apache.airavata.model.security.AuthzToken authzToken) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
     {
-      send_getAPIVersion();
+      send_getAPIVersion(authzToken);
       return recv_getAPIVersion();
     }
 
-    public void send_getAPIVersion() throws org.apache.thrift.TException
+    public void send_getAPIVersion(org.apache.airavata.model.security.AuthzToken authzToken) throws org.apache.thrift.TException
     {
       getAPIVersion_args args = new getAPIVersion_args();
+      args.setAuthzToken(authzToken);
       sendBase("getAPIVersion", args);
     }
 
-    public String recv_getAPIVersion() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException
+    public String recv_getAPIVersion() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
     {
       getAPIVersion_result result = new getAPIVersion_result();
       receiveBase(result, "getAPIVersion");
@@ -2094,6 +2097,9 @@ import org.slf4j.LoggerFactory;
       if (result.ase != null) {
         throw result.ase;
       }
+      if (result.ae != null) {
+        throw result.ae;
+      }
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getAPIVersion failed: unknown result");
     }
 
@@ -6232,26 +6238,29 @@ import org.slf4j.LoggerFactory;
       super(protocolFactory, clientManager, transport);
     }
 
-    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
+    public void getAPIVersion(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      getAPIVersion_call method_call = new getAPIVersion_call(resultHandler, this, ___protocolFactory, ___transport);
+      getAPIVersion_call method_call = new getAPIVersion_call(authzToken, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
     public static class getAPIVersion_call extends org.apache.thrift.async.TAsyncMethodCall {
-      public getAPIVersion_call(org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+      private org.apache.airavata.model.security.AuthzToken authzToken;
+      public getAPIVersion_call(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
         super(client, protocolFactory, transport, resultHandler, false);
+        this.authzToken = authzToken;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
         prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getAPIVersion", org.apache.thrift.protocol.TMessageType.CALL, 0));
         getAPIVersion_args args = new getAPIVersion_args();
+        args.setAuthzToken(authzToken);
         args.write(prot);
         prot.writeMessageEnd();
       }
 
-      public String getResult() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException {
+      public String getResult() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
         if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
           throw new IllegalStateException("Method call not finished!");
         }
@@ -10743,13 +10752,15 @@ import org.slf4j.LoggerFactory;
       public getAPIVersion_result getResult(I iface, getAPIVersion_args args) throws org.apache.thrift.TException {
         getAPIVersion_result result = new getAPIVersion_result();
         try {
-          result.success = iface.getAPIVersion();
+          result.success = iface.getAPIVersion(args.authzToken);
         } catch (org.apache.airavata.model.error.InvalidRequestException ire) {
           result.ire = ire;
         } catch (org.apache.airavata.model.error.AiravataClientException ace) {
           result.ace = ace;
         } catch (org.apache.airavata.model.error.AiravataSystemException ase) {
           result.ase = ase;
+        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+          result.ae = ae;
         }
         return result;
       }
@@ -14494,6 +14505,11 @@ import org.slf4j.LoggerFactory;
                         result.setAseIsSet(true);
                         msg = result;
             }
+            else             if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
+                        result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+                        result.setAeIsSet(true);
+                        msg = result;
+            }
              else 
             {
               msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
@@ -14515,7 +14531,7 @@ import org.slf4j.LoggerFactory;
       }
 
       public void start(I iface, getAPIVersion_args args, org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws TException {
-        iface.getAPIVersion(resultHandler);
+        iface.getAPIVersion(args.authzToken,resultHandler);
       }
     }
 
@@ -22983,6 +22999,7 @@ import org.slf4j.LoggerFactory;
   public static class getAPIVersion_args implements org.apache.thrift.TBase<getAPIVersion_args, getAPIVersion_args._Fields>, java.io.Serializable, Cloneable, Comparable<getAPIVersion_args>   {
     private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getAPIVersion_args");
 
+    private static final org.apache.thrift.protocol.TField AUTHZ_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("authzToken", org.apache.thrift.protocol.TType.STRUCT, (short)1);
 
     private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
     static {
@@ -22990,10 +23007,11 @@ import org.slf4j.LoggerFactory;
       schemes.put(TupleScheme.class, new getAPIVersion_argsTupleSchemeFactory());
     }
 
+    public org.apache.airavata.model.security.AuthzToken authzToken; // required
 
     /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
     @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-;
+      AUTHZ_TOKEN((short)1, "authzToken");
 
       private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -23008,6 +23026,8 @@ import org.slf4j.LoggerFactory;
        */
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
           default:
             return null;
         }
@@ -23046,9 +23066,13 @@ import org.slf4j.LoggerFactory;
         return _fieldName;
       }
     }
+
+    // isset id assignments
     public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+      tmpMap.put(_Fields.AUTHZ_TOKEN, new org.apache.thrift.meta_data.FieldMetaData("authzToken", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.security.AuthzToken.class)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getAPIVersion_args.class, metaDataMap);
     }
@@ -23056,10 +23080,20 @@ import org.slf4j.LoggerFactory;
     public getAPIVersion_args() {
     }
 
+    public getAPIVersion_args(
+      org.apache.airavata.model.security.AuthzToken authzToken)
+    {
+      this();
+      this.authzToken = authzToken;
+    }
+
     /**
      * Performs a deep copy on <i>other</i>.
      */
     public getAPIVersion_args(getAPIVersion_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.airavata.model.security.AuthzToken(other.authzToken);
+      }
     }
 
     public getAPIVersion_args deepCopy() {
@@ -23068,15 +23102,51 @@ import org.slf4j.LoggerFactory;
 
     @Override
     public void clear() {
+      this.authzToken = null;
+    }
+
+    public org.apache.airavata.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public getAPIVersion_args setAuthzToken(org.apache.airavata.model.security.AuthzToken authzToken) {
+      this.authzToken = authzToken;
+      return this;
+    }
+
+    public void unsetAuthzToken() {
+      this.authzToken = null;
+    }
+
+    /** Returns true if field authzToken is set (has been assigned a value) and false otherwise */
+    public boolean isSetAuthzToken() {
+      return this.authzToken != null;
+    }
+
+    public void setAuthzTokenIsSet(boolean value) {
+      if (!value) {
+        this.authzToken = null;
+      }
     }
 
     public void setFieldValue(_Fields field, Object value) {
       switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.airavata.model.security.AuthzToken)value);
+        }
+        break;
+
       }
     }
 
     public Object getFieldValue(_Fields field) {
       switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
       }
       throw new IllegalStateException();
     }
@@ -23088,6 +23158,8 @@ import org.slf4j.LoggerFactory;
       }
 
       switch (field) {
+      case AUTHZ_TOKEN:
+        return isSetAuthzToken();
       }
       throw new IllegalStateException();
     }
@@ -23105,6 +23177,15 @@ import org.slf4j.LoggerFactory;
       if (that == null)
         return false;
 
+      boolean this_present_authzToken = true && this.isSetAuthzToken();
+      boolean that_present_authzToken = true && that.isSetAuthzToken();
+      if (this_present_authzToken || that_present_authzToken) {
+        if (!(this_present_authzToken && that_present_authzToken))
+          return false;
+        if (!this.authzToken.equals(that.authzToken))
+          return false;
+      }
+
       return true;
     }
 
@@ -23121,6 +23202,16 @@ import org.slf4j.LoggerFactory;
 
       int lastComparison = 0;
 
+      lastComparison = Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAuthzToken()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.authzToken, other.authzToken);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
       return 0;
     }
 
@@ -23141,13 +23232,26 @@ import org.slf4j.LoggerFactory;
       StringBuilder sb = new StringBuilder("getAPIVersion_args(");
       boolean first = true;
 
+      sb.append("authzToken:");
+      if (this.authzToken == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.authzToken);
+      }
+      first = false;
       sb.append(")");
       return sb.toString();
     }
 
     public void validate() throws org.apache.thrift.TException {
       // check for required fields
+      if (authzToken == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'authzToken' was not present! Struct: " + toString());
+      }
       // check for sub-struct validity
+      if (authzToken != null) {
+        authzToken.validate();
+      }
     }
 
     private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -23184,6 +23288,15 @@ import org.slf4j.LoggerFactory;
             break;
           }
           switch (schemeField.id) {
+            case 1: // AUTHZ_TOKEN
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.authzToken = new org.apache.airavata.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
             default:
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
           }
@@ -23199,6 +23312,11 @@ import org.slf4j.LoggerFactory;
         struct.validate();
 
         oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.authzToken != null) {
+          oprot.writeFieldBegin(AUTHZ_TOKEN_FIELD_DESC);
+          struct.authzToken.write(oprot);
+          oprot.writeFieldEnd();
+        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -23216,11 +23334,15 @@ import org.slf4j.LoggerFactory;
       @Override
       public void write(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_args struct) throws org.apache.thrift.TException {
         TTupleProtocol oprot = (TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
       }
 
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_args struct) throws org.apache.thrift.TException {
         TTupleProtocol iprot = (TTupleProtocol) prot;
+        struct.authzToken = new org.apache.airavata.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
       }
     }
 
@@ -23233,6 +23355,7 @@ import org.slf4j.LoggerFactory;
     private static final org.apache.thrift.protocol.TField IRE_FIELD_DESC = new org.apache.thrift.protocol.TField("ire", org.apache.thrift.protocol.TType.STRUCT, (short)1);
     private static final org.apache.thrift.protocol.TField ACE_FIELD_DESC = new org.apache.thrift.protocol.TField("ace", org.apache.thrift.protocol.TType.STRUCT, (short)2);
     private static final org.apache.thrift.protocol.TField ASE_FIELD_DESC = new org.apache.thrift.protocol.TField("ase", org.apache.thrift.protocol.TType.STRUCT, (short)3);
+    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)4);
 
     private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
     static {
@@ -23244,13 +23367,15 @@ import org.slf4j.LoggerFactory;
     public org.apache.airavata.model.error.InvalidRequestException ire; // required
     public org.apache.airavata.model.error.AiravataClientException ace; // required
     public org.apache.airavata.model.error.AiravataSystemException ase; // required
+    public org.apache.airavata.model.error.AuthorizationException ae; // required
 
     /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
     @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
       SUCCESS((short)0, "success"),
       IRE((short)1, "ire"),
       ACE((short)2, "ace"),
-      ASE((short)3, "ase");
+      ASE((short)3, "ase"),
+      AE((short)4, "ae");
 
       private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -23273,6 +23398,8 @@ import org.slf4j.LoggerFactory;
             return ACE;
           case 3: // ASE
             return ASE;
+          case 4: // AE
+            return AE;
           default:
             return null;
         }
@@ -23324,6 +23451,8 @@ import org.slf4j.LoggerFactory;
           new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
       tmpMap.put(_Fields.ASE, new org.apache.thrift.meta_data.FieldMetaData("ase", org.apache.thrift.TFieldRequirementType.DEFAULT, 
           new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getAPIVersion_result.class, metaDataMap);
     }
@@ -23335,13 +23464,15 @@ import org.slf4j.LoggerFactory;
       String success,
       org.apache.airavata.model.error.InvalidRequestException ire,
       org.apache.airavata.model.error.AiravataClientException ace,
-      org.apache.airavata.model.error.AiravataSystemException ase)
+      org.apache.airavata.model.error.AiravataSystemException ase,
+      org.apache.airavata.model.error.AuthorizationException ae)
     {
       this();
       this.success = success;
       this.ire = ire;
       this.ace = ace;
       this.ase = ase;
+      this.ae = ae;
     }
 
     /**
@@ -23360,6 +23491,9 @@ import org.slf4j.LoggerFactory;
       if (other.isSetAse()) {
         this.ase = new org.apache.airavata.model.error.AiravataSystemException(other.ase);
       }
+      if (other.isSetAe()) {
+        this.ae = new org.apache.airavata.model.error.AuthorizationException(other.ae);
+      }
     }
 
     public getAPIVersion_result deepCopy() {
@@ -23372,6 +23506,7 @@ import org.slf4j.LoggerFactory;
       this.ire = null;
       this.ace = null;
       this.ase = null;
+      this.ae = null;
     }
 
     public String getSuccess() {
@@ -23470,6 +23605,30 @@ import org.slf4j.LoggerFactory;
       }
     }
 
+    public org.apache.airavata.model.error.AuthorizationException getAe() {
+      return this.ae;
+    }
+
+    public getAPIVersion_result setAe(org.apache.airavata.model.error.AuthorizationException ae) {
+      this.ae = ae;
+      return this;
+    }
+
+    public void unsetAe() {
+      this.ae = null;
+    }
+
+    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
+    public boolean isSetAe() {
+      return this.ae != null;
+    }
+
+    public void setAeIsSet(boolean value) {
+      if (!value) {
+        this.ae = null;
+      }
+    }
+
     public void setFieldValue(_Fields field, Object value) {
       switch (field) {
       case SUCCESS:
@@ -23504,6 +23663,14 @@ import org.slf4j.LoggerFactory;
         }
         break;
 
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.airavata.model.error.AuthorizationException)value);
+        }
+        break;
+
       }
     }
 
@@ -23521,6 +23688,9 @@ import org.slf4j.LoggerFactory;
       case ASE:
         return getAse();
 
+      case AE:
+        return getAe();
+
       }
       throw new IllegalStateException();
     }
@@ -23540,6 +23710,8 @@ import org.slf4j.LoggerFactory;
         return isSetAce();
       case ASE:
         return isSetAse();
+      case AE:
+        return isSetAe();
       }
       throw new IllegalStateException();
     }
@@ -23593,6 +23765,15 @@ import org.slf4j.LoggerFactory;
           return false;
       }
 
+      boolean this_present_ae = true && this.isSetAe();
+      boolean that_present_ae = true && that.isSetAe();
+      if (this_present_ae || that_present_ae) {
+        if (!(this_present_ae && that_present_ae))
+          return false;
+        if (!this.ae.equals(that.ae))
+          return false;
+      }
+
       return true;
     }
 
@@ -23649,6 +23830,16 @@ import org.slf4j.LoggerFactory;
           return lastComparison;
         }
       }
+      lastComparison = Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
       return 0;
     }
 
@@ -23700,6 +23891,14 @@ import org.slf4j.LoggerFactory;
         sb.append(this.ase);
       }
       first = false;
+      if (!first) sb.append(", ");
+      sb.append("ae:");
+      if (this.ae == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ae);
+      }
+      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -23778,6 +23977,15 @@ import org.slf4j.LoggerFactory;
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
+            case 4: // AE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+                struct.ae.read(iprot);
+                struct.setAeIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
             default:
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
           }
@@ -23813,6 +24021,11 @@ import org.slf4j.LoggerFactory;
           struct.ase.write(oprot);
           oprot.writeFieldEnd();
         }
+        if (struct.ae != null) {
+          oprot.writeFieldBegin(AE_FIELD_DESC);
+          struct.ae.write(oprot);
+          oprot.writeFieldEnd();
+        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -23843,7 +24056,10 @@ import org.slf4j.LoggerFactory;
         if (struct.isSetAse()) {
           optionals.set(3);
         }
-        oprot.writeBitSet(optionals, 4);
+        if (struct.isSetAe()) {
+          optionals.set(4);
+        }
+        oprot.writeBitSet(optionals, 5);
         if (struct.isSetSuccess()) {
           oprot.writeString(struct.success);
         }
@@ -23856,12 +24072,15 @@ import org.slf4j.LoggerFactory;
         if (struct.isSetAse()) {
           struct.ase.write(oprot);
         }
+        if (struct.isSetAe()) {
+          struct.ae.write(oprot);
+        }
       }
 
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_result struct) throws org.apache.thrift.TException {
         TTupleProtocol iprot = (TTupleProtocol) prot;
-        BitSet incoming = iprot.readBitSet(4);
+        BitSet incoming = iprot.readBitSet(5);
         if (incoming.get(0)) {
           struct.success = iprot.readString();
           struct.setSuccessIsSet(true);
@@ -23881,6 +24100,11 @@ import org.slf4j.LoggerFactory;
           struct.ase.read(iprot);
           struct.setAseIsSet(true);
         }
+        if (incoming.get(4)) {
+          struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+          struct.ae.read(iprot);
+          struct.setAeIsSet(true);
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchBES.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchBES.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchBES.java
index 44ebfc7..b4fd0bc 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchBES.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchBES.java
@@ -57,7 +57,7 @@ public class CreateLaunchBES {
 
     public static void main(String[] args) throws Exception {
         airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-        System.out.println("API version is " + airavataClient.getAPIVersion());
+        System.out.println("API version is " + airavataClient.getAPIVersion(null));
 //        createGateway();
 //        getGateway("testGatewayId");
 //        registerApplications(); // run this only the first time

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index ed85238..b78bd3d 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -86,7 +86,7 @@ public class CreateLaunchExperiment {
 
     public static void main(String[] args) throws Exception {
         airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-        System.out.println("API version is " + airavataClient.getAPIVersion());
+        System.out.println("API version is " + airavataClient.getAPIVersion(null));
         Experiment experiment = airavataClient.getExperiment("echotest_fcc7127d-73e9-4e43-bc07-07399a7c5efc");
         long creationTime = experiment.getCreationTime();
         Date date = new Date(creationTime);

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperimentUS3.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperimentUS3.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperimentUS3.java
index bf82ed3..2c4aede 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperimentUS3.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperimentUS3.java
@@ -52,7 +52,7 @@ public class CreateLaunchExperimentUS3 {
     public static void main(String[] args) {
         try {
             final Airavata.Client airavata = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-            System.out.println("API version is " + airavata.getAPIVersion());
+            System.out.println("API version is " + airavata.getAPIVersion(null));
 //            addDescriptors();
 //            final String expId = createUS3ExperimentForTrestles(airavata);
             final String expId = createUS3ExperimentForStampede(airavata);

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
index 8cfbd65..197a363 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
@@ -27,6 +27,7 @@ import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
 import org.apache.airavata.model.error.AiravataClientException;
 import org.apache.airavata.model.error.AiravataSystemException;
 import org.apache.airavata.model.error.InvalidRequestException;
+import org.apache.airavata.model.security.AuthzToken;
 import org.apache.airavata.model.workspace.experiment.*;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
@@ -48,7 +49,7 @@ public class TestCreateLaunchExperiment {
     public static void main(String[] args) {
         try {
             final Airavata.Client airavata = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-            System.out.println("API version is " + airavata.getAPIVersion());
+            System.out.println("API version is " + airavata.getAPIVersion(null));
             Calendar cal1 = Calendar.getInstance();
             cal1.add(Calendar.DATE, -1);
             Long from = cal1.getTimeInMillis();

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterOGCEUS3Application.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterOGCEUS3Application.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterOGCEUS3Application.java
index 6389e7d..359f183 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterOGCEUS3Application.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterOGCEUS3Application.java
@@ -70,7 +70,7 @@ public class RegisterOGCEUS3Application {
     public static void main(String[] args) {
         try {
 			airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-			System.out.println("API version is " + airavataClient.getAPIVersion());
+			System.out.println("API version is " + airavataClient.getAPIVersion(null));
 
 			//Register all compute hosts
 			registerXSEDEHosts();

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
index 3464246..c9fc3d6 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
@@ -140,7 +140,7 @@ public class RegisterSampleApplications {
     public static void main(String[] args) {
         try {
             Airavata.Client airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-            System.out.println("API version is " + airavataClient.getAPIVersion());
+            System.out.println("API version is " + airavataClient.getAPIVersion(null));
 
             RegisterSampleApplications registerSampleApplications = new RegisterSampleApplications(airavataClient);
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterUS3Application.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterUS3Application.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterUS3Application.java
index 4e0510c..e00c209 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterUS3Application.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterUS3Application.java
@@ -70,7 +70,7 @@ public class RegisterUS3Application {
     public static void main(String[] args) {
         try {
 			airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
-			System.out.println("API version is " + airavataClient.getAPIVersion());
+			System.out.println("API version is " + airavataClient.getAPIVersion(null));
 
 			//Register all compute hosts
 			registerXSEDEHosts();

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/thrift-interface-descriptions/airavataAPI.thrift
----------------------------------------------------------------------
diff --git a/airavata-api/thrift-interface-descriptions/airavataAPI.thrift b/airavata-api/thrift-interface-descriptions/airavataAPI.thrift
index 7f027f5..3d107e1 100644
--- a/airavata-api/thrift-interface-descriptions/airavataAPI.thrift
+++ b/airavata-api/thrift-interface-descriptions/airavataAPI.thrift
@@ -33,6 +33,7 @@ include "applicationDeploymentModel.thrift"
 include "applicationInterfaceModel.thrift"
 include "gatewayResourceProfileModel.thrift"
 include "workflowDataModel.thrift"
+include "securityModel.thrift"
 
 namespace java org.apache.airavata.api
 namespace php Airavata.API
@@ -66,10 +67,11 @@ service Airavata {
   /**
    * Fetch Apache Airavata API version
   */
-  string getAPIVersion()
+  string getAPIVersion(1: required securityModel.AuthzToken authzToken)
         throws (1: airavataErrors.InvalidRequestException ire,
                 2: airavataErrors.AiravataClientException ace,
-                3: airavataErrors.AiravataSystemException ase)
+                3: airavataErrors.AiravataSystemException ase,
+                4: airavataErrors.AuthorizationException ae)
 
   string addGateway(1: required workspaceModel.Gateway gateway)
          throws (1: airavataErrors.InvalidRequestException ire,

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/airavata-api/thrift-interface-descriptions/airavataDataModel.thrift
----------------------------------------------------------------------
diff --git a/airavata-api/thrift-interface-descriptions/airavataDataModel.thrift b/airavata-api/thrift-interface-descriptions/airavataDataModel.thrift
index 0149f23..74de1da 100644
--- a/airavata-api/thrift-interface-descriptions/airavataDataModel.thrift
+++ b/airavata-api/thrift-interface-descriptions/airavataDataModel.thrift
@@ -21,6 +21,7 @@
 include "workspaceModel.thrift"
 include "airavataErrors.thrift"
 include "messagingEvents.thrift"
+include "securityModel.thrift"
 
 namespace java org.apache.airavata.model
 namespace php Airavata.Model

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
index 391a3c6..6855a8e 100644
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
+++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
@@ -58,4 +58,9 @@ public final class Constants {
     public static final String STAT = "stat";
     public static final String JOB = "job";
     public static final String ZOOKEEPER_TIMEOUT = "zookeeper.timeout";
+    //API security relates property names
+    public static final String IS_API_SECURED = "api.secured";
+    public static final String REMOTE_OAUTH_SERVER_URL = "remote.oauth.authorization.server";
+    public static final String ADMIN_USERNAME = "admin.user.name";
+    public static final String ADMIN_PASSWORD = "admin.password";
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
index 57a548c..8370e40 100644
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
+++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
@@ -252,4 +252,19 @@ public class ServerSettings extends ApplicationSettings {
         return Boolean.valueOf(getSetting(ENABLE_EMAIL_BASED_MONITORING, "false"));
     }
 
+    public static boolean isAPISecured() throws ApplicationSettingsException {
+        return Boolean.valueOf(getSetting(Constants.IS_API_SECURED));
+    }
+
+    public static String getRemoteOauthServerUrl() throws ApplicationSettingsException {
+        return getSetting(Constants.REMOTE_OAUTH_SERVER_URL);
+    }
+
+    public static String getAdminUsername() throws ApplicationSettingsException {
+        return getSetting(Constants.ADMIN_USERNAME);
+    }
+
+    public static String getAdminPassword() throws ApplicationSettingsException {
+        return getSetting(Constants.ADMIN_PASSWORD);
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/modules/configuration/server/src/main/resources/airavata-server.properties
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties
index 27e962e..baf4cd1 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -274,3 +274,11 @@ gfac-experiments=/gfac-experiments
 gfac-server-name=gfac-node0
 orchestrator-server-name=orch-node0
 airavata-server-name=api-node0
+
+########################################################################
+## API Security Configuration
+########################################################################
+api.secured=true
+remote.oauth.authorization.server=https://localhost:9443/services/
+admin.user.name=admin
+admin.password=admin
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
----------------------------------------------------------------------
diff --git a/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java b/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
index d56c2b8..4ce3490 100644
--- a/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
+++ b/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
@@ -68,7 +68,7 @@ public class BaseCaseIT extends WorkflowIntegrationTestBase {
 
     @Test(groups = {"setupTests"})
     public void testSetup() throws Exception {
-        String version = this.client.getAPIVersion();
+        String version = this.client.getAPIVersion(null);
         Assert.assertNotNull(version);
         log("Airavata version - " + version);
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/modules/integration-tests/src/test/java/org/apache/airavata/integration/WorkflowIntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/modules/integration-tests/src/test/java/org/apache/airavata/integration/WorkflowIntegrationTestBase.java b/modules/integration-tests/src/test/java/org/apache/airavata/integration/WorkflowIntegrationTestBase.java
index b6528f0..fd42c08 100644
--- a/modules/integration-tests/src/test/java/org/apache/airavata/integration/WorkflowIntegrationTestBase.java
+++ b/modules/integration-tests/src/test/java/org/apache/airavata/integration/WorkflowIntegrationTestBase.java
@@ -23,6 +23,7 @@ package org.apache.airavata.integration;
 
 import org.apache.airavata.api.Airavata;
 import org.apache.airavata.api.client.AiravataClientFactory;
+import org.apache.airavata.common.utils.Constants;
 import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.model.error.*;
 import org.apache.airavata.model.workspace.experiment.Experiment;
@@ -113,6 +114,7 @@ public abstract class WorkflowIntegrationTestBase {
             ServerSettings.setSetting(MYPROXY_USER_NAME, myProxyUserName);
             ServerSettings.setSetting(MYPROXY_PWD, myProxyPassword);
             ServerSettings.setSetting(CERT_LOCATION, certLocation);
+            ServerSettings.setSetting(Constants.IS_API_SECURED, "false");
         }
 
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/samples/java-client/secure-client/pom.xml
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/pom.xml b/samples/java-client/secure-client/pom.xml
index 5197cc7..e4dd9d6 100644
--- a/samples/java-client/secure-client/pom.xml
+++ b/samples/java-client/secure-client/pom.xml
@@ -66,10 +66,20 @@
             <version>4.4</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4</version>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
             <version>1.7.10</version>
         </dependency>
+        <dependency>
+            <groupId>com.googlecode.json-simple</groupId>
+            <artifactId>json-simple</artifactId>
+            <version>1.1</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/AiravataSecurityException.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/AiravataSecurityException.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/AiravataSecurityException.java
new file mode 100644
index 0000000..2d5e959
--- /dev/null
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/AiravataSecurityException.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.secure.sample;
+
+public class AiravataSecurityException extends Exception {
+    public AiravataSecurityException(String message) {
+        super(message);
+    }
+
+    public AiravataSecurityException() {
+        super();
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java
deleted file mode 100644
index 0c2c518..0000000
--- a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Constants.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.airavata.secure.sample;
-
-public class Constants {
-    public static final String SERVER_HOST = "localhost";
-    public static final int SERVER_PORT = 8930;
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java
new file mode 100644
index 0000000..f547e0d
--- /dev/null
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthAppRegisteringClient.java
@@ -0,0 +1,109 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.secure.sample;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceException;
+import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
+import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.net.ssl.*;
+import java.rmi.RemoteException;
+
+public class OAuthAppRegisteringClient {
+    private OAuthAdminServiceStub stub;
+    private final static Logger logger = LoggerFactory.getLogger(OAuthAppRegisteringClient.class);
+
+    public OAuthAppRegisteringClient(String auhorizationServerURL, String username, String password,
+                                     ConfigurationContext configCtx) throws Exception {
+        String serviceURL = auhorizationServerURL + "OAuthAdminService";
+        try {
+            stub = new OAuthAdminServiceStub(configCtx, serviceURL);
+            CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, stub._getServiceClient());
+        } catch (AxisFault e) {
+            logger.error("Error initializing OAuth2 Client");
+            throw new Exception("Error initializing OAuth Client", e);
+        }
+        //TODO:enable proper SSL handshake
+        try {
+            // Get SSL context
+            SSLContext sc = SSLContext.getInstance("SSL");
+
+            // Create empty HostnameVerifier
+            HostnameVerifier hv = new HostnameVerifier() {
+                public boolean verify(String urlHostName, SSLSession session) {
+                    return true;
+                }
+            };
+            HttpsURLConnection.setDefaultHostnameVerifier(hv);
+
+            // Create a trust manager that does not validate certificate chains
+            TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+                public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+
+                public void checkClientTrusted(java.security.cert.X509Certificate[] certs,
+                                               String authType) {
+                }
+
+                public void checkServerTrusted(java.security.cert.X509Certificate[] certs,
+                                               String authType) {
+                }
+            }};
+
+            sc.init(null, trustAllCerts, new java.security.SecureRandom());
+            SSLContext.setDefault(sc);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public OAuthConsumerAppDTO registerApplication(String appName, String consumerId, String consumerSecret)
+            throws AiravataSecurityException {
+
+        try {
+            OAuthConsumerAppDTO consumerAppDTO = new OAuthConsumerAppDTO();
+            consumerAppDTO.setApplicationName(appName);
+            // consumer key and secret is set by the application.
+            consumerAppDTO.setOauthConsumerKey(consumerId);
+            consumerAppDTO.setOauthConsumerSecret(consumerSecret);
+            //consumerAppDTO.setUsername(adminUserName);
+            stub.registerOAuthApplicationData(consumerAppDTO);
+            // After registration application is retrieve
+            return stub.getOAuthApplicationDataByAppName(Properties.appName);
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+            throw new AiravataSecurityException("Error in registering the OAuth application.");
+        } catch (RemoteException e) {
+            e.printStackTrace();
+            throw new AiravataSecurityException("Error in registering the OAuth application.");
+        } catch (OAuthAdminServiceException e) {
+            e.printStackTrace();
+            throw new AiravataSecurityException("Error in registering the OAuth application.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java
new file mode 100644
index 0000000..10ac3db
--- /dev/null
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/OAuthTokenRetrievalClient.java
@@ -0,0 +1,87 @@
+package org.apache.airavata.secure.sample;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+
+import javax.net.ssl.SSLContext;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class OAuthTokenRetrievalClient {
+
+    public String retrieveAccessToken(String consumerId, String consumerSecret, String userName, String password)
+            throws SecurityException {
+
+        HttpPost postMethod = null;
+        try {
+            //TODO:handle SSL handshake properly.
+            org.apache.http.conn.ssl.SSLSocketFactory sf = new org.apache.http.conn.ssl.SSLSocketFactory(
+                    SSLContext.getDefault());
+            sf.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+            Scheme httpsScheme = new Scheme("https", sf, Properties.authzServerPort);
+            HttpClient httpClient = new DefaultHttpClient();
+            httpClient.getConnectionManager().getSchemeRegistry().register(httpsScheme);
+
+            postMethod = new HttpPost(Properties.oauthTokenEndPointURL);
+            //build the HTTP request with relevant params for resource owner credential grant type
+            String authInfo = consumerId + ":" + consumerSecret;
+            String authHeader = new String(Base64.encodeBase64(authInfo.getBytes()));
+
+            postMethod.setHeader("Content-Type", "application/x-www-form-urlencoded");
+            postMethod.setHeader("Authorization", "Basic " + authHeader);
+
+            List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
+            urlParameters.add(new BasicNameValuePair("grant_type", "password"));
+            urlParameters.add(new BasicNameValuePair("username", userName));
+            urlParameters.add(new BasicNameValuePair("password", password));
+
+            postMethod.setEntity(new UrlEncodedFormEntity(urlParameters));
+
+            HttpResponse response = httpClient.execute(postMethod);
+
+            BufferedReader rd = new BufferedReader(
+                    new InputStreamReader(response.getEntity().getContent()));
+
+            StringBuilder result = new StringBuilder();
+            String line = "";
+            while ((line = rd.readLine()) != null) {
+                result.append(line);
+            }
+
+            JSONParser parser = new JSONParser();
+            JSONObject jsonObject = (JSONObject) parser.parse(result.toString());
+            return (String) jsonObject.get("access_token");
+        } catch (ClientProtocolException e) {
+            throw new SecurityException(e.getMessage());
+        } catch (UnsupportedEncodingException e) {
+            throw new SecurityException(e.getMessage());
+        } catch (IOException e) {
+            throw new SecurityException(e.getMessage());
+        } catch (NoSuchAlgorithmException e) {
+            throw new SecurityException(e.getMessage());
+        } catch (ParseException e) {
+            throw new SecurityException(e.getMessage());
+        } finally {
+            if (postMethod != null) {
+                postMethod.releaseConnection();
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Properties.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Properties.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Properties.java
new file mode 100644
index 0000000..33661cc
--- /dev/null
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/Properties.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.secure.sample;
+
+public class Properties {
+    //Airavata server host, port
+    public static final String SERVER_HOST = "localhost";
+    public static final int SERVER_PORT = 8930;
+
+    public static String oauthAuthzServerURL = "https://localhost:9443/services/";
+    public static String oauthTokenEndPointURL = "https://localhost:9443/oauth2/token";
+    public static int authzServerPort = 9443;
+    public static String adminUserName = "admin";
+    public static String adminPassword = "admin";
+
+    //OAuth consumer app properties
+    public static String appName = "AiravataGWP1";
+    public static String consumerID = "AiravataGW1";
+    public static String consumerSecret = "AiravataGW1234";
+
+    //resource owner credential
+    public static String userName = "admin";
+    public static String password = "admin";
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/addb4be9/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
index f94f2ff..56c6992 100644
--- a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
@@ -22,21 +22,111 @@ package org.apache.airavata.secure.sample;
 
 import org.apache.airavata.api.client.AiravataClientFactory;
 import org.apache.airavata.model.error.AiravataClientConnectException;
-import org.apache.airavata.model.error.AiravataClientException;
-import org.apache.airavata.model.error.AiravataSystemException;
-import org.apache.airavata.model.error.InvalidRequestException;
 import org.apache.airavata.api.Airavata;
+import org.apache.airavata.model.security.AuthzToken;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
+
+import java.util.Scanner;
 
 public class SecureClient {
     private static Logger logger = LoggerFactory.getLogger(SecureClient.class);
 
-    public static void main(String[] args) throws AiravataClientConnectException, TException {
-        Airavata.Client client = createAiravataClient(Constants.SERVER_HOST, Constants.SERVER_PORT);
-        String version = client.getAPIVersion();
+    public static void main(String[] args) throws Exception {
+        //register OAuth application - this happens once during initialization of the gateway.
+
+        /************************Start obtaining input from user*****************************/
+        System.out.println("");
+        System.out.println("Registering OAuth application representing the client....");
+        System.out.println("Please enter following information as you prefer, or use defaults.");
+        Scanner scanner = new Scanner(System.in);
+        System.out.println("OAuth application name: (default:" + Properties.appName +
+                ", press 'd' to use default value.)");
+        String appNameInput = scanner.next();
+        String appName = null;
+        if (appNameInput.trim().equals("d")) {
+            appName = Properties.appName;
+        } else {
+            appName = appNameInput.trim();
+        }
+
+        System.out.println("Consumer Id: (default:" + Properties.consumerID + ", press 'd' to use default value.)");
+        String consumerIdInput = scanner.next();
+        String consumerId = null;
+        if (consumerIdInput.trim().equals("d")) {
+            consumerId = Properties.consumerID;
+        } else {
+            consumerId = consumerIdInput.trim();
+        }
+
+        System.out.println("Consumer Secret: (default:" + Properties.consumerSecret +
+                ", press 'd' to use default value.)");
+        String consumerSecInput = scanner.next();
+        String consumerSecret = null;
+        if (consumerSecInput.trim().equals("d")) {
+            consumerSecret = Properties.consumerSecret;
+        } else {
+            consumerSecret = consumerSecInput.trim();
+        }
+        /***************************** Finish obtaining input from user*******************************************/
+
+        /*********************** Perform registration of the client as an OAuth app***************************/
+        ConfigurationContext configContext =
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
+        OAuthAppRegisteringClient authAppRegisteringClient = new OAuthAppRegisteringClient(
+                Properties.oauthAuthzServerURL, Properties.adminUserName, Properties.adminPassword, configContext);
+        OAuthConsumerAppDTO appDTO = authAppRegisteringClient.registerApplication(appName, consumerId, consumerSecret);
+        /********************* Complete registering the client ***********************************************/
+        System.out.println("");
+        System.out.println("Registered OAuth app successfully. Following is app's details:");
+        System.out.println("App Name: " + appDTO.getApplicationName());
+        System.out.println("Consumer ID: " + appDTO.getOauthConsumerKey());
+        System.out.println("Consumer Secret: " + appDTO.getOauthConsumerSecret());
+        System.out.println("");
+        //obtain OAuth access token
+
+        /************************Start obtaining input from user*****************************/
+        System.out.println("Obtaining OAuth access token via 'Resource Owner Password' grant type....");
+        System.out.println("Please enter following information as you prefer, or use defaults.");
+        System.out.println("End user's name: (default:" + Properties.userName +
+                ", press 'd' to use default value.)");
+        String userNameInput = scanner.next();
+        String userName = null;
+        if (userNameInput.trim().equals("d")) {
+            userName = Properties.userName;
+        } else {
+            userName = userNameInput.trim();
+        }
+
+        System.out.println("End user's password: (default:" + Properties.password + ", press 'd' to use default value.)");
+        String passwordInput = scanner.next();
+        String password = null;
+        if (passwordInput.trim().equals("d")) {
+            password = Properties.password;
+        } else {
+            password = passwordInput.trim();
+        }
+        /***************************** Finish obtaining input from user*******************************************/
+
+        //obtain the OAuth token for the specified end user.
+        String accessToken = new OAuthTokenRetrievalClient().retrieveAccessToken(consumerId, consumerSecret, userName,
+                password);
+        System.out.println("OAuth access token obtained for the user: " + userName + " is: " + accessToken);
+        System.out.println("");
+
+        //invoke Airavata API by the SecureClient, on behalf of the user.
+        System.out.println("Invoking Airavata API...");
+        Airavata.Client client = createAiravataClient(Properties.SERVER_HOST, Properties.SERVER_PORT);
+        AuthzToken authzToken = new AuthzToken();
+        authzToken.setAccessToken(accessToken);
+        String version = client.getAPIVersion(authzToken);
         System.out.println("Airavata API version: " + version);
+        System.out.println("");
     }
 
     public static Airavata.Client createAiravataClient(String serverHost, int serverPort) throws
@@ -50,24 +140,4 @@ public class SecureClient {
             throw e;
         }
     }
-
-    public static String getAPIVersion(Airavata.Client client) throws TException {
-        try {
-            return client.getAPIVersion();
-        } catch (InvalidRequestException e) {
-            logger.error("Error in retrieving API version.");
-            throw new InvalidRequestException(e);
-        } catch (AiravataClientException e) {
-            logger.error("Error in retrieving API version.");
-            throw new AiravataClientException(e);
-        } catch (AiravataSystemException e) {
-            logger.error("Error in retrieving API version.");
-            throw new AiravataSystemException(e);
-        } catch (TException e) {
-            logger.error("Error in retrieving API version.");
-            throw new TException(e);
-        }
-    }
-
-
 }


[4/8] airavata git commit: making the access token to be used configurable.

Posted by sm...@apache.org.
making the access token to be used configurable.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/b62a56aa
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/b62a56aa
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/b62a56aa

Branch: refs/heads/master
Commit: b62a56aa29c15e070b1efcc7e4f7e05d5309fc45
Parents: addb4be
Author: Hasini Gunasinghe <ha...@gmail.com>
Authored: Mon May 25 08:43:10 2015 +0530
Committer: Hasini Gunasinghe <ha...@gmail.com>
Committed: Mon May 25 08:43:10 2015 +0530

----------------------------------------------------------------------
 .../org/apache/airavata/secure/sample/SecureClient.java  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/b62a56aa/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
----------------------------------------------------------------------
diff --git a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
index 56c6992..f3333f2 100644
--- a/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
+++ b/samples/java-client/secure-client/src/main/java/org/apache/airavata/secure/sample/SecureClient.java
@@ -121,9 +121,18 @@ public class SecureClient {
 
         //invoke Airavata API by the SecureClient, on behalf of the user.
         System.out.println("Invoking Airavata API...");
+        System.out.println("Enter the access token to be used: (default:" + accessToken + ", press 'd' to use default value.)");
+        String accessTokenInput = scanner.next();
+        String acTk = null;
+        if (accessTokenInput.trim().equals("d")) {
+            acTk = accessToken;
+        } else {
+            acTk = accessTokenInput.trim();
+        }
+
         Airavata.Client client = createAiravataClient(Properties.SERVER_HOST, Properties.SERVER_PORT);
         AuthzToken authzToken = new AuthzToken();
-        authzToken.setAccessToken(accessToken);
+        authzToken.setAccessToken(acTk);
         String version = client.getAPIVersion(authzToken);
         System.out.println("Airavata API version: " + version);
         System.out.println("");