[picketlink-commits] Picketlink SVN: r1152 - in trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws: handler and 2 other directories.

picketlink-commits at lists.jboss.org picketlink-commits at lists.jboss.org
Fri Aug 5 16:09:22 EDT 2011


Author: anil.saldhana at jboss.com
Date: 2011-08-05 16:09:21 -0400 (Fri, 05 Aug 2011)
New Revision: 1152

Modified:
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/PicketLinkDispatch.java
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthenticationHandler.java
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthorizationHandler.java
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/JBWSTokenIssuingLoginModule.java
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java
   trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/util/JBossWSSERoleExtractor.java
Log:
PLFED-219: error codes

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/PicketLinkDispatch.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/PicketLinkDispatch.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/PicketLinkDispatch.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -56,6 +56,7 @@
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
+import org.picketlink.identity.federation.core.ErrorCodes;
 import org.picketlink.identity.federation.core.saml.v2.common.IDGenerator;
 import org.picketlink.identity.federation.core.util.Base64;
 import org.picketlink.identity.federation.core.util.SOAPUtil;
@@ -192,7 +193,7 @@
       { 
          boolean result = handler.handleMessage(msgContext);
          if( !result)
-            throw new WebServiceException("Handler "+ handler.getClass() + " returned false");
+            throw new WebServiceException(ErrorCodes.PROCESSING_EXCEPTION + "Handler "+ handler.getClass() + " returned false");
       }
       
       if(sslSocketFactory != null)

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -38,6 +38,7 @@
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
+import org.picketlink.identity.federation.core.ErrorCodes;
 import org.picketlink.identity.federation.core.util.StringUtil;
 import org.picketlink.trust.jbossws.Constants;
 import org.picketlink.trust.jbossws.Util;
@@ -214,15 +215,15 @@
       }
       
       if( httpHeaderName == null && httpCookieName == null )
-         throw new RuntimeException("Either httpHeaderName or httpCookieName should be set" );
+         throw new RuntimeException(ErrorCodes.INJECTED_VALUE_MISSING + "Either httpHeaderName or httpCookieName should be set" );
       
       HttpServletRequest servletRequest = getHttpRequest(msgContext);
       if( servletRequest == null )
-         throw new IllegalStateException("Unable to proceed as Http request is null"); 
+         throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Unable to proceed as Http request is null"); 
        
       String token = getTokenValue(servletRequest);
       if(token==null)
-         throw new IllegalStateException("Null Token");
+         throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Null Token");
       SOAPElement security = null;
       try
       {

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -33,6 +33,7 @@
 
 import org.jboss.security.SecurityContext;
 import org.picketlink.identity.federation.bindings.jboss.subject.PicketLinkPrincipal;
+import org.picketlink.identity.federation.core.ErrorCodes;
 import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
 import org.picketlink.identity.federation.core.saml.v2.util.AssertionUtil;
 import org.picketlink.identity.federation.core.util.StringUtil;
@@ -71,7 +72,7 @@
       SOAPMessage soapMessage = ctx.getMessage();
       
       if(soapMessage == null)
-         throw new IllegalStateException("SOAP Message is null");
+         throw new IllegalStateException(ErrorCodes.NULL_VALUE + "SOAP Message");
       
       // retrieve the assertion
       Document document = soapMessage.getSOAPPart();
@@ -84,7 +85,7 @@
          {
             assertionType = SAMLUtil.fromElement(assertion);
             if(AssertionUtil.hasExpired(assertionType))
-               throw new RuntimeException("Assertion has expired");
+               throw new RuntimeException(ErrorCodes.EXPIRED_ASSERTION + "Assertion has expired");
          }
          catch(Exception e )
          { 

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthenticationHandler.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthenticationHandler.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthenticationHandler.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -28,6 +28,7 @@
 
 import org.jboss.security.AuthenticationManager;
 import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+import org.picketlink.identity.federation.core.ErrorCodes;
 
 /**
  * Perform Authentication for POJO Web Services
@@ -57,7 +58,7 @@
 
       if (authenticationManager.isValid(principal, credential, subject) == false)
       {
-         String msg = "Authentication failed, principal=" + principal;
+         String msg = ErrorCodes.PROCESSING_EXCEPTION + "Authentication failed, principal=" + principal;
          log.error(msg);
          SecurityException e = new SecurityException(msg);
          throw new RuntimeException(e);

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthorizationHandler.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthorizationHandler.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/WSAuthorizationHandler.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -43,6 +43,7 @@
 import org.jboss.security.SimplePrincipal;
 import org.jboss.security.callbacks.SecurityContextCallbackHandler;
 import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+import org.picketlink.identity.federation.core.ErrorCodes;
 import org.picketlink.identity.federation.core.exceptions.ProcessingException;
 import org.picketlink.trust.jbossws.util.JBossWSNativeStackUtil;
 import org.picketlink.trust.jbossws.util.JBossWSSERoleExtractor;
@@ -75,7 +76,7 @@
       //Read the jboss-wsse.xml file
       InputStream is = getWSSE(context);
       if( is == null )
-         throw new RuntimeException( "unable to load jboss-wsse.xml");
+         throw new RuntimeException(ErrorCodes.RESOURCE_NOT_FOUND +  "unable to load jboss-wsse.xml");
       
       QName portName = (QName) msgContext.get(MessageContext.WSDL_PORT); 
       QName opName = (QName) msgContext.get(MessageContext.WSDL_OPERATION);
@@ -84,13 +85,13 @@
          portName = JBossWSNativeStackUtil.getPortNameViaReflection(getClass(), msgContext);
       
       if(portName == null)
-         throw new RuntimeException("Unable to determine port name from the message context");
+         throw new RuntimeException(ErrorCodes.NULL_VALUE + "Unable to determine port name from the message context");
       
       if(opName == null)
          opName = getOperationName(msgContext);
       
       if(opName == null)
-         throw new RuntimeException("Unable to determine operation name from the message context");
+         throw new RuntimeException(ErrorCodes.NULL_VALUE + "Unable to determine operation name from the message context");
       
       List<String> roles = null;
       
@@ -132,7 +133,7 @@
             builder.append("::Actual Roles=").append(authorizationManager.getSubjectRoles(subject,scbh));
             log.error(builder.toString() );
             
-            throw new RuntimeException("Authorization Failed");
+            throw new RuntimeException(ErrorCodes.PROCESSING_EXCEPTION + "Authorization Failed");
          }
       }
       return true;
@@ -151,7 +152,7 @@
    protected InputStream getWSSE(ServletContext context)
    {
       if( context == null )
-         throw new RuntimeException("Servlet Context is null");
+         throw new RuntimeException(ErrorCodes.NULL_VALUE + "Servlet Context is null");
       
       InputStream is = context.getResourceAsStream("/WEB-INF/jboss-wsse.xml");
       return is;

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/JBWSTokenIssuingLoginModule.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/JBWSTokenIssuingLoginModule.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/JBWSTokenIssuingLoginModule.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -35,6 +35,7 @@
 
 import org.jboss.logging.Logger;
 import org.picketlink.identity.federation.bindings.jboss.subject.PicketLinkPrincipal;
+import org.picketlink.identity.federation.core.ErrorCodes;
 import org.picketlink.identity.federation.core.util.StringUtil;
 import org.picketlink.identity.federation.core.wstrust.STSClient;
 import org.picketlink.identity.federation.core.wstrust.STSClientConfig;
@@ -96,7 +97,7 @@
             } 
          }
          if(samlCredential == null)
-            throw new LoginException("SamlCredential is not available in subject");
+            throw new LoginException(ErrorCodes.NULL_VALUE + "SamlCredential is not available in subject");
          Principal principal = new PicketLinkPrincipal("");
          if (super.isUseFirstPass())
          {
@@ -176,7 +177,7 @@
                   }
                   catch (Exception e)
                   {
-                     throw new RuntimeException("Unable to instantiate handler:"+token, e);
+                     throw new RuntimeException(ErrorCodes.CANNOT_CREATE_INSTANCE + "Unable to instantiate handler:"+token, e);
                   }
                }
             }
@@ -221,7 +222,7 @@
                      }
                      catch (Exception e1)
                      {
-                        throw new RuntimeException("Unable to create SSL Socket Factory:",e1);
+                        throw new RuntimeException(ErrorCodes.PROCESSING_EXCEPTION + "Unable to create SSL Socket Factory:",e1);
                      }
                   }
                   finally

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -35,6 +35,7 @@
 import org.jboss.security.SimpleGroup;
 import org.jboss.security.SimplePrincipal;
 import org.jboss.security.auth.spi.AbstractServerLoginModule;
+import org.picketlink.identity.federation.core.ErrorCodes;
 import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
 import org.picketlink.identity.federation.core.saml.v2.util.AssertionUtil;
 import org.picketlink.identity.federation.core.util.StringUtil;
@@ -99,7 +100,7 @@
             return p;
          }
       }
-      throw new RuntimeException("Unable to get the Identity from the subject.");
+      throw new RuntimeException(ErrorCodes.PROCESSING_EXCEPTION + "Unable to get the Identity from the subject.");
    }
    
    @Override
@@ -117,13 +118,13 @@
          } 
       }
       if( samlCredential == null)
-         throw new RuntimeException("SAML Credential not found in the subject");
+         throw new RuntimeException(ErrorCodes.NULL_VALUE + "SAML Credential not found in the subject");
       
       try
       { 
          String assertionStr = samlCredential.getAssertionAsString();
          if(StringUtil.isNullOrEmpty(assertionStr))
-            throw new RuntimeException("Assertion String is null or empty");
+            throw new RuntimeException(ErrorCodes.NULL_VALUE + "Assertion String is null or empty");
          
          SAMLParser parser = new SAMLParser();
          AssertionType assertion = (AssertionType) parser.parse(new ByteArrayInputStream(assertionStr.getBytes()));

Modified: trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/util/JBossWSSERoleExtractor.java
===================================================================
--- trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/util/JBossWSSERoleExtractor.java	2011-08-02 03:18:49 UTC (rev 1151)
+++ trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/util/JBossWSSERoleExtractor.java	2011-08-05 20:09:21 UTC (rev 1152)
@@ -25,6 +25,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.picketlink.identity.federation.core.ErrorCodes;
 import org.picketlink.identity.federation.core.exceptions.ProcessingException;
 import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
 import org.w3c.dom.Document;
@@ -122,7 +123,7 @@
          int len = nl.getLength();
 
          if( len > 1 )
-            throw new ProcessingException( "More than one authorize element");
+            throw new ProcessingException( ErrorCodes.PROCESSING_EXCEPTION + "More than one authorize element");
          Node authorize = nl.item(0);
          roles.addAll(getRolesFromAuthorize((Element) authorize));
       } 
@@ -160,7 +161,7 @@
    {
       //Validate that we do not have unchecked and roles
       if(roles.contains(UNCHECKED) && roles.size() > 1)
-         throw new ProcessingException("unchecked and role(s) cannot be together");
+         throw new ProcessingException(ErrorCodes.PROCESSING_EXCEPTION + "unchecked and role(s) cannot be together");
       return roles;
    }
    



More information about the picketlink-commits mailing list