axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r449457 - in /webservices/axis2/trunk/java/modules: integration/test/org/apache/rampart/ security/src/org/apache/rampart/ security/src/org/apache/rampart/builder/ security/src/org/apache/rampart/util/ security/test/org/apache/rampart/
Date Sun, 24 Sep 2006 18:46:49 GMT
Author: ruchithf
Date: Sun Sep 24 11:46:48 2006
New Revision: 449457

URL: http://svn.apache.org/viewvc?view=rev&rev=449457
Log:
Got the asymm sig only test working :-)

Modified:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartEngine.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java
Sun Sep 24 11:46:48 2006
@@ -65,7 +65,7 @@
             serviceClient.engageModule(new QName("addressing"));
             serviceClient.engageModule(new QName("rampart"));
 
-            for (int i = 1; i <= 1; i++) { //<-The number of tests we have
+            for (int i = 1; i <= 2; i++) { //<-The number of tests we have
                 options.setTo(new EndpointReference("http://127.0.0.1:" + PORT + "/axis2/services/SecureService"
+ i));
                 options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy("test-resources/rampart/policy/"
+ i + ".xml"));
                 serviceClient.setOptions(options);

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartEngine.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartEngine.java
Sun Sep 24 11:46:48 2006
@@ -58,8 +58,10 @@
             results = engine.processSecurityHeader(rmd.getDocument(),
                       null, 
                       RampartUtil.getPasswordCB(rmd),
-                      RampartUtil.getSignatureCrypto(rpd.getRampartConfig()), 
-                      RampartUtil.getEncryptionCrypto(rpd.getRampartConfig()));
+                      RampartUtil.getSignatureCrypto(rpd.getRampartConfig(), 
+                              msgCtx.getAxisService().getClassLoader()), 
+                      RampartUtil.getEncryptionCrypto(rpd.getRampartConfig(), 
+                              msgCtx.getAxisService().getClassLoader()));
         }
         
         return results;

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
Sun Sep 24 11:46:48 2006
@@ -122,6 +122,8 @@
     private boolean isClientSide;
     
     private boolean sender;
+    
+    private ClassLoader customClassLoader;
 
     public RampartMessageData(MessageContext msgCtx, boolean sender) throws RampartException
{
         
@@ -179,11 +181,12 @@
                         OMElement policyElem = param.getParameterElement().getFirstElement();
                         this.servicePolicy = PolicyEngine.getPolicy(policyElem);
                     }
+
+                    //Set the policy in the config ctx
+                    msgCtx.getConfigurationContext().setProperty(
+                            RampartMessageData.getOperationPolicyKey(msgCtx), this.servicePolicy);
                 }
                 
-                //Set the policy in the config ctx
-                msgCtx.getConfigurationContext().setProperty(
-                        RampartMessageData.getOperationPolicyKey(msgCtx), this.servicePolicy);
             }
             
             
@@ -211,6 +214,8 @@
             
             this.config = WSSConfig.getDefaultWSConfig();
 
+            this.customClassLoader = msgCtx.getAxisService().getClassLoader();
+            
             this.secHeader = new WSSecHeader();
             secHeader.insertSecurityHeader(this.document);
             
@@ -476,7 +481,8 @@
     public static String getOperationPolicyKey(MessageContext msgCtx) {
         if(msgCtx.getAxisOperation() != null) {
             return createPolicyKey(msgCtx.getAxisService().getName(), 
-                    msgCtx.getAxisOperation().getName());
+                                msgCtx.getAxisOperation().getName());
+            
         }
         return null;
     }
@@ -514,5 +520,9 @@
      */
     public boolean isClientSide() {
         return isClientSide;
+    }
+
+    public ClassLoader getCustomClassLoader() {
+        return customClassLoader;
     }
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
Sun Sep 24 11:46:48 2006
@@ -146,7 +146,7 @@
                     encr.setDocument(doc);
                     encr.setUserInfo(config.getEncryptionUser());
                     encr.setSymmetricEncAlgorithm(rpd.getAlgorithmSuite().getEncryption());
-                    encr.prepare(doc, RampartUtil.getEncryptionCrypto(config));
+                    encr.prepare(doc, RampartUtil.getEncryptionCrypto(config, rmd.getCustomClassLoader()));
 
                     Element bstElem = encr.getBinarySecurityTokenElement();
                     if (bstElem != null) {
@@ -324,11 +324,11 @@
             }
         }
         
+        Vector encrParts = RampartUtil.getEncryptedParts(rmd);
         //Do encryption
         Token encrToken = rpd.getRecipientToken();
-        if(encrToken != null) {
+        if(encrToken != null && encrParts.size() > 0) {
             Element refList = null;
-            Vector encrParts = RampartUtil.getEncryptedParts(rmd);
             if(encrToken.isDerivedKeys()) {
                 
                 try {
@@ -371,7 +371,7 @@
                     encr.setUserInfo(rpd.getRampartConfig().getEncryptionUser());
                     encr.setSymmetricEncAlgorithm(rpd.getAlgorithmSuite().getEncryption());
                     encr.prepare(doc, RampartUtil.getEncryptionCrypto(rpd
-                            .getRampartConfig()));
+                            .getRampartConfig(), rmd.getCustomClassLoader()));
                     
                     this.setInsertionLocation(this.timestampElement);
                     if(encr.getBSTTokenId() != null) {
@@ -462,12 +462,12 @@
         } else {
             sig = this.getSignatureBuider(rmd, sigToken);
             Element bstElem = sig.getBinarySecurityTokenElement();
-            if (Constants.INCLUDE_ALWAYS.equals(sigToken.getInclusion())
-                    || Constants.INCLUDE_ONCE.equals(sigToken.getInclusion())) {
+            if(bstElem != null) {
                 bstElem = RampartUtil.insertSiblingAfter(rmd, this
-                        .getInsertionLocation(), bstElem);
+                                        .getInsertionLocation(), bstElem);
                 this.setInsertionLocation(bstElem);
             }
+            
             if (rmd.getPolicyData().isTokenProtection()
                     && sig.getBSTTokenId() != null) {
                 sigParts.add(new WSEncryptionPart(sig.getBSTTokenId()));

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java
Sun Sep 24 11:46:48 2006
@@ -180,7 +180,7 @@
             encrKey.setKeySize(rpd.getAlgorithmSuite().getMaximumSymmetricKeyLength());
             encrKey.setKeyEncAlgo(rpd.getAlgorithmSuite().getAsymmetricKeyWrap());
             
-            encrKey.prepare(doc, RampartUtil.getEncryptionCrypto(rpd.getRampartConfig()));
+            encrKey.prepare(doc, RampartUtil.getEncryptionCrypto(rpd.getRampartConfig(),
rmd.getCustomClassLoader()));
             
             return encrKey;
         } catch (WSSecurityException e) {
@@ -251,7 +251,8 @@
         
         try {
             sig.prepare(rmd.getDocument(), RampartUtil.getSignatureCrypto(rpd
-                    .getRampartConfig()), rmd.getSecHeader());
+                    .getRampartConfig(), rmd.getCustomClassLoader()), 
+                    rmd.getSecHeader());
         } catch (WSSecurityException e) {
             throw new RampartException("errorInSignatureWithX509Token", e);
         }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
Sun Sep 24 11:46:48 2006
@@ -424,7 +424,8 @@
                 
                 encr.setEphemeralKey(encrTok.getSecret());
                 encr.setDocument(doc);
-                encr.prepare(doc, RampartUtil.getEncryptionCrypto(rpd.getRampartConfig()));
+                encr.prepare(doc, RampartUtil.getEncryptionCrypto(rpd
+                        .getRampartConfig(), rmd.getCustomClassLoader()));
                 
                 //Encrypt, get hold of the ref list and add it
                 refList = encr.encryptForExternalRef(null, encrParts);

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java
Sun Sep 24 11:46:48 2006
@@ -65,6 +65,7 @@
 
 public class RampartUtil {
 
+    private static final String CRYPTO_PROVIDER = "org.apache.ws.security.crypto.provider";
     private static Log log = LogFactory.getLog(RampartUtil.class);
     
 
@@ -165,7 +166,7 @@
      * @return
      * @throws RampartException
      */
-    public static Crypto getEncryptionCrypto(RampartConfig config)
+    public static Crypto getEncryptionCrypto(RampartConfig config, ClassLoader loader)
             throws RampartException {
         log.debug("Loading encryption crypto");
         
@@ -174,7 +175,8 @@
             String provider = cryptoConfig.getProvider();
             log.debug("Usig provider: " + provider);
             Properties prop = cryptoConfig.getProp();
-            return CryptoFactory.getInstance(provider, prop);
+            prop.put(CRYPTO_PROVIDER, provider);
+            return CryptoFactory.getInstance(prop, loader);
         } else {
             log.debug("Trying the signature crypto info");
             //Try using signature crypto infomation
@@ -184,7 +186,8 @@
                 String provider = cryptoConfig.getProvider();
                 log.debug("Usig provider: " + provider);
                 Properties prop = cryptoConfig.getProp();
-                return CryptoFactory.getInstance(provider, prop);
+                prop.put(CRYPTO_PROVIDER, provider);
+                return CryptoFactory.getInstance(prop, loader);
             } else {
                 return null;
             }
@@ -199,7 +202,7 @@
      * @return
      * @throws RampartException
      */
-    public static Crypto getSignatureCrypto(RampartConfig config)
+    public static Crypto getSignatureCrypto(RampartConfig config, ClassLoader loader)
             throws RampartException {
         log.debug("Loading Signature crypto");
         
@@ -208,7 +211,8 @@
             String provider = cryptoConfig.getProvider();
             log.debug("Usig provider: " + provider);
             Properties prop = cryptoConfig.getProp();
-            return CryptoFactory.getInstance(provider, prop);
+            prop.put(CRYPTO_PROVIDER, provider);
+            return CryptoFactory.getInstance(prop, loader);
         } else {
             return null;
         }
@@ -412,8 +416,8 @@
             client.setRstTemplate(rstTemplate);
     
             // Set crypto information
-            Crypto crypto = RampartUtil.getSignatureCrypto(rmd
-                    .getPolicyData().getRampartConfig());
+            Crypto crypto = RampartUtil.getSignatureCrypto(rmd.getPolicyData().getRampartConfig(),

+                    rmd.getMsgContext().getAxisService().getClassLoader());
             CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
             client.setCryptoInfo(crypto, cbh);
     

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java?view=diff&rev=449457&r1=449456&r2=449457
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
(original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
Sun Sep 24 11:46:48 2006
@@ -204,11 +204,12 @@
             
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
-            
+            System.out.println(ctx.getEnvelope());
             ArrayList list = new ArrayList();
             
             list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
             list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
             list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
             
             this.verifySecHeader(list.iterator(), ctx.getEnvelope());



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message