cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1173560 - in /cxf/trunk/services/sts/sts-core/src/test: java/org/apache/cxf/sts/common/ java/org/apache/cxf/sts/operation/ resources/restricted/
Date Wed, 21 Sep 2011 10:27:55 GMT
Author: coheigea
Date: Wed Sep 21 10:27:54 2011
New Revision: 1173560

URL: http://svn.apache.org/viewvc?rev=1173560&view=rev
Log:
Add support to build the STS core if unlimited security policies are not installed

Added:
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/TestUtils.java
    cxf/trunk/services/sts/sts-core/src/test/resources/restricted/
    cxf/trunk/services/sts/sts-core/src/test/resources/restricted/stsstore.jks
Modified:
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java

Added: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/TestUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/TestUtils.java?rev=1173560&view=auto
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/TestUtils.java
(added)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/TestUtils.java
Wed Sep 21 10:27:54 2011
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.sts.common;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+public final class TestUtils {
+    
+    private TestUtils() {
+        // complete
+    }
+
+    public static boolean checkUnrestrictedPoliciesInstalled() {
+        boolean unrestrictedPoliciesInstalled = false;
+        try {
+            byte[] data = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+
+            SecretKey key192 = new SecretKeySpec(
+                new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                            0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                            0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17},
+                            "AES");
+            Cipher c = Cipher.getInstance("AES");
+            c.init(Cipher.ENCRYPT_MODE, key192);
+            c.doFinal(data);
+            unrestrictedPoliciesInstalled = true;
+        } catch (Exception e) {
+            return unrestrictedPoliciesInstalled;
+        }
+        return unrestrictedPoliciesInstalled;
+    }
+    
+}

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java?rev=1173560&r1=1173559&r2=1173560&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
(original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
Wed Sep 21 10:27:54 2011
@@ -36,6 +36,7 @@ import org.apache.cxf.sts.QNameConstants
 import org.apache.cxf.sts.STSConstants;
 import org.apache.cxf.sts.StaticSTSProperties;
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
+import org.apache.cxf.sts.common.TestUtils;
 import org.apache.cxf.sts.service.EncryptionProperties;
 import org.apache.cxf.sts.service.ServiceMBean;
 import org.apache.cxf.sts.service.StaticService;
@@ -53,6 +54,12 @@ import org.apache.ws.security.components
  */
 public class IssueEncryptedUnitTest extends org.junit.Assert {
     
+    private static boolean unrestrictedPoliciesInstalled;
+    
+    static {
+        unrestrictedPoliciesInstalled = TestUtils.checkUnrestrictedPoliciesInstalled();
+    };
+    
     /**
      * Test to successfully issue a (dummy) encrypted token.
      */
@@ -69,6 +76,11 @@ public class IssueEncryptedUnitTest exte
         // Add Service
         ServiceMBean service = new StaticService();
         service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
+        EncryptionProperties encryptionProperties = new EncryptionProperties();
+        if (!unrestrictedPoliciesInstalled) {
+            encryptionProperties.setEncryptionAlgorithm(WSConstants.AES_128);
+        }
+        service.setEncryptionProperties(encryptionProperties);
         issueOperation.setServices(Collections.singletonList(service));
         
         // Add STSProperties object
@@ -117,6 +129,11 @@ public class IssueEncryptedUnitTest exte
         // Add Service
         ServiceMBean service = new StaticService();
         service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
+        EncryptionProperties encryptionProperties = new EncryptionProperties();
+        if (!unrestrictedPoliciesInstalled) {
+            encryptionProperties.setEncryptionAlgorithm(WSConstants.AES_128);
+        }
+        service.setEncryptionProperties(encryptionProperties);
         issueOperation.setServices(Collections.singletonList(service));
         
         // Add STSProperties object
@@ -148,7 +165,6 @@ public class IssueEncryptedUnitTest exte
             // expected
         }
         
-        EncryptionProperties encryptionProperties = new EncryptionProperties();
         encryptionProperties.setEncryptionName("myservicekey");
         service.setEncryptionProperties(encryptionProperties);
         
@@ -310,6 +326,9 @@ public class IssueEncryptedUnitTest exte
         service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
         EncryptionProperties encryptionProperties = new EncryptionProperties();
         encryptionProperties.setEncryptionName("myservicekey");
+        if (!unrestrictedPoliciesInstalled) {
+            encryptionProperties.setEncryptionAlgorithm(WSConstants.AES_128);
+        }
         encryptionProperties.setKeyWrapAlgorithm(WSConstants.KEYTRANSPORT_RSAOEP);
         service.setEncryptionProperties(encryptionProperties);
         issueOperation.setServices(Collections.singletonList(service));
@@ -369,6 +388,9 @@ public class IssueEncryptedUnitTest exte
         service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
         EncryptionProperties encryptionProperties = new EncryptionProperties();
         encryptionProperties.setEncryptionName("myservicekey");
+        if (!unrestrictedPoliciesInstalled) {
+            encryptionProperties.setEncryptionAlgorithm(WSConstants.AES_128);
+        }
         service.setEncryptionProperties(encryptionProperties);
         issueOperation.setServices(Collections.singletonList(service));
         
@@ -441,6 +463,9 @@ public class IssueEncryptedUnitTest exte
         service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
         EncryptionProperties encryptionProperties = new EncryptionProperties();
         encryptionProperties.setEncryptionName("myservicekey");
+        if (!unrestrictedPoliciesInstalled) {
+            encryptionProperties.setEncryptionAlgorithm(WSConstants.AES_128);
+        }
         encryptionProperties.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
         service.setEncryptionProperties(encryptionProperties);
         issueOperation.setServices(Collections.singletonList(service));
@@ -515,10 +540,13 @@ public class IssueEncryptedUnitTest exte
             "org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin"
         );
         properties.put("org.apache.ws.security.crypto.merlin.keystore.password", "stsspass");
