Change security context to support some of the gram functionality tests
authoramilaj <amilaj@unknown>
Thu, 20 Jun 2013 03:15:53 +0000 (03:15 +0000)
committeramilaj <amilaj@unknown>
Thu, 20 Jun 2013 03:15:53 +0000 (03:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/airavata/sandbox@1494844 13f79535-47bb-0310-9956-ffa450edef68

grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/SecurityContext.java

index f727026..2a07394 100644 (file)
@@ -40,6 +40,9 @@ public class SecurityContext {
     private MyProxyCredentials myProxyCredentials;
     private static final Logger log = Logger.getLogger(SecurityContext.class);
 
+    private String userName = null;
+    private String password = null;
+
     /**
      * 
      * Constructs a ApplicationGlobalContext.
@@ -53,6 +56,17 @@ public class SecurityContext {
 
     }
 
+    public SecurityContext(String user, String pwd) throws Exception {
+
+        this.userName = user;
+        this.password = pwd;
+
+        log.setLevel(org.apache.log4j.Level.INFO);
+        loadConfiguration();
+
+    }
+
+
     public static void main(String[] args) {
         try {
             SecurityContext myproxy = new SecurityContext();
@@ -124,14 +138,18 @@ public class SecurityContext {
                         this.myProxyCredentials.setMyProxyPortNumber(MyProxy.DEFAULT_PORT);
                     }
                     String myproxyuser = properties.getProperty(ServiceConstants.MYPROXY_USERNAME);
-                    if (myproxyuser != null) {
+                    if (userName != null) {
+                        this.myProxyCredentials.setMyProxyUserName(userName);
+                    } else {
                         this.myProxyCredentials.setMyProxyUserName(myproxyuser);
                     }
 
                     System.out.println("My proxy user name " + myproxyuser);
 
                     String myproxypass = properties.getProperty(ServiceConstants.MYPROXY_PASSWD);
-                    if (myproxypass != null) {
+                    if (password != null) {
+                        this.myProxyCredentials.setMyProxyPassword(password);
+                    } else {
                         this.myProxyCredentials.setMyProxyPassword(myproxypass);
                     }
 
@@ -171,6 +189,16 @@ public class SecurityContext {
     }
 
     /**
+     * Returns the raw gssCredential, without creating a proxy.
+     *
+     * @return The gssCredential
+     */
+    public GSSCredential getRawCredential() throws Exception{
+
+        return gssCredential;
+    }
+
+    /**
      * Returns the gssCredential.
      * 
      * @return The gssCredential