airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patanac...@apache.org
Subject svn commit: r1162187 - in /incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers: AmazonSecurityHandler.java MyProxySecurityHandler.java
Date Fri, 26 Aug 2011 17:54:39 GMT
Author: patanachai
Date: Fri Aug 26 17:54:38 2011
New Revision: 1162187

URL: http://svn.apache.org/viewvc?rev=1162187&view=rev
Log:
Check null to prevent empty header SOAP

Modified:
    incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/AmazonSecurityHandler.java
    incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/MyProxySecurityHandler.java

Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/AmazonSecurityHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/AmazonSecurityHandler.java?rev=1162187&r1=1162186&r2=1162187&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/AmazonSecurityHandler.java
(original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/AmazonSecurityHandler.java
Fri Aug 26 17:54:38 2011
@@ -17,7 +17,7 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
+ */
 
 package org.apache.airavata.services.gfac.axis2.handlers;
 
@@ -38,39 +38,42 @@ import org.apache.axis2.handlers.Abstrac
 
 public class AmazonSecurityHandler extends AbstractHandler {
 
-	private static final String SECURITY_CONTEXT = "security-context";
-	private static final String AMAZON = "amazon-webservices";
-	private static final String ACCESS_KEY_ID = "access-key-id";
-	private static final String SECRET_ACCESS_KEY = "secret-access-key";
-
-	public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
-		SOAPEnvelope envelope = msgContext.getEnvelope();
-		SOAPHeader header = envelope.getHeader();
-		Iterator it = header.examineAllHeaderBlocks();
-		while (it.hasNext()) {
-			SOAPHeaderBlock x = (SOAPHeaderBlock) it.next();
-			String elementName = x.getLocalName();
-
-			if (elementName.equals(SECURITY_CONTEXT)) {
-
-				OMElement amazon = x.getFirstChildWithName(new QName(null, AMAZON));
-
-				if (amazon != null) {
-
-					AmazonSecurityContext amazonSecurityContext = new AmazonSecurityContext();
-
-					OMElement accessKey = amazon.getFirstChildWithName(new QName(null, ACCESS_KEY_ID));
-					OMElement secretKey = amazon.getFirstChildWithName(new QName(null, SECRET_ACCESS_KEY));
-
-					amazonSecurityContext.setAccessKey(accessKey.getText());
-					amazonSecurityContext.setSecretKey(secretKey.getText());
-
-					// set to context
-					MessageContextUtil.addContextToProperty(msgContext, GFacService.SECURITY_CONTEXT, "amazon",amazonSecurityContext);
-				}
-			}
-		}
-		return InvocationResponse.CONTINUE;
-	}
+    private static final String SECURITY_CONTEXT = "security-context";
+    private static final String AMAZON = "amazon-webservices";
+    private static final String ACCESS_KEY_ID = "access-key-id";
+    private static final String SECRET_ACCESS_KEY = "secret-access-key";
+
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+        SOAPEnvelope envelope = msgContext.getEnvelope();
+        SOAPHeader header = envelope.getHeader();
+        if (header != null) {
+            Iterator it = header.examineAllHeaderBlocks();
+            while (it.hasNext()) {
+                SOAPHeaderBlock x = (SOAPHeaderBlock) it.next();
+                String elementName = x.getLocalName();
+
+                if (elementName.equals(SECURITY_CONTEXT)) {
+
+                    OMElement amazon = x.getFirstChildWithName(new QName(null, AMAZON));
+
+                    if (amazon != null) {
+
+                        AmazonSecurityContext amazonSecurityContext = new AmazonSecurityContext();
+
+                        OMElement accessKey = amazon.getFirstChildWithName(new QName(null,
ACCESS_KEY_ID));
+                        OMElement secretKey = amazon.getFirstChildWithName(new QName(null,
SECRET_ACCESS_KEY));
+
+                        amazonSecurityContext.setAccessKey(accessKey.getText());
+                        amazonSecurityContext.setSecretKey(secretKey.getText());
+
+                        // set to context
+                        MessageContextUtil.addContextToProperty(msgContext, GFacService.SECURITY_CONTEXT,
"amazon",
+                                amazonSecurityContext);
+                    }
+                }
+            }
+        }
+        return InvocationResponse.CONTINUE;
+    }
 
 }

Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/MyProxySecurityHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/MyProxySecurityHandler.java?rev=1162187&r1=1162186&r2=1162187&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/MyProxySecurityHandler.java
(original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/handlers/MyProxySecurityHandler.java
Fri Aug 26 17:54:38 2011
@@ -17,7 +17,7 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
+ */
 
 package org.apache.airavata.services.gfac.axis2.handlers;
 
@@ -38,44 +38,47 @@ import org.apache.axis2.handlers.Abstrac
 
 public class MyProxySecurityHandler extends AbstractHandler {
 
-	private static final String SECURITY_CONTEXT = "security-context";
-	private static final String MYPROXY = "grid-myproxy";
-	private static final String MYPROXY_SERVER = "myproxy-server";
-	private static final String MYPROXY_USERNAME = "username";
-	private static final String MYPROXY_PASSWORD = "password";
-	private static final String MYPROXY_LIFE = "life-time-inhours";
-
-	public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
-		SOAPEnvelope envelope = msgContext.getEnvelope();
-		SOAPHeader header = envelope.getHeader();
-		Iterator it = header.examineAllHeaderBlocks();
-		while (it.hasNext()) {
-			SOAPHeaderBlock x = (SOAPHeaderBlock) it.next();
-			String elementName = x.getLocalName();
-
-			if (elementName.equals(SECURITY_CONTEXT)) {
-
-				OMElement myproxy = x.getFirstChildWithName(new QName(null, MYPROXY));
-
-				if (myproxy != null) {
-					GSISecurityContext gsiSecurityContext = new GSISecurityContext();
-
-					OMElement server = myproxy.getFirstChildWithName(new QName(null, MYPROXY_SERVER));
-					OMElement username = myproxy.getFirstChildWithName(new QName(null, MYPROXY_USERNAME));
-					OMElement password = myproxy.getFirstChildWithName(new QName(null, MYPROXY_PASSWORD));
-					OMElement life = myproxy.getFirstChildWithName(new QName(null, MYPROXY_LIFE));
-
-					gsiSecurityContext.setMyproxyServer(server.getText());
-					gsiSecurityContext.setMyproxyUserName(username.getText());
-					gsiSecurityContext.setMyproxyPasswd(password.getText());
-					gsiSecurityContext.setMyproxyLifetime(Integer.parseInt(life.getText()));
-
-					// set to context
-					MessageContextUtil.addContextToProperty(msgContext, GFacService.SECURITY_CONTEXT, "myproxy",
gsiSecurityContext);
-				}
-			}
-		}
-		return InvocationResponse.CONTINUE;
-	}
+    private static final String SECURITY_CONTEXT = "security-context";
+    private static final String MYPROXY = "grid-myproxy";
+    private static final String MYPROXY_SERVER = "myproxy-server";
+    private static final String MYPROXY_USERNAME = "username";
+    private static final String MYPROXY_PASSWORD = "password";
+    private static final String MYPROXY_LIFE = "life-time-inhours";
+
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+        SOAPEnvelope envelope = msgContext.getEnvelope();
+        SOAPHeader header = envelope.getHeader();
+        if (header != null) {
+            Iterator it = header.examineAllHeaderBlocks();
+            while (it.hasNext()) {
+                SOAPHeaderBlock x = (SOAPHeaderBlock) it.next();
+                String elementName = x.getLocalName();
+
+                if (elementName.equals(SECURITY_CONTEXT)) {
+
+                    OMElement myproxy = x.getFirstChildWithName(new QName(null, MYPROXY));
+
+                    if (myproxy != null) {
+                        GSISecurityContext gsiSecurityContext = new GSISecurityContext();
+
+                        OMElement server = myproxy.getFirstChildWithName(new QName(null,
MYPROXY_SERVER));
+                        OMElement username = myproxy.getFirstChildWithName(new QName(null,
MYPROXY_USERNAME));
+                        OMElement password = myproxy.getFirstChildWithName(new QName(null,
MYPROXY_PASSWORD));
+                        OMElement life = myproxy.getFirstChildWithName(new QName(null, MYPROXY_LIFE));
+
+                        gsiSecurityContext.setMyproxyServer(server.getText());
+                        gsiSecurityContext.setMyproxyUserName(username.getText());
+                        gsiSecurityContext.setMyproxyPasswd(password.getText());
+                        gsiSecurityContext.setMyproxyLifetime(Integer.parseInt(life.getText()));
+
+                        // set to context
+                        MessageContextUtil.addContextToProperty(msgContext, GFacService.SECURITY_CONTEXT,
"myproxy",
+                                gsiSecurityContext);
+                    }
+                }
+            }
+        }
+        return InvocationResponse.CONTINUE;
+    }
 
 }



Mime
View raw message