You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2014/11/25 16:06:18 UTC

svn commit: r1641627 - in /webservices/wss4j/trunk: integration/ integration/src/test/java/org/apache/wss4j/integration/test/common/ integration/src/test/java/org/apache/wss4j/integration/test/kerberos/ parent/ ws-security-common/ ws-security-common/sr...

Author: coheigea
Date: Tue Nov 25 15:06:18 2014
New Revision: 1641627

URL: http://svn.apache.org/r1641627
Log:
Upgrade to Apache DS 2.0.0 + use the annotations based approach to launch the KDC for testing

Removed:
    webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/common/KerberosServiceStarter.java
Modified:
    webservices/wss4j/trunk/integration/pom.xml
    webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
    webservices/wss4j/trunk/parent/pom.xml
    webservices/wss4j/trunk/ws-security-common/pom.xml
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/kerberos/KerberosTokenDecoderImpl.java

Modified: webservices/wss4j/trunk/integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/integration/pom.xml?rev=1641627&r1=1641626&r2=1641627&view=diff
==============================================================================
--- webservices/wss4j/trunk/integration/pom.xml (original)
+++ webservices/wss4j/trunk/integration/pom.xml Tue Nov 25 15:06:18 2014
@@ -76,79 +76,20 @@
         </dependency>
         <dependency>
             <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-kerberos-shared</artifactId>
-            <version>1.5.7</version>
+            <artifactId>apacheds-core-annotations</artifactId>
+            <version>${apacheds.version}</version>
+            <scope>test</scope>
             <exclusions>
                 <exclusion>
                     <groupId>bouncycastle</groupId>
                     <artifactId>bcprov-jdk15</artifactId>
                 </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.server</groupId>
-                    <artifactId>apacheds-i18n</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.server</groupId>
-                    <artifactId>apacheds-core-jndi</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.server</groupId>
-                    <artifactId>apacheds-protocol-shared</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema-loader</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema-manager</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-cursor</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-jndi</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-asn1-codec</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-constants</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-converter</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema-dao</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldif</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-dsml-parser</artifactId>
-                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-core-annotations</artifactId>
-            <version>1.5.7</version>
+            <artifactId>apacheds-core-integ</artifactId>
+            <version>${apacheds.version}</version>
             <scope>test</scope>
             <exclusions>
                 <exclusion>
@@ -160,7 +101,7 @@
         <dependency>
             <groupId>org.apache.directory.server</groupId>
             <artifactId>apacheds-protocol-shared</artifactId>
-            <version>1.5.7</version>
+            <version>${apacheds.version}</version>
             <scope>test</scope>
             <exclusions>
                 <exclusion>
@@ -172,19 +113,23 @@
         <dependency>
             <groupId>org.apache.directory.server</groupId>
             <artifactId>apacheds-protocol-kerberos</artifactId>
-            <version>1.5.7</version>
+            <version>${apacheds.version}</version>
             <scope>test</scope>
             <exclusions>
                 <exclusion>
                     <groupId>bouncycastle</groupId>
                     <artifactId>bcprov-jdk15</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>net.sf.ehcache</groupId>
+                    <artifactId>ehcache-core</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.directory.server</groupId>
             <artifactId>apacheds-interceptor-kerberos</artifactId>
-            <version>1.5.7</version>
+            <version>${apacheds.version}</version>
             <scope>test</scope>
             <exclusions>
                 <exclusion>
@@ -194,6 +139,17 @@
             </exclusions>
         </dependency>
         <dependency>
+            <groupId>org.apache.directory.server</groupId>
+            <artifactId>apacheds-kerberos-codec</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>net.sf.ehcache</groupId>
+                    <artifactId>ehcache-core</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>2.4</version>

Modified: webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java?rev=1641627&r1=1641626&r2=1641627&view=diff
==============================================================================
--- webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java (original)
+++ webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java Tue Nov 25 15:06:18 2014
@@ -18,6 +18,39 @@
  */
 package org.apache.wss4j.integration.test.kerberos;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.crypto.SecretKey;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.xml.crypto.dsig.SignatureMethod;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.directory.server.annotations.CreateKdcServer;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.ApplyLdifFiles;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.annotations.CreateIndex;
+import org.apache.directory.server.core.annotations.CreatePartition;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.kerberos.KeyDerivationInterceptor;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.kerberos.KerberosContextAndServiceNameCallback;
 import org.apache.wss4j.common.spnego.SpnegoTokenContext;
@@ -34,11 +67,12 @@ import org.apache.wss4j.dom.message.toke
 import org.apache.wss4j.dom.message.token.KerberosSecurity;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.apache.wss4j.dom.validate.KerberosTokenValidator;