-        properties.put("org.apache.ws.security.crypto.merlin.keystore.file", "stsstore.jks");
+        if (unrestrictedPoliciesInstalled) {
+            properties.put("org.apache.ws.security.crypto.merlin.keystore.file", "stsstore.jks");
+        } else {
+            properties.put("org.apache.ws.security.crypto.merlin.keystore.file", "restricted/stsstore.jks");
+        }
         
         return properties;
     }
     
-    
 }

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java?rev=1173560&r1=1173559&r2=1173560&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
(original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
Wed Sep 21 10:27:54 2011
@@ -42,6 +42,8 @@ import org.apache.cxf.sts.StaticSTSPrope
 import org.apache.cxf.sts.cache.DefaultInMemoryCache;
 import org.apache.cxf.sts.cache.STSCache;
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
+import org.apache.cxf.sts.common.TestUtils;
+import org.apache.cxf.sts.service.EncryptionProperties;
 import org.apache.cxf.sts.service.ServiceMBean;
 import org.apache.cxf.sts.service.StaticService;
 import org.apache.cxf.sts.token.provider.SCTProvider;
@@ -71,6 +73,12 @@ public class IssueSCTUnitTest extends or
     
     private static STSCache cache = new DefaultInMemoryCache();
     
+    private static boolean unrestrictedPoliciesInstalled;
+    
+    static {
+        unrestrictedPoliciesInstalled = TestUtils.checkUnrestrictedPoliciesInstalled();
+    };
+    
     /**
      * Test to successfully issue a SecurityContextToken
      */
@@ -160,6 +168,11 @@ public class IssueSCTUnitTest extends or
         // Add Service
         ServiceMBean service = new StaticService();
         service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
+        EncryptionProperties encryptionProperties = new EncryptionProperties();
+        if (!unrestrictedPoliciesInstalled) {
+            encryptionProperties.setEncryptionAlgorithm(WSConstants.AES_128);
+        }
+        service.setEncryptionProperties(encryptionProperties);
         issueOperation.setServices(Collections.singletonList(service));
         
         // Add STSProperties object

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java?rev=1173560&r1=1173559&r2=1173560&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java
(original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java
Wed Sep 21 10:27:54 2011
@@ -42,6 +42,8 @@ import org.apache.cxf.sts.STSConstants;
 import org.apache.cxf.sts.STSPropertiesMBean;
 import org.apache.cxf.sts.StaticSTSProperties;
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
+import org.apache.cxf.sts.common.TestUtils;
+import org.apache.cxf.sts.service.EncryptionProperties;
 import org.apache.cxf.sts.service.ServiceMBean;
 import org.apache.cxf.sts.service.StaticService;
 import org.apache.cxf.sts.token.provider.SAMLTokenProvider;
@@ -76,6 +78,12 @@ public class IssueSamlUnitTest extends o
         QNameConstants.WS_TRUST_FACTORY.createRequestedAttachedReference(null).getName();
     public static final QName UNATTACHED_REFERENCE = 
         QNameConstants.WS_TRUST_FACTORY.createRequestedUnattachedReference(null).getName();
+        
+    private static boolean unrestrictedPoliciesInstalled;
+        
+    static {
+        unrestrictedPoliciesInstalled = TestUtils.checkUnrestrictedPoliciesInstalled();
+    };
     
     /**
      * Test to successfully issue a Saml 1.1 token.
@@ -237,6 +245,11 @@ public class IssueSamlUnitTest extends o
         // Add Service
         ServiceMBean service = new StaticService();
         service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
+        EncryptionProperties encryptionProperties = new EncryptionProperties();
+        if (!unrestrictedPoliciesInstalled) {
+            encryptionProperties.setEncryptionAlgorithm(WSConstants.AES_128);
+        }
+        service.setEncryptionProperties(encryptionProperties);
         issueOperation.setServices(Collections.singletonList(service));
         
         // Add STSProperties object

Added: cxf/trunk/services/sts/sts-core/src/test/resources/restricted/stsstore.jks
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/resources/restricted/stsstore.jks?rev=1173560&view=auto
==============================================================================
Files cxf/trunk/services/sts/sts-core/src/test/resources/restricted/stsstore.jks (added) and
cxf/trunk/services/sts/sts-core/src/test/resources/restricted/stsstore.jks Wed Sep 21 10:27:54
2011 differ



Mime
View raw message