Author: nandana
Date: Fri Aug 28 18:22:44 2009
New Revision: 808980

URL: http://svn.apache.org/viewvc?rev=808980&view=rev
Log:
RAMPART-246 Applying the patch. Thanks Prabath.

Modified:
    
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuer.java
    
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuerConfig.java

Modified: 
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuer.java
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuer.java?rev=808980&r1=808979&r2=808980&view=diff
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuer.java
 (original)
+++ 
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuer.java
 Fri Aug 28 18:22:44 2009
@@ -45,6 +45,7 @@
 import org.apache.ws.security.components.crypto.CryptoFactory;
 import org.apache.ws.security.message.WSSecEncryptedKey;
 import org.apache.ws.security.util.Base64;
+import org.apache.ws.security.util.Loader;
 import org.apache.ws.security.util.XmlSchemaDateFormat;
 import org.apache.xml.security.signature.XMLSignature;
 import org.apache.xml.security.utils.EncryptionConstants;
@@ -438,6 +439,27 @@
                SAMLCallbackHandler handler = config.getCallbackHander();
                handler.handle(cb);
                attrs = cb.getAttributes();
+            } else if (config.getCallbackHandlerName() != null
+                                       && 
config.getCallbackHandlerName().trim().length() > 0) {
+                               SAMLAttributeCallback cb = new 
SAMLAttributeCallback(data);
+                               SAMLCallbackHandler handler = null;
+                               MessageContext msgContext = 
data.getInMessageContext();
+                               ClassLoader classLoader = 
msgContext.getAxisService().getClassLoader();
+                               Class cbClass = null;
+                               try {
+                                       cbClass = Loader.loadClass(classLoader, 
config.getCallbackHandlerName());
+                               } catch (ClassNotFoundException e) {
+                                       throw new 
TrustException("cannotLoadPWCBClass", new String[]{config
+                                                       
.getCallbackHandlerName()}, e);
+                               }
+                               try {
+                                       handler = (SAMLCallbackHandler) 
cbClass.newInstance();
+                               } catch (java.lang.Exception e) {
+                                       throw new 
TrustException("cannotCreatePWCBInstance", new String[]{config
+                                                       
.getCallbackHandlerName()}, e);
+                               }
+                               handler.handle(cb);
+                               attrs = cb.getAttributes();
             }else{
                //TODO Remove this after discussing
                 SAMLAttribute attribute = new SAMLAttribute("Name",

Modified: 
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuerConfig.java
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuerConfig.java?rev=808980&r1=808979&r2=808980&view=diff
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuerConfig.java
 (original)
+++ 
webservices/rampart/trunk/java/modules/rampart-trust/src/main/java/org/apache/rahas/impl/SAMLTokenIssuerConfig.java
 Fri Aug 28 18:22:44 2009
@@ -61,10 +61,15 @@
     private final static QName ISSUER_KEY_ALIAS = new QName("issuerKeyAlias");
 
     /**
-     * Element name to include the password of the private key to sign the
-     * response or the issued token
-     */
-    private final static QName ISSUER_KEY_PASSWD = new 
QName("issuerKeyPassword");
+        * Element name to include the password of the private key to sign the 
response or the issued
+        * token
+        */
+       private final static QName ISSUER_KEY_PASSWD = new 
QName("issuerKeyPassword");
+
+       /**
+        * Element name of the attribute call-back handler
+        */
+       private final static QName ATTR_CALLBACK_HANDLER_NAME = new 
QName("attrCallbackHandlerName");
 
     /**
      * Element to specify the lifetime of the SAMLToken
@@ -94,6 +99,7 @@
     protected Map trustedServices = new HashMap();
     protected String trustStorePropFile;
     protected SAMLCallbackHandler callbackHander;
+    protected String callbackHandlerName;
   
     /**
      * Create a new configuration with issuer name and crypto information
@@ -140,6 +146,11 @@
             this.proofKeyType = proofKeyElem.getText().trim();
         }
 
+        OMElement callbackNameElem = 
elem.getFirstChildWithName(ATTR_CALLBACK_HANDLER_NAME);
+        if (callbackNameElem != null) {
+            this.callbackHandlerName = callbackNameElem.getText().trim();
+        }
+        
         //The alias of the private key
         OMElement userElem = elem.getFirstChildWithName(ISSUER_KEY_ALIAS);
         if (userElem != null) {
@@ -286,6 +297,9 @@
         OMElement issuerKeyPasswd = fac.createOMElement(ISSUER_KEY_PASSWD, 
configElem);
         issuerKeyPasswd.setText(this.issuerKeyPassword);
         
+        OMElement callbackHandlerName = 
fac.createOMElement(ATTR_CALLBACK_HANDLER_NAME, configElem);
+        callbackHandlerName.setText(this.callbackHandlerName);
+        
         configElem.addChild(this.cryptoPropertiesElement);
         
         OMElement keySizeElem = fac.createOMElement(KEY_SIZE, configElem);
@@ -398,6 +412,14 @@
        public void setCallbackHander(SAMLCallbackHandler callbackHander) {
                this.callbackHander = callbackHander;
        }
+       
+       public String getCallbackHandlerName() {
+               return callbackHandlerName;
+       }
+
+       public void setCallbackHandlerName(String callbackHandlerName) {
+               this.callbackHandlerName = callbackHandlerName;
+       }
 
     /**
      * Uses the <code>wst:AppliesTo</code> to figure out the certificate to


Reply via email to