-import org.apache.wss4j.integration.test.common.KerberosServiceStarter;
 import org.apache.wss4j.stax.WSSec;
-import org.apache.wss4j.stax.ext.*;
+import org.apache.wss4j.stax.ext.InboundWSSec;
+import org.apache.wss4j.stax.ext.OutboundWSSec;
+import org.apache.wss4j.stax.ext.WSSConstants;
+import org.apache.wss4j.stax.ext.WSSSecurityProperties;
 import org.apache.wss4j.stax.securityEvent.KerberosTokenSecurityEvent;
-import org.apache.wss4j.stax.test.AbstractTestBase;
 import org.apache.wss4j.stax.test.utils.SOAPUtil;
 import org.apache.wss4j.stax.test.utils.StAX2DOM;
 import org.apache.wss4j.stax.test.utils.XmlReaderToWriter;
@@ -50,47 +84,68 @@ import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 
-import javax.crypto.SecretKey;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import javax.xml.crypto.dsig.SignatureMethod;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+@RunWith(FrameworkRunner.class)
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.List;
+//Define the DirectoryService
+@CreateDS(name = "KerberosTest-class",
+    enableAccessControl = false,
+    allowAnonAccess = false,
+    enableChangeLog = true,
+    partitions = {
+        @CreatePartition(
+            name = "example",
+            suffix = "dc=example,dc=com",
+            indexes = {
+                @CreateIndex(attribute = "objectClass"),
+                @CreateIndex(attribute = "dc"),
+                @CreateIndex(attribute = "ou")
+            } )
+        },
+    additionalInterceptors = {
+       KeyDerivationInterceptor.class
+    }
+)
 
-public class KerberosTest extends AbstractTestBase {
+@CreateLdapServer(
+    transports = {
+        @CreateTransport(protocol = "LDAP")
+    }
+)
+
+@CreateKdcServer(
+    transports = {
+        @CreateTransport(protocol = "TCP", address = "127.0.0.1", port = 23749),
+        @CreateTransport(protocol = "UDP", address = "127.0.0.1", port = 23749)
+    },
+    primaryRealm = "service.ws.apache.org",
+    kdcPrincipal = "krbtgt/service.ws.apache.org@service.ws.apache.org"
+)
+
+//Inject an file containing entries
+@ApplyLdifFiles("kerberos/kerberos.ldif")
+
+public class KerberosTest extends AbstractLdapTestUnit {
     
     private static final org.slf4j.Logger LOG = 
         org.slf4j.LoggerFactory.getLogger(KerberosTest.class);
-
-    private static boolean kerberosServerStarted = false;
-
+    
+    private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
+    private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+    private static DocumentBuilderFactory dbf;
+    
     @BeforeClass
     public static void setUp() throws Exception {
 
         WSSConfig.init();
-
+        
         //
         // This test fails with the IBM JDK
         //
         if (!"IBM Corporation".equals(System.getProperty("java.vendor"))) {
-            kerberosServerStarted = KerberosServiceStarter.startKerberosServer();
-
             String basedir = System.getProperty("basedir");
             if (basedir == null) {
                 basedir = new File(".").getCanonicalPath();
@@ -102,13 +157,19 @@ public class KerberosTest extends Abstra
             System.setProperty("java.security.auth.login.config", basedir + "/integration/src/test/resources/kerberos/kerberos.jaas");
             System.setProperty("java.security.krb5.conf", basedir + "/integration/src/test/resources/kerberos/krb5.conf");
         }
+        
+        dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        dbf.setIgnoringComments(false);
+        dbf.setCoalescing(false);
+        dbf.setIgnoringElementContentWhitespace(false);
+        
+        xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, false);
+        xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
     }
 
     @AfterClass
     public static void tearDown() throws Exception {
-        if (kerberosServerStarted) {
-            KerberosServiceStarter.stopKerberosServer();
-        }
         SecurityTestUtil.cleanup();
     }
     
@@ -122,13 +183,12 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testKerberosCreationAndProcessing() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
+        
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         
@@ -180,11 +240,10 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testSpnego() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -217,11 +276,10 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testKerberosClient() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
 
         CallbackHandler callbackHandler = new CallbackHandler() {
@@ -261,11 +319,10 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testKerberosSignature() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -335,11 +392,10 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testKerberosSignatureKI() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -413,11 +469,10 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testKerberosEncryption() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -485,11 +540,10 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testKerberosEncryptionBSTFirst() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -558,11 +612,10 @@ public class KerberosTest extends Abstra
      */
     @Test
     public void testKerberosEncryptionKI() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -630,14 +683,12 @@ public class KerberosTest extends Abstra
     //
     // Streaming tests
     //
-
     @Test
     public void testKerberosSignatureOutbound() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document document;
         {
             WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -669,7 +720,7 @@ public class KerberosTest extends Abstra
             XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
             xmlStreamWriter.close();
 
-            document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
+            document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
             NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
             Assert.assertEquals(nodeList.getLength(), 1);
         }
@@ -713,11 +764,10 @@ public class KerberosTest extends Abstra
 
     @Test
     public void testKerberosSignatureInbound() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         {
             Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
@@ -789,7 +839,7 @@ public class KerberosTest extends Abstra
             XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(
                     new ByteArrayInputStream(baos.toByteArray())), null, securityEventListener);
 
-            Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+            Document document = StAX2DOM.readDoc(dbf.newDocumentBuilder(), xmlStreamReader);
 
             //header element must still be there
             NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
@@ -806,11 +856,10 @@ public class KerberosTest extends Abstra
 
     @Test
     public void testKerberosSignatureKIInbound() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         {
             Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
@@ -886,7 +935,7 @@ public class KerberosTest extends Abstra
             XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(
                     new ByteArrayInputStream(baos.toByteArray())), null, securityEventListener);
 
-            Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+            Document document = StAX2DOM.readDoc(dbf.newDocumentBuilder(), xmlStreamReader);
 
             //header element must still be there
             NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
@@ -899,11 +948,10 @@ public class KerberosTest extends Abstra
 
     @Test
     public void testKerberosEncryptionOutbound() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         Document document;
         {
             WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -936,7 +984,7 @@ public class KerberosTest extends Abstra
             XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
             xmlStreamWriter.close();
 
-            document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
+            document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
             NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_ReferenceList.getNamespaceURI(), WSSConstants.TAG_xenc_ReferenceList.getLocalPart());
             Assert.assertEquals(1, nodeList.getLength());
         }
@@ -979,11 +1027,10 @@ public class KerberosTest extends Abstra
 
     @Test
     public void testKerberosEncryptionInbound() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         {
             Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
@@ -1053,7 +1100,7 @@ public class KerberosTest extends Abstra
             XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(
                     new ByteArrayInputStream(baos.toByteArray())), null, securityEventListener);
 
-            Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+            Document document = StAX2DOM.readDoc(dbf.newDocumentBuilder(), xmlStreamReader);
 
             //header element must still be there
             NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_wsse_BinarySecurityToken.getNamespaceURI(), WSSConstants.TAG_wsse_BinarySecurityToken.getLocalPart());
@@ -1070,11 +1117,10 @@ public class KerberosTest extends Abstra
 
     @Test
     public void testKerberosEncryptionKIInbound() throws Exception {
-        if (!kerberosServerStarted) {
-            System.out.println("Skipping test because kerberos server could not be started");
+        if (!isServiceUp()) {
             return;
         }
-
+        
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         {
             Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
@@ -1149,7 +1195,7 @@ public class KerberosTest extends Abstra
             XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(
                     new ByteArrayInputStream(baos.toByteArray())), null, securityEventListener);
 
-            Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+            Document document = StAX2DOM.readDoc(dbf.newDocumentBuilder(), xmlStreamReader);
 
             //header element must still be there
             NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_wsse_BinarySecurityToken.getNamespaceURI(), WSSConstants.TAG_wsse_BinarySecurityToken.getLocalPart());
@@ -1163,4 +1209,13 @@ public class KerberosTest extends Abstra
             Assert.assertEquals(kerberosTokenSecurityEvents.size(), 1);
         }
     }
+    
+    private boolean isServiceUp() {
+        if (super.getKdcServer().isEnabled() && super.getKdcServer().isStarted()) {
+            return true;
+        }
+        
+        return false;
+    }
+    
 }

Modified: webservices/wss4j/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/parent/pom.xml?rev=1641627&r1=1641626&r2=1641627&view=diff
==============================================================================
--- webservices/wss4j/trunk/parent/pom.xml (original)
+++ webservices/wss4j/trunk/parent/pom.xml Tue Nov 25 15:06:18 2014
@@ -34,7 +34,7 @@
     <url>http://ws.apache.org/wss4j/</url>
 
     <properties>
-        <apacheds.version>1.5.7</apacheds.version>
+        <apacheds.version>2.0.0-M19</apacheds.version>
         <bcprov.version>1.51</bcprov.version>
         <commons.compress.version>1.4.1</commons.compress.version>
         <ehcache.version>2.8.5</ehcache.version>
@@ -155,7 +155,7 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.directory.server</groupId>
-                <artifactId>apacheds-kerberos-shared</artifactId>
+                <artifactId>apacheds-kerberos-codec</artifactId>
                 <version>${apacheds.version}</version>
             </dependency>
             <dependency>

Modified: webservices/wss4j/trunk/ws-security-common/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/pom.xml?rev=1641627&r1=1641626&r2=1641627&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/pom.xml (original)
+++ webservices/wss4j/trunk/ws-security-common/pom.xml Tue Nov 25 15:06:18 2014
@@ -199,68 +199,12 @@
         </dependency>
         <dependency>
             <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-kerberos-shared</artifactId>
+            <artifactId>apacheds-kerberos-codec</artifactId>
             <optional>true</optional>
             <exclusions>
                 <exclusion>
-                    <groupId>bouncycastle</groupId>
-                    <artifactId>bcprov-jdk15</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.server</groupId>
-                    <artifactId>apacheds-core-jndi</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.server</groupId>
-                    <artifactId>apacheds-protocol-shared</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema-loader</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema-manager</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-cursor</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-jndi</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-asn1-codec</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-constants</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-converter</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema-dao</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldif</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-dsml-parser</artifactId>
+                    <groupId>net.sf.ehcache</groupId>
+                    <artifactId>ehcache-core</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/kerberos/KerberosTokenDecoderImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/kerberos/KerberosTokenDecoderImpl.java?rev=1641627&r1=1641626&r2=1641627&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/kerberos/KerberosTokenDecoderImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/kerberos/KerberosTokenDecoderImpl.java Tue Nov 25 15:06:18 2014
@@ -19,17 +19,18 @@
 
 package org.apache.wss4j.common.kerberos;
 
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.components.EncTicketPart;
+import org.apache.directory.shared.kerberos.components.EncryptionKey;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.apache.directory.server.kerberos.protocol.codec.KerberosDecoder;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
-import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KeyUsage;
-import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
-import org.apache.directory.server.kerberos.shared.io.decoder.ApplicationRequestDecoder;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
-import org.apache.directory.server.kerberos.shared.messages.components.EncTicketPart;
-import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 
 import javax.security.auth.Subject;
 import javax.security.auth.kerberos.KerberosKey;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -84,8 +85,8 @@ public class KerberosTokenDecoderImpl im
         if (!decoded) {
             decodeServiceTicket();
         }
-        if (encTicketPart != null && encTicketPart.getSessionKey() != null) {
-            return encTicketPart.getSessionKey().getKeyValue();
+        if (encTicketPart != null && encTicketPart.getKey() != null) {
+            return encTicketPart.getKey().getKeyValue();
         }
         return null;
     }
@@ -99,7 +100,7 @@ public class KerberosTokenDecoderImpl im
         if (!decoded) {
             decodeServiceTicket();
         }
-        return encTicketPart.getClientPrincipal().toString();
+        return encTicketPart.getCName().toString();
     }
 
     // Decode the service ticket.
@@ -137,18 +138,21 @@ public class KerberosTokenDecoderImpl im
                 throw new KerberosTokenDecoderException("invalid kerberos token");
             }
 
-            ApplicationRequestDecoder applicationRequestDecoder = new ApplicationRequestDecoder();
-            ApplicationRequest applicationRequest = applicationRequestDecoder.decode(toByteArray(asn1InputStream));
+            ApReq applicationRequest = 
+                KerberosDecoder.decodeApReq(toByteArray(asn1InputStream));
 
-            final int encryptionType = applicationRequest.getTicket().getEncPart().getEType().getOrdinal();
+            final int encryptionType = applicationRequest.getTicket().getEncPart().getEType().getValue();
             KerberosKey kerberosKey = getKrbKey(subject, encryptionType);
 
             EncryptionKey encryptionKey =
-                    new EncryptionKey(EncryptionType.getTypeByOrdinal(encryptionType), kerberosKey.getEncoded());
+                    new EncryptionKey(EncryptionType.getTypeByValue(encryptionType), kerberosKey.getEncoded());
 
             CipherTextHandler cipherTextHandler = new CipherTextHandler();
-            this.encTicketPart = (EncTicketPart) cipherTextHandler.unseal(
-                    EncTicketPart.class, encryptionKey, applicationRequest.getTicket().getEncPart(), KeyUsage.NUMBER2);
+            byte[] dec = cipherTextHandler.decrypt(
+                         encryptionKey, applicationRequest.getTicket().getEncPart(), 
+                                                      KeyUsage.getTypeByOrdinal(2));
+            
+            this.encTicketPart = KerberosDecoder.decodeEncTicketPart(dec);
         } catch (KerberosException e) {
             throw new KerberosTokenDecoderException(e);
         } catch (IOException e) {