cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1329945 [3/4] - in /cxf/sandbox/fediz: fediz-core/.settings/ fediz-core/src/main/java/org/apache/cxf/fediz/core/ fediz-core/src/main/java/org/apache/cxf/fediz/core/config/ fediz-core/src/main/java/org/apache/cxf/fediz/core/exception/ fediz...
Date Tue, 24 Apr 2012 19:03:41 GMT
Modified: cxf/sandbox/fediz/fediz-core/src/main/java/org/apache/cxf/fediz/core/util/XMLUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-core/src/main/java/org/apache/cxf/fediz/core/util/XMLUtils.java?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-core/src/main/java/org/apache/cxf/fediz/core/util/XMLUtils.java (original)
+++ cxf/sandbox/fediz/fediz-core/src/main/java/org/apache/cxf/fediz/core/util/XMLUtils.java Tue Apr 24 19:03:39 2012
@@ -67,13 +67,13 @@ import org.xml.sax.SAXException;
 @SuppressWarnings("PMD")
 public final class XMLUtils {
 
-    //private static final Logger LOG = LogUtils.getL7dLogger(XMLUtils.class);
-    
-    private static final Map<ClassLoader, DocumentBuilderFactory> DOCUMENT_BUILDER_FACTORIES
-        = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilderFactory>());
-    
-    private static final Map<ClassLoader, TransformerFactory> TRANSFORMER_FACTORIES
-        = Collections.synchronizedMap(new WeakHashMap<ClassLoader, TransformerFactory>());
+    // private static final Logger LOG = LogUtils.getL7dLogger(XMLUtils.class);
+
+    private static final Map<ClassLoader, DocumentBuilderFactory> DOCUMENT_BUILDER_FACTORIES = Collections
+            .synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilderFactory>());
+
+    private static final Map<ClassLoader, TransformerFactory> TRANSFORMER_FACTORIES = Collections
+            .synchronizedMap(new WeakHashMap<ClassLoader, TransformerFactory>());
 
     private XMLUtils() {
     }
@@ -93,6 +93,7 @@ public final class XMLUtils {
         }
         return factory;
     }
+
     private static DocumentBuilderFactory getDocumentBuilderFactory() {
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         if (loader == null) {
@@ -109,47 +110,54 @@ public final class XMLUtils {
         }
         return factory;
     }
-    public static Transformer newTransformer() throws TransformerConfigurationException {
+
+    public static Transformer newTransformer()
+            throws TransformerConfigurationException {
         return getTransformerFactory().newTransformer();
     }
-    public static Transformer newTransformer(int indent) throws TransformerConfigurationException {
+
+    public static Transformer newTransformer(int indent)
+            throws TransformerConfigurationException {
         if (indent > 0) {
             TransformerFactory f = TransformerFactory.newInstance();
             try {
-                //sun way of setting indent
+                // sun way of setting indent
                 f.setAttribute("indent-number", Integer.toString(indent));
             } catch (Throwable t) {
-                //ignore
+                // ignore
             }
             return f.newTransformer();
         }
         return getTransformerFactory().newTransformer();
     }
 
-    public static DocumentBuilder getParser() throws ParserConfigurationException {
+    public static DocumentBuilder getParser()
+            throws ParserConfigurationException {
         return getDocumentBuilderFactory().newDocumentBuilder();
     }
 
-    public static Document parse(InputSource is) throws ParserConfigurationException, SAXException,
-        IOException {
+    public static Document parse(InputSource is)
+            throws ParserConfigurationException, SAXException, IOException {
         return getParser().parse(is);
     }
 
-    public static Document parse(File is) throws ParserConfigurationException, SAXException,
-        IOException {
+    public static Document parse(File is) throws ParserConfigurationException,
+            SAXException, IOException {
         return getParser().parse(is);
     }
 
-    public static Document parse(InputStream in) throws ParserConfigurationException, SAXException,
-        IOException {
+    public static Document parse(InputStream in)
+            throws ParserConfigurationException, SAXException, IOException {
         return getParser().parse(in);
     }
 
-    public static Document parse(String in) throws ParserConfigurationException, SAXException, IOException {
+    public static Document parse(String in)
+            throws ParserConfigurationException, SAXException, IOException {
         return parse(in.getBytes());
     }
 
-    public static Document parse(byte[] in) throws ParserConfigurationException, SAXException, IOException {
+    public static Document parse(byte[] in)
+            throws ParserConfigurationException, SAXException, IOException {
         if (in == null) {
             return null;
         }
@@ -163,62 +171,68 @@ public final class XMLUtils {
     public static void writeTo(Node node, OutputStream os) {
         writeTo(new DOMSource(node), os);
     }
+
     public static void writeTo(Node node, OutputStream os, int indent) {
         writeTo(new DOMSource(node), os, indent);
     }
+
     public static void writeTo(Source src, OutputStream os) {
         writeTo(src, os, -1);
     }
+
     public static void writeTo(Node node, Writer os) {
         writeTo(new DOMSource(node), os);
     }
+
     public static void writeTo(Node node, Writer os, int indent) {
         writeTo(new DOMSource(node), os, indent);
     }
+
     public static void writeTo(Source src, Writer os) {
         writeTo(src, os, -1);
     }
+
     public static void writeTo(Source src, OutputStream os, int indent) {
         String enc = null;
         if (src instanceof DOMSource
-            && ((DOMSource)src).getNode() instanceof Document) {
+                && ((DOMSource) src).getNode() instanceof Document) {
             try {
-                enc = ((Document)((DOMSource)src).getNode()).getXmlEncoding();
+                enc = ((Document) ((DOMSource) src).getNode()).getXmlEncoding();
             } catch (Exception ex) {
-                //ignore - not DOM level 3
+                // ignore - not DOM level 3
             }
         }
         writeTo(src, os, indent, enc, "no");
     }
+
     public static void writeTo(Source src, Writer os, int indent) {
         String enc = null;
         if (src instanceof DOMSource
-            && ((DOMSource)src).getNode() instanceof Document) {
+                && ((DOMSource) src).getNode() instanceof Document) {
             try {
-                enc = ((Document)((DOMSource)src).getNode()).getXmlEncoding();
+                enc = ((Document) ((DOMSource) src).getNode()).getXmlEncoding();
             } catch (Exception ex) {
-                //ignore - not DOM level 3
+                // ignore - not DOM level 3
             }
         }
         writeTo(src, os, indent, enc, "no");
     }
-    public static void writeTo(Source src,
-                               OutputStream os,
-                               int indent,
-                               String charset,
-                               String omitXmlDecl) {
+
+    public static void writeTo(Source src, OutputStream os, int indent,
+            String charset, String omitXmlDecl) {
         Transformer it;
         try {
             if (StringUtils.isEmpty(charset)) {
-                charset = "utf-8"; 
+                charset = "utf-8";
             }
 
             it = newTransformer(indent);
             it.setOutputProperty(OutputKeys.METHOD, "xml");
             if (indent > -1) {
                 it.setOutputProperty(OutputKeys.INDENT, "yes");
-                it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
-                                     Integer.toString(indent));
+                it.setOutputProperty(
+                        "{http://xml.apache.org/xslt}indent-amount",
+                        Integer.toString(indent));
             }
             it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
             it.setOutputProperty(OutputKeys.ENCODING, charset);
@@ -227,23 +241,22 @@ public final class XMLUtils {
             throw new RuntimeException("Failed to configure TRaX", e);
         }
     }
-    public static void writeTo(Source src,
-                               Writer os,
-                               int indent,
-                               String charset,
-                               String omitXmlDecl) {
+
+    public static void writeTo(Source src, Writer os, int indent,
+            String charset, String omitXmlDecl) {
         Transformer it;
         try {
             if (StringUtils.isEmpty(charset)) {
-                charset = "utf-8"; 
+                charset = "utf-8";
             }
 
             it = newTransformer(indent);
             it.setOutputProperty(OutputKeys.METHOD, "xml");
             if (indent > -1) {
                 it.setOutputProperty(OutputKeys.INDENT, "yes");
-                it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
-                                     Integer.toString(indent));
+                it.setOutputProperty(
+                        "{http://xml.apache.org/xslt}indent-amount",
+                        Integer.toString(indent));
             }
             it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
             it.setOutputProperty(OutputKeys.ENCODING, charset);
@@ -252,11 +265,14 @@ public final class XMLUtils {
             throw new RuntimeException("Failed to configure TRaX", e);
         }
     }
-    public static String toString(Source source) throws TransformerException, IOException {
+
+    public static String toString(Source source) throws TransformerException,
+            IOException {
         return toString(source, null);
     }
 
-    public static String toString(Source source, Properties props) throws TransformerException, IOException {
+    public static String toString(Source source, Properties props)
+            throws TransformerException, IOException {
         StringWriter bos = new StringWriter();
         StreamResult sr = new StreamResult(bos);
         Transformer trans = newTransformer();
@@ -275,6 +291,7 @@ public final class XMLUtils {
         writeTo(node, out, indent);
         return out.toString();
     }
+
     public static String toString(Node node) {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         writeTo(node, out);
@@ -294,7 +311,8 @@ public final class XMLUtils {
         return el.getAttributeNode(attrName);
     }
 
-    public static void replaceAttribute(Element element, String attr, String value) {
+    public static void replaceAttribute(Element element, String attr,
+            String value) {
         if (element.hasAttribute(attr)) {
             element.removeAttribute(attr);
         }
@@ -316,12 +334,13 @@ public final class XMLUtils {
         NamedNodeMap attributes = element.getAttributes();
         for (int i = 0; i < attributes.getLength(); i++) {
             Node node = attributes.item(i);
-            System.err.println("## prefix=" + node.getPrefix() + " localname:" + node.getLocalName()
-                               + " value=" + node.getNodeValue());
+            System.err.println("## prefix=" + node.getPrefix() + " localname:"
+                    + node.getLocalName() + " value=" + node.getNodeValue());
         }
     }
 
-    public static QName getNamespace(Map<String, String> namespaces, String str, String defaultNamespace) {
+    public static QName getNamespace(Map<String, String> namespaces,
+            String str, String defaultNamespace) {
         String prefix = null;
         String localName = null;
 
@@ -335,7 +354,7 @@ public final class XMLUtils {
 
         String namespceURI = defaultNamespace;
         if (prefix != null) {
-            namespceURI = (String)namespaces.get(prefix);
+            namespceURI = (String) namespaces.get(prefix);
         }
         return new QName(namespceURI, localName);
     }
@@ -346,7 +365,8 @@ public final class XMLUtils {
 
             it.setOutputProperty(OutputKeys.METHOD, "xml");
             it.setOutputProperty(OutputKeys.INDENT, "yes");
-            it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+            it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
+                    "2");
             it.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
             it.transform(new DOMSource(element), new StreamResult(writer));
         } catch (Exception e) {
@@ -355,14 +375,17 @@ public final class XMLUtils {
     }
 
     public static Element createElementNS(Node node, QName name) {
-        return createElementNS(node.getOwnerDocument(), name.getNamespaceURI(), name.getLocalPart());
+        return createElementNS(node.getOwnerDocument(), name.getNamespaceURI(),
+                name.getLocalPart());
     }
 
     public static Element createElementNS(Document root, QName name) {
-        return createElementNS(root, name.getNamespaceURI(), name.getLocalPart());
+        return createElementNS(root, name.getNamespaceURI(),
+                name.getLocalPart());
     }
 
-    public static Element createElementNS(Document root, String namespaceURI, String qualifiedName) {
+    public static Element createElementNS(Document root, String namespaceURI,
+            String qualifiedName) {
         return root.createElementNS(namespaceURI, qualifiedName);
     }
 
@@ -374,7 +397,7 @@ public final class XMLUtils {
         return createTextNode(node.getOwnerDocument(), data);
     }
 
-    public static void removeContents(Node parent) {     
+    public static void removeContents(Node parent) {
         Node node = parent.getFirstChild();
         while (node != null) {
             parent.removeChild(node);
@@ -388,15 +411,17 @@ public final class XMLUtils {
         // Try to get the DOMImplementation from doc first before
         // defaulting to the sun implementation.
         if (docImpl != null && docImpl.hasFeature("LS", "3.0")) {
-            impl = (DOMImplementationLS)docImpl.getFeature("LS", "3.0");
+            impl = (DOMImplementationLS) docImpl.getFeature("LS", "3.0");
         } else {
-            DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
-            impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
+            DOMImplementationRegistry registry = DOMImplementationRegistry
+                    .newInstance();
+            impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
             if (impl == null) {
                 System.setProperty(DOMImplementationRegistry.PROPERTY,
-                                   "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+                        "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
                 registry = DOMImplementationRegistry.newInstance();
-                impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
+                impl = (DOMImplementationLS) registry
+                        .getDOMImplementation("LS");
             }
         }
         LSOutput output = impl.createLSOutput();
@@ -408,9 +433,11 @@ public final class XMLUtils {
         return new ByteArrayInputStream(buf);
     }
 
-    public static Element fetchElementByNameAttribute(Element parent, String targetName, String nameValue) {
-        
-        List<Element> elemList = DOMUtils.findAllElementsByTagName(parent, targetName);
+    public static Element fetchElementByNameAttribute(Element parent,
+            String targetName, String nameValue) {
+
+        List<Element> elemList = DOMUtils.findAllElementsByTagName(parent,
+                targetName);
         for (Element elem : elemList) {
             if (elem.getAttribute("name").equals(nameValue)) {
                 return elem;
@@ -441,24 +468,24 @@ public final class XMLUtils {
         return new QName(ns, localName, prefix);
     }
 
-    public static Node  fromSource(Source src) throws Exception {
+    public static Node fromSource(Source src) throws Exception {
 
         Transformer trans = TransformerFactory.newInstance().newTransformer();
         DOMResult res = new DOMResult();
         trans.transform(src, res);
         return res.getNode();
     }
-    
+
     public static QName convertStringToQName(String expandedQName) {
         return convertStringToQName(expandedQName, "");
     }
-    
+
     public static QName convertStringToQName(String expandedQName, String prefix) {
         int ind1 = expandedQName.indexOf('{');
         if (ind1 != 0) {
             return new QName(expandedQName);
         }
-        
+
         int ind2 = expandedQName.indexOf('}');
         if (ind2 <= ind1 + 1 || ind2 >= expandedQName.length() - 1) {
             return null;
@@ -467,7 +494,7 @@ public final class XMLUtils {
         String localName = expandedQName.substring(ind2 + 1);
         return new QName(ns, localName, prefix);
     }
-    
+
     public static Set<QName> convertStringsToQNames(List<String> expandedQNames) {
         Set<QName> dropElements = Collections.emptySet();
         if (expandedQNames != null) {
@@ -478,5 +505,5 @@ public final class XMLUtils {
         }
         return dropElements;
     }
-    
+
 }

Added: cxf/sandbox/fediz/fediz-core/src/main/resources/configFile.xsd
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-core/src/main/resources/configFile.xsd?rev=1329945&view=auto
==============================================================================
--- cxf/sandbox/fediz/fediz-core/src/main/resources/configFile.xsd (added)
+++ cxf/sandbox/fediz/fediz-core/src/main/resources/configFile.xsd Tue Apr 24 19:03:39 2012
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <xsd:element name="authType" type="xsd:string"/>
+  <xsd:element name="detectReplayedTokens" type="xsd:boolean"/>
+  <xsd:element name="requiresWoParameter" type="xsd:boolean"/>
+  <xsd:element name="trustStorePassword" type="xsd:string"/>
+  <xsd:element name="trustStoreFile"  type="xsd:string"/>
+  <xsd:element name="freshness" type="xsd:string"/>
+  <xsd:element name="roleClaimUri" type="xsd:string"/>
+  <xsd:element name="targetIdpServerUrl" type="xsd:string"/>
+  <xsd:element name="webAppConfig">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="targetIdpServerUrl"/>
+        <xsd:element ref="authType"/>
+        <xsd:element ref="federationProcessorConfig"/>
+        <xsd:element ref="idpRoleToGroupMapper"/>
+      </xsd:sequence>
+      <xsd:attribute name="contextPath" type="xsd:string"/>
+      <xsd:attribute name="name" type="xsd:string"/>
+    </xsd:complexType>
+  </xsd:element>
+  <xsd:element name="realm" type="xsd:string"/>
+  <xsd:element name="trustedIssuer" type="xsd:string"/>
+  <xsd:element name="federationProcessorConfig">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="realm"/>
+        <xsd:element ref="trustedIssuer"/>
+        <xsd:element ref="roleClaimUri"/>
+        <xsd:element ref="roleDelimiter"/>
+        <xsd:element ref="addDefaultRole"/>
+        <xsd:element ref="defaultRole"/>
+        <xsd:element ref="detectExpiredTokens"/>
+        <xsd:element ref="detectReplayedTokens"/>
+        <xsd:element ref="freshness"/>
+        <xsd:element ref="maxClockSkew"/>
+        <xsd:element ref="TokenReplayCacheExpirationTime"/>
+        <xsd:element ref="trustStoreFile"/>
+        <xsd:element ref="trustStorePassword"/>
+        <xsd:element ref="tokenValidators"/>
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+  <xsd:element name="roleDelimiter" type="xsd:string"/>
+  <xsd:element name="validator">
+    <xsd:complexType>
+      <xsd:attribute name="className" type="xsd:string"/>
+    </xsd:complexType>
+  </xsd:element>
+  <xsd:element name="maxClockSkew" type="xsd:int"/>
+  <xsd:element name="property">
+    <xsd:complexType>
+      <xsd:attribute name="value" type="xsd:string"/>
+      <xsd:attribute name="name" type="xsd:string"/>
+    </xsd:complexType>
+  </xsd:element>
+  <xsd:element name="addDefaultRole" type="xsd:boolean"/>
+  <xsd:element name="defaultRole" type="xsd:string"/>
+  <xsd:element name="idpRoleToGroupMapper">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element maxOccurs="unbounded" ref="property"/>
+      </xsd:sequence>
+      <xsd:attribute name="classname" type="xsd:string"/>
+    </xsd:complexType>
+  </xsd:element>
+  <xsd:element name="tokenValidators">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element maxOccurs="unbounded" ref="validator"/>
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+  <xsd:element name="TokenRequestorConfig">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element maxOccurs="unbounded" ref="webAppConfig"/>
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+  <xsd:element name="detectExpiredTokens" type="xsd:boolean"/>
+  <xsd:element name="TokenReplayCacheExpirationTime" type="xsd:long"/>
+</xsd:schema>
\ No newline at end of file

Modified: cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/FederationProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/FederationProcessorTest.java?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/FederationProcessorTest.java (original)
+++ cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/FederationProcessorTest.java Tue Apr 24 19:03:39 2012
@@ -18,32 +18,25 @@
 package org.apache.cxf.fediz.core;
 
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-
-import org.apache.cxf.fediz.core.FederationConfiguration;
-import org.apache.cxf.fediz.core.FederationConstants;
-import org.apache.cxf.fediz.core.FederationProcessor;
-import org.apache.cxf.fediz.core.FederationProcessorImpl;
-import org.apache.cxf.fediz.core.FederationRequest;
-import org.apache.cxf.fediz.core.FederationResponse;
-import org.junit.BeforeClass;
+import java.net.URL;
 
 import junit.framework.Assert;
 
-import static org.apache.cxf.fediz.core.FederationConstants.DEFAULT_ROLE_URI;
+import org.apache.cxf.fediz.core.config.FederationConfigurator;
+import org.apache.cxf.fediz.core.config.FederationContext;
+import org.junit.BeforeClass;
 
 public class FederationProcessorTest {
-
-    private static final String TEST_OTHER_ISSUER = "ZFS IDP DEV";
     private static final String TEST_USER = "alice";
-    private static final String TEST_TRUSTSTORE_FILE = "stsstore.jks";
-    private static final String TEST_TRUSTSTORE_PASSWORD = "stsspass";
     private static final String TEST_RSTR_ISSUER = "DoubleItSTSIssuer";
-    private static final String TEST_CERT_CONSTRAINT = ".*CN=www.sts.com.*";
 
+    private static final String CONFIG_FILE = "fediz_test_config.xml";
+    private static final String CONFIG_FILE_WRONG_ISSUER = "fediz_test_config2.xml";
 
     private static String sRSTR = null;
 
@@ -51,11 +44,13 @@ public class FederationProcessorTest {
     public static void readWResult() {
         InputStream is = null;
         try {
-            is = FederationProcessorTest.class.getResourceAsStream("/RSTR.xml");
+            is = FederationProcessorTest.class
+                    .getResourceAsStream("/RSTR.xml");
             if (is == null) {
                 throw new FileNotFoundException("Failed to get RSTR.xml");
             }
-            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
+            BufferedReader bufferedReader = new BufferedReader(
+                    new InputStreamReader(is));
             StringBuilder stringBuilder = new StringBuilder();
             String line = null;
             while ((line = bufferedReader.readLine()) != null) {
@@ -75,6 +70,36 @@ public class FederationProcessorTest {
             }
         }
         Assert.assertNotNull("RSTR resource null", sRSTR);
+        Assert.assertNotNull(loadRootConfig());
+
+    }
+
+    private static FederationContext loadRootConfig() {
+        try {
+            FederationConfigurator configurator = new FederationConfigurator();
+            final URL resource = Thread.currentThread().getContextClassLoader()
+                    .getResource(CONFIG_FILE);
+            File f = new File(resource.toURI());
+            configurator.loadConfig(f);
+            return configurator.getFederationContext("ROOT");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    private static FederationContext loadOtherIssuerRootConfig() {
+        try {
+            FederationConfigurator configurator = new FederationConfigurator();
+            final URL resource = Thread.currentThread().getContextClassLoader()
+                    .getResource(CONFIG_FILE_WRONG_ISSUER);
+            File f = new File(resource.toURI());
+            configurator.loadConfig(f);
+            return configurator.getFederationContext("ROOT");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
 
     }
 
@@ -84,44 +109,31 @@ public class FederationProcessorTest {
         FederationRequest wfReq = new FederationRequest();
         wfReq.setWa(FederationConstants.ACTION_SIGNIN);
         wfReq.setWresult(sRSTR);
-
-        FederationConfiguration config = new FederationConfiguration();
-        config.setTrustedIssuer(TEST_CERT_CONSTRAINT);
-        config.setRoleDelimiter(";");
-        config.setRoleURI(FederationConstants.DEFAULT_ROLE_URI);
-        config.setTrustStoreFile(TEST_TRUSTSTORE_FILE);
-        config.setTrustStorePassword(TEST_TRUSTSTORE_PASSWORD);
+        FederationContext config = loadRootConfig();
         config.setDetectReplayedTokens(false);
 
         FederationProcessor wfProc = new FederationProcessorImpl();
         FederationResponse wfRes = wfProc.processRequest(wfReq, config);
-        Assert.assertEquals("Principal name wrong", TEST_USER, wfRes.getUsername());
+        Assert.assertEquals("Principal name wrong", TEST_USER,
+                wfRes.getUsername());
         Assert.assertEquals("Issuer wrong", TEST_RSTR_ISSUER, wfRes.getIssuer());
     }
 
-
     @org.junit.Test
     public void validateSAML2TokenWithWrongIssuer() {
 
         FederationRequest wfReq = new FederationRequest();
         wfReq.setWa(FederationConstants.ACTION_SIGNIN);
         wfReq.setWresult(sRSTR);
-
-        FederationConfiguration config = new FederationConfiguration();
-        config.setTrustedIssuer(TEST_OTHER_ISSUER);
-        config.setRoleDelimiter(";");
-        config.setRoleURI(FederationConstants.DEFAULT_ROLE_URI);
-        config.setTrustStoreFile(TEST_TRUSTSTORE_FILE);
-        config.setTrustStorePassword(TEST_TRUSTSTORE_PASSWORD);
+        FederationContext config = loadOtherIssuerRootConfig();
         config.setDetectReplayedTokens(false);
-
         FederationProcessor wfProc = new FederationProcessorImpl();
         try {
             wfProc.processRequest(wfReq, config);
             Assert.fail("Processing must fail because of wrong issuer configured");
-        }
-        catch (RuntimeException ex) {
-            Assert.assertEquals("Exception expected", "Issuer '" + TEST_RSTR_ISSUER + "' not trusted", ex.getMessage());
+        } catch (RuntimeException ex) {
+            Assert.assertEquals("Exception expected", "Issuer '"
+                    + TEST_RSTR_ISSUER + "' not trusted", ex.getMessage());
         }
     }
 
@@ -132,21 +144,16 @@ public class FederationProcessorTest {
         wfReq.setWa(FederationConstants.ACTION_SIGNIN);
         wfReq.setWresult(sRSTR);
 
-        FederationConfiguration config = new FederationConfiguration();
-        config.setTrustedIssuer(TEST_CERT_CONSTRAINT);
-        config.setRoleDelimiter(";");
-        config.setRoleURI(DEFAULT_ROLE_URI);
-        config.setTrustStoreFile(TEST_TRUSTSTORE_FILE);
-        config.setTrustStorePassword(TEST_TRUSTSTORE_PASSWORD);
+        FederationContext config = loadRootConfig();
         config.setDetectReplayedTokens(false);
 
         FederationProcessor wfProc = new FederationProcessorImpl();
         FederationResponse wfRes = wfProc.processRequest(wfReq, config);
-        Assert.assertEquals("Principal name wrong", TEST_USER, wfRes.getUsername());
+        Assert.assertEquals("Principal name wrong", TEST_USER,
+                wfRes.getUsername());
         Assert.assertEquals("Issuer wrong", TEST_RSTR_ISSUER, wfRes.getIssuer());
-        Assert.assertEquals("One role must be found", 1, wfRes.getRoles().size());
+        Assert.assertEquals("One role must be found", 1, wfRes.getRoles()
+                .size());
     }
 
-
-
 }

Added: cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java?rev=1329945&view=auto
==============================================================================
--- cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java (added)
+++ cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java Tue Apr 24 19:03:39 2012
@@ -0,0 +1,224 @@
+package org.apache.cxf.fediz.core.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.math.BigInteger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.junit.Assert;
+
+public class FedizConfigurationTest {
+
+    private static final String ISSUER = "http://url_to_the_issuer";
+    private static final String PROTOCOL_VERSION = "1.0.0";
+    private static final String REQUEST = "request value";
+    private static final String REPLY = "reply value";
+    private static final String TARGET_REALM = "target realm";
+    private static final String HOME_REALM_CLASS = "org.apache.fediz.realm.MyHomeRealm.class";
+    private static final String FRESHNESS_VALUE = "10000";
+
+    private static final String CONFIG_NAME = "ROOT";
+    private static final String CLOCK_SKEW = "1000";
+    private static final String KEYSTORE_FILE = "/path/keystore.jks";
+    private static final String FACTORY_ALGORITHM_1 = "factory algorithm 1";
+    private static final String FACTORY_ALGORITHM_2 = "factory algorithm 2";
+    private static final String RESOURCE_TYPE = "resource";
+
+    private static final String FILE_TYPE = "file";
+    private static final String KEYSTORE_PASSWORD_1 = "passw0rd1";
+    private static final String KEYSTORE_RESOURCE_PATH_1 = "org.apache.fediz.kestore1";
+    private static final String KEYSTORE_PASSWORD_2 = "passw0rd2";
+    private static final String KEYSTORE_RESOURCE_PATH_2 = "org.apache.fediz.kestore2";
+    private static final String KEYSTORE_PASSWORD_3 = "passw0rd3";
+    private static final String KEYSTORE_RESOURCE_PATH_3 = "org.apache.fediz.kestore3";
+    private static final String CERT_STORE_FILE_1 = "/path/truststore.jks";
+    private static final String CERT_STORE_FILE_2 = "/path/keyfile.pem";
+    private static final String AUTH_TYPE_VALUE = "some auth type";
+
+    private static final String AUDIENCE_URI_1 = "http://host_one:port/url";
+    private static final String AUDIENCE_URI_2 = "http://host_two:port/url";
+    private static final String AUDIENCE_URI_3 = "http://host_three:port/url";
+
+    private static final String ROLE_DELIMITER = ";";
+    private static final String ROLE_URI = "http://someserver:8080/path/roles.uri";
+    private static final String CLAIM_TYPE_1 = "a particular claim type";
+    private static final String CLAIM_TYPE_2 = "a second particular claim type";
+
+    private static final String CONFIG_FILE = "./fedizconfig.xml";
+
+    private FedizConfig createConfiguration() throws JAXBException {
+
+        FedizConfig rootConfig = new FedizConfig();
+        ContextConfig config = new ContextConfig();
+        rootConfig.getContextConfig().add(config);
+
+        config.setName(CONFIG_NAME);
+        config.setMaximumClockSkew(new BigInteger(CLOCK_SKEW));
+        config.setCertificateValidation(ValidationType.CHAIN_TRUST);
+
+        TrustManagersType tm0 = new TrustManagersType();
+
+        CertStoreType cs0 = new CertStoreType();
+        cs0.setFile(KEYSTORE_FILE);
+        tm0.setCertStore(cs0);
+        tm0.setFactoryAlgorithm(FACTORY_ALGORITHM_1);
+
+        KeyStoreType ks0 = new KeyStoreType();
+        ks0.setType(RESOURCE_TYPE);
+        ks0.setPassword(KEYSTORE_PASSWORD_1);
+        ks0.setResource(KEYSTORE_RESOURCE_PATH_1);
+
+        tm0.setKeyStore(ks0);
+
+        config.setServiceCertificate(tm0);
+
+        FederationProtocolType protocol = new FederationProtocolType();
+        config.setProtocol(protocol);
+
+        TrustedIssuers trustedIssuer = new TrustedIssuers();
+
+        TrustManagersType tm1 = new TrustManagersType();
+        CertStoreType cs1 = new CertStoreType();
+        cs1.setFile(CERT_STORE_FILE_1);
+        tm1.setCertStore(cs1);
+        tm1.setFactoryAlgorithm(FACTORY_ALGORITHM_2);
+
+        KeyStoreType ks1 = new KeyStoreType();
+        ks1.setType(RESOURCE_TYPE);
+        ks1.setPassword(KEYSTORE_PASSWORD_2);
+        ks1.setResource(KEYSTORE_RESOURCE_PATH_2);
+
+        tm1.setKeyStore(ks1);
+        trustedIssuer.getTrustedIssuerItem().add(tm1);
+
+        TrustManagersType tm2 = new TrustManagersType();
+
+        CertStoreType cs2 = new CertStoreType();
+        cs2.setFile(CERT_STORE_FILE_2);
+        tm2.setCertStore(cs2);
+        tm2.setFactoryAlgorithm(FACTORY_ALGORITHM_2);
+
+        KeyStoreType ks2 = new KeyStoreType();
+        ks2.setType(FILE_TYPE);
+        ks2.setPassword(KEYSTORE_PASSWORD_3);
+        ks2.setResource(KEYSTORE_RESOURCE_PATH_3);
+
+        tm2.setKeyStore(ks2);
+        trustedIssuer.getTrustedIssuerItem().add(tm2);
+
+        config.setTrustedIssuers(trustedIssuer);
+
+        AuthenticationType authType = new AuthenticationType();
+        authType.setType(ArgumentType.STRING);
+        authType.setValue(AUTH_TYPE_VALUE);
+
+        AudienceUris audienceUris = new AudienceUris();
+        audienceUris.getAudienceItem().add(AUDIENCE_URI_1);
+        audienceUris.getAudienceItem().add(AUDIENCE_URI_2);
+        audienceUris.getAudienceItem().add(AUDIENCE_URI_3);
+        config.setAudienceUris(audienceUris);
+
+        protocol.setAuthenticationType(authType);
+        protocol.setRoleDelimiter(ROLE_DELIMITER);
+        protocol.setRoleURI(ROLE_URI);
+
+        ClaimTypesRequested claimTypeReq = new ClaimTypesRequested();
+        ClaimType claimType = new ClaimType();
+        claimType.setOptional(true);
+        claimType.setType(CLAIM_TYPE_1);
+        claimTypeReq.getClaimType().add(claimType);
+
+        ClaimType claimType2 = new ClaimType();
+        claimType2.setOptional(true);
+        claimType2.setType(CLAIM_TYPE_2);
+        claimTypeReq.getClaimType().add(claimType2);
+
+        protocol.setClaimTypesRequested(claimTypeReq);
+
+        protocol.setFreshness(FRESHNESS_VALUE);
+
+        HomeRealm homeRealm = new HomeRealm();
+        homeRealm.setType(ArgumentType.CLASS);
+        homeRealm.setValue(HOME_REALM_CLASS);
+
+        protocol.setHomeRealm(homeRealm);
+        protocol.setRealm(TARGET_REALM);
+        protocol.setReply(REPLY);
+        protocol.setRequest("REQUEST");
+        protocol.setVersion(PROTOCOL_VERSION);
+        protocol.setIssuer(ISSUER);
+
+        return rootConfig;
+
+    }
+
+    @org.junit.Test
+    public void readWriteConfig() throws JAXBException {
+
+        final JAXBContext jaxbContext = JAXBContext
+                .newInstance(FedizConfig.class);
+        FedizConfig configOut = createConfiguration();
+
+        StringWriter writer = new StringWriter();
+        jaxbContext.createMarshaller().marshal(configOut, writer);
+
+        StringReader reader = new StringReader(writer.toString());
+        FedizConfig configIn = (FedizConfig) jaxbContext.createUnmarshaller()
+                .unmarshal(reader);
+    }
+
+    @org.junit.Test
+    public void testSaveConfig() throws JAXBException, IOException {
+        final JAXBContext jaxbContext = JAXBContext
+                .newInstance(FedizConfig.class);
+
+        FederationConfigurator configurator = new FederationConfigurator();
+        FedizConfig configOut = createConfiguration();
+        StringWriter writer = new StringWriter();
+        jaxbContext.createMarshaller().marshal(configOut, writer);
+        StringReader reader = new StringReader(writer.toString());
+        configurator.loadConfig(reader);
+
+        File f = new File(CONFIG_FILE);
+        f.createNewFile();
+
+        configurator.saveConfiguration(f);
+    }
+
+    @org.junit.Test
+    public void testLoadConfig() throws JAXBException {
+        FederationConfigurator configurator = new FederationConfigurator();
+        File f = new File(CONFIG_FILE);
+        configurator.loadConfig(f);
+    }
+
+    @org.junit.Test
+    public void verifyConfig() throws JAXBException {
+
+        final JAXBContext jaxbContext = JAXBContext
+                .newInstance(FedizConfig.class);
+
+        FederationConfigurator configurator = new FederationConfigurator();
+        FedizConfig configOut = createConfiguration();
+        StringWriter writer = new StringWriter();
+        jaxbContext.createMarshaller().marshal(configOut, writer);
+        StringReader reader = new StringReader(writer.toString());
+        configurator.loadConfig(reader);
+
+        ContextConfig config = configurator.getContextConfig(CONFIG_NAME);
+        Assert.assertNotNull(config);
+        AudienceUris audience = config.getAudienceUris();
+        Assert.assertEquals(3, audience.getAudienceItem().size());
+        Assert.assertTrue(config.getProtocol() instanceof FederationProtocolType);
+        FederationProtocolType fp = (FederationProtocolType) config
+                .getProtocol();
+
+        Assert.assertEquals(HOME_REALM_CLASS, fp.getHomeRealm().getValue());
+
+    }
+
+}
\ No newline at end of file

Added: cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java?rev=1329945&view=auto
==============================================================================
--- cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java (added)
+++ cxf/sandbox/fediz/fediz-core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java Tue Apr 24 19:03:39 2012
@@ -0,0 +1,189 @@
+package org.apache.cxf.fediz.core.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.math.BigInteger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.junit.Assert;
+
+public class FedizConfigurationWriterTest {
+
+    private static final String TRUST_ISSUER_CERT_CONSTRAINT = ".*CN=www.sts.com.*";
+    private static final String ROLE_URI = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role";
+    private static final String ROLE_DELIMITER = ";";
+
+    private static final String ISSUER = "http://url_to_the_issuer";
+    private static final String PROTOCOL_VERSION = "1.0.0";
+    private static final String REQUEST = "request value";
+    private static final String REPLY = "reply value";
+    private static final String TARGET_REALM = "target realm";
+    private static final String HOME_REALM_CLASS = "org.apache.fediz.realm.MyHomeRealm.class";
+    private static final String FRESHNESS_VALUE = "10000";
+
+    private static final String CONFIG_NAME = "ROOT";
+    private static final String CLOCK_SKEW = "1000";
+    private static final String KEYSTORE_FILE = "stsstore.jks";
+
+    private static final String FILE_TYPE = "file";
+    private static final String RESOURCE_TYPE = "resource";
+
+    private static final String KEYSTORE_PASSWORD = "stsspass";
+    private static final String AUDIENCE_URI_1 = "http://host_one:port/url";
+
+    private static final String AUTH_TYPE_VALUE = "some auth type";
+
+    private static final String CLAIM_TYPE_1 = "a particular claim type";
+
+    private static final String CONFIG_FILE = "./fediz_test_config.xml";
+
+    private FedizConfig createConfiguration() throws JAXBException {
+
+        FedizConfig rootConfig = new FedizConfig();
+        ContextConfig config = new ContextConfig();
+        rootConfig.getContextConfig().add(config);
+
+        config.setName(CONFIG_NAME);
+        config.setMaximumClockSkew(new BigInteger(CLOCK_SKEW));
+        config.setCertificateValidation(ValidationType.CHAIN_TRUST);
+
+        // TrustManagersType tm0 = new TrustManagersType();
+        //
+        // KeyStoreType ks0 = new KeyStoreType();
+        // ks0.setType(FILE_TYPE);
+        // ks0.setPassword(KEYSTORE_PASSWORD);
+        // ks0.setFile(KEYSTORE_FILE);
+        //
+        // tm0.setKeyStore(ks0);
+        //
+        // config.setServiceCertificate(tm0);
+
+        FederationProtocolType protocol = new FederationProtocolType();
+        config.setProtocol(protocol);
+
+        TrustedIssuers trustedIssuer = new TrustedIssuers();
+
+        TrustManagersType tm1 = new TrustManagersType();
+        tm1.setProvider(TRUST_ISSUER_CERT_CONSTRAINT);
+        // CertStoreType cs1 = new CertStoreType();
+        // cs1.setFile(CERT_STORE_FILE_1);
+        // tm1.setCertStore(cs1);
+        // tm1.setFactoryAlgorithm(FACTORY_ALGORITHM_2);
+
+        KeyStoreType ks1 = new KeyStoreType();
+        ks1.setType(FILE_TYPE);
+        ks1.setPassword(KEYSTORE_PASSWORD);
+        ks1.setFile(KEYSTORE_FILE);
+
+        tm1.setKeyStore(ks1);
+        trustedIssuer.getTrustedIssuerItem().add(tm1);
+
+        config.setTrustedIssuers(trustedIssuer);
+
+        AuthenticationType authType = new AuthenticationType();
+        authType.setType(ArgumentType.STRING);
+        authType.setValue(AUTH_TYPE_VALUE);
+
+        AudienceUris audienceUris = new AudienceUris();
+        audienceUris.getAudienceItem().add(AUDIENCE_URI_1);
+        config.setAudienceUris(audienceUris);
+
+        protocol.setAuthenticationType(authType);
+        protocol.setRoleDelimiter(ROLE_DELIMITER);
+        protocol.setRoleURI(ROLE_URI);
+
+        ClaimTypesRequested claimTypeReq = new ClaimTypesRequested();
+        ClaimType claimType = new ClaimType();
+        claimType.setOptional(true);
+        claimType.setType(CLAIM_TYPE_1);
+        claimTypeReq.getClaimType().add(claimType);
+
+        protocol.setClaimTypesRequested(claimTypeReq);
+
+        protocol.setFreshness(FRESHNESS_VALUE);
+
+        HomeRealm homeRealm = new HomeRealm();
+        homeRealm.setType(ArgumentType.CLASS);
+        homeRealm.setValue(HOME_REALM_CLASS);
+
+        protocol.setHomeRealm(homeRealm);
+        protocol.setRealm(TARGET_REALM);
+        protocol.setReply(REPLY);
+        protocol.setRequest("REQUEST");
+        protocol.setVersion(PROTOCOL_VERSION);
+        protocol.setIssuer(ISSUER);
+
+        return rootConfig;
+
+    }
+
+    @org.junit.Test
+    public void readWriteConfig() throws JAXBException {
+
+        final JAXBContext jaxbContext = JAXBContext
+                .newInstance(FedizConfig.class);
+        FedizConfig configOut = createConfiguration();
+
+        StringWriter writer = new StringWriter();
+        jaxbContext.createMarshaller().marshal(configOut, writer);
+
+        StringReader reader = new StringReader(writer.toString());
+        FedizConfig configIn = (FedizConfig) jaxbContext.createUnmarshaller()
+                .unmarshal(reader);
+    }
+
+    @org.junit.Test
+    public void testSaveConfig() throws JAXBException, IOException {
+        final JAXBContext jaxbContext = JAXBContext
+                .newInstance(FedizConfig.class);
+
+        FederationConfigurator configurator = new FederationConfigurator();
+        FedizConfig configOut = createConfiguration();
+        StringWriter writer = new StringWriter();
+        jaxbContext.createMarshaller().marshal(configOut, writer);
+        StringReader reader = new StringReader(writer.toString());
+        configurator.loadConfig(reader);
+
+        File f = new File(CONFIG_FILE);
+        f.createNewFile();
+
+        configurator.saveConfiguration(f);
+    }
+
+    @org.junit.Test
+    public void testLoadConfig() throws JAXBException {
+        FederationConfigurator configurator = new FederationConfigurator();
+        File f = new File(CONFIG_FILE);
+        configurator.loadConfig(f);
+    }
+
+    @org.junit.Test
+    public void verifyConfig() throws JAXBException {
+
+        final JAXBContext jaxbContext = JAXBContext
+                .newInstance(FedizConfig.class);
+
+        FederationConfigurator configurator = new FederationConfigurator();
+        FedizConfig configOut = createConfiguration();
+        StringWriter writer = new StringWriter();
+        jaxbContext.createMarshaller().marshal(configOut, writer);
+        StringReader reader = new StringReader(writer.toString());
+        configurator.loadConfig(reader);
+
+        ContextConfig config = configurator.getContextConfig(CONFIG_NAME);
+        Assert.assertNotNull(config);
+        AudienceUris audience = config.getAudienceUris();
+        Assert.assertEquals(1, audience.getAudienceItem().size());
+        Assert.assertTrue(config.getProtocol() instanceof FederationProtocolType);
+        FederationProtocolType fp = (FederationProtocolType) config
+                .getProtocol();
+
+        Assert.assertEquals(HOME_REALM_CLASS, fp.getHomeRealm().getValue());
+
+    }
+
+}
\ No newline at end of file

Added: cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config.xml?rev=1329945&view=auto
==============================================================================
--- cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config.xml (added)
+++ cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config.xml Tue Apr 24 19:03:39 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<FedizConfig>
+	<contextConfig name="ROOT">
+		<audienceUris>
+			<audienceItem>http://host_one:port/url</audienceItem>
+		</audienceUris>
+		<certificateValidation>ChainTrust</certificateValidation>
+		<trustedIssuers>
+			<trustedIssuerItem provider=".*CN=www.sts.com.*">
+				<keyStore file="stsstore.jks" password="stsspass" type="file" />
+			</trustedIssuerItem>
+		</trustedIssuers>
+		<maximumClockSkew>1000</maximumClockSkew>
+		<protocol xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+			xsi:type="federationProtocolType" version="1.0.0">
+			<realm>target realm</realm>
+			<issuer>http://url_to_the_issuer</issuer>
+			<roleDelimiter>;</roleDelimiter>
+			<roleURI>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role</roleURI>
+			<authenticationType value="some auth type" type="String" />
+			<homeRealm value="org.apache.fediz.realm.MyHomeRealm.class"
+				type="Class" />
+			<freshness>10000</freshness>
+			<reply>reply value</reply>
+			<request>REQUEST</request>
+			<claimTypesRequested>
+				<claimType type="a particular claim type" optional="true" />
+			</claimTypesRequested>
+		</protocol>
+	</contextConfig>
+</FedizConfig>
\ No newline at end of file

Added: cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config2.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config2.xml?rev=1329945&view=auto
==============================================================================
--- cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config2.xml (added)
+++ cxf/sandbox/fediz/fediz-core/src/test/resources/fediz_test_config2.xml Tue Apr 24 19:03:39 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<FedizConfig>
+	<contextConfig name="ROOT">
+		<audienceUris>
+			<audienceItem>http://host_one:port/url</audienceItem>
+		</audienceUris>
+		<certificateValidation>ChainTrust</certificateValidation>
+		<trustedIssuers>
+			<trustedIssuerItem provider="DoubleItSTSIssuer">
+				<keyStore file="stsstore.jks" password="stsspass" type="file" />
+			</trustedIssuerItem>
+		</trustedIssuers>
+		<maximumClockSkew>1000</maximumClockSkew>
+		<protocol xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+			xsi:type="federationProtocolType" version="1.0.0">
+			<realm>target realm</realm>
+			<issuer>http://url_to_the_issuer</issuer>
+			<roleDelimiter>;</roleDelimiter>
+			<roleURI>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role</roleURI>
+			<authenticationType value="some auth type" type="String" />
+			<homeRealm value="org.apache.fediz.realm.MyHomeRealm.class"
+				type="Class" />
+			<freshness>10000</freshness>
+			<reply>reply value</reply>
+			<request>REQUEST</request>
+			<claimTypesRequested>
+				<claimType type="a particular claim type" optional="true" />
+			</claimTypesRequested>
+		</protocol>
+	</contextConfig>
+</FedizConfig>
\ No newline at end of file

Modified: cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java (original)
+++ cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java Tue Apr 24 19:03:39 2012
@@ -37,7 +37,8 @@ import javax.xml.transform.stream.Stream
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.cxf.fediz.core.Claim;
 import org.apache.cxf.fediz.core.ClaimCollection;
-import org.apache.cxf.fediz.tomcat.FederationPrincipal;
+import org.apache.cxf.fediz.core.FederationPrincipal;
+import org.apache.cxf.fediz.tomcat.FederationPrincipalImpl;
 import org.apache.hello_world_soap_http.Greeter;
 import org.w3c.dom.Element;
 
@@ -140,8 +141,8 @@ public class FederationServlet extends H
             out.println("Has role '" + item + "': " + ((request.isUserInRole(item)) ? "<b>yes</b>" : "no") + "<p>" );
         }
 
-        if (p instanceof FederationPrincipal) {
-            FederationPrincipal fp = (FederationPrincipal)p;
+        if (p instanceof FederationPrincipalImpl) {
+            FederationPrincipalImpl fp = (FederationPrincipalImpl)p;
 
             out.println("<br><b>Claims</b><p>");
             ClaimCollection claims = fp.getClaims();
@@ -150,7 +151,7 @@ public class FederationServlet extends H
             }
         }
         else {
-            out.println("Principal is not instance of FederationPrincipal");
+            out.println("Principal is not instance of FederationPrincipalImpl");
         }
 
         Greeter service = (Greeter)ApplicationContextProvider.getContext().getBean("HelloServiceClient");

Modified: cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml (original)
+++ cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml Tue Apr 24 19:03:39 2012
@@ -22,7 +22,13 @@
 		<init-param>
 			<param-name>sts.wsdl.endpoint</param-name>
 			<param-value>TransportUT_Port</param-value>
-		</init-param>				
+		</init-param>
+<!--		
+		<init-param>
+			<param-name>ws-trust-tokentype</param-name>
+			<param-value>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</param-value>
+		</init-param>
+-->		
 	</servlet>
 
 	<servlet-mapping>

Modified: cxf/sandbox/fediz/fediz-tomcat-example/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/pom.xml?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/pom.xml (original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/pom.xml Tue Apr 24 19:03:39 2012
@@ -17,12 +17,14 @@
    </properties>
 
     <dependencies>
+    <!-- 
 		<dependency>
 			<groupId>org.apache.tomcat</groupId>
 			<artifactId>tomcat-catalina</artifactId>
 			<version>${tomcat.version}</version>
 			<scope>provided</scope>
 		</dependency>
+		 -->
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java (original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java Tue Apr 24 19:03:39 2012
@@ -13,55 +13,52 @@ import javax.servlet.http.HttpServletReq
 import org.w3c.dom.Element;
 
 /**
- * Add security token to thread local
- *
- * @deprecated  Use filter shipped with SAFT
- */
-@Deprecated
+* Add security token to thread local
+*/
 public class FederationFilter implements Filter {
 
-    private static final String DEFAULT_SECURITY_TOKEN_ATTR = "org.apache.fediz.SECURITY_TOKEN";
-    private static final String SECURITY_TOKEN_ATTR_CONFIG = "security.token.attribute";
+	private static final String DEFAULT_SECURITY_TOKEN_ATTR = "org.apache.fediz.SECURITY_TOKEN";
+	private static final String SECURITY_TOKEN_ATTR_CONFIG = "security.token.attribute";
+	
+	private String securityTokenAttr = DEFAULT_SECURITY_TOKEN_ATTR;
+	
+	@Override
+	public void init(FilterConfig filterConfig) throws ServletException {
+		String attrName = filterConfig.getInitParameter(SECURITY_TOKEN_ATTR_CONFIG);
+		if (attrName != null) {
+			securityTokenAttr = attrName;
+		}
+		
+	}
+
+	@Override
+	public void doFilter(ServletRequest request, ServletResponse response,
+			FilterChain chain) throws IOException, ServletException {
+	
+		if (request instanceof HttpServletRequest) {
+			HttpServletRequest hrequest = (HttpServletRequest)request;
+			Element el = (Element)hrequest.getSession().getAttribute(securityTokenAttr);
+			if (el != null) {
+				try
+				{
+					SecurityTokenThreadLocal.setToken(el);
+					chain.doFilter(request, response);
+				} finally {
+					SecurityTokenThreadLocal.setToken(null);
+				}		
+			} else {
+				chain.doFilter(request, response);
+			}
+			
+		} else {
+			chain.doFilter(request, response);
+		}
+	}
+
+	@Override
+	public void destroy() {
+		// TODO Auto-generated method stub
 
-    private String securityTokenAttr = DEFAULT_SECURITY_TOKEN_ATTR;
-
-    @Override
-    public void init(FilterConfig filterConfig) throws ServletException {
-        String attrName = filterConfig.getInitParameter(SECURITY_TOKEN_ATTR_CONFIG);
-        if (attrName != null) {
-            securityTokenAttr = attrName;
-        }
-
-    }
-
-    @Override
-    public void doFilter(ServletRequest request, ServletResponse response,
-                         FilterChain chain) throws IOException, ServletException {
-
-        if (request instanceof HttpServletRequest) {
-            HttpServletRequest hrequest = (HttpServletRequest)request;
-            Element el = (Element)hrequest.getSession().getAttribute(securityTokenAttr);
-            if (el != null) {
-                try
-                {
-                    SecurityTokenThreadLocal.setToken(el);
-                    chain.doFilter(request, response);
-                } finally {
-                    SecurityTokenThreadLocal.setToken(null);
-                }		
-            } else {
-                chain.doFilter(request, response);
-            }
-
-        } else {
-            chain.doFilter(request, response);
-        }
-    }
-
-    @Override
-    public void destroy() {
-        // TODO Auto-generated method stub
-
-    }
+	}
 
 }

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java (original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java Tue Apr 24 19:03:39 2012
@@ -20,7 +20,7 @@ import javax.xml.transform.stream.Stream
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.cxf.fediz.core.Claim;
 import org.apache.cxf.fediz.core.ClaimCollection;
-import org.apache.cxf.fediz.tomcat.FederationPrincipal;
+import org.apache.cxf.fediz.core.FederationPrincipal;
 import org.w3c.dom.Element;
 
 public class FederationServlet extends HttpServlet {

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java (original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java Tue Apr 24 19:03:39 2012
@@ -4,22 +4,19 @@ import org.w3c.dom.Element;
 
 
 /**
- * Thread local storage for security token
- *
- * @deprecated  Use TLS shipped with SAFT
- */
-@Deprecated
+* Thread local storage for security token
+*/
 public class SecurityTokenThreadLocal {
 
-    private static final ThreadLocal<Element> threadToken = 
-        new ThreadLocal<Element>() {
-    };
-
-    public static void setToken(Element token) {
-        threadToken.set(token);
-    }
-
-    public static Element getToken() {
-        return threadToken.get();
-    }
+	private static final ThreadLocal<Element> threadToken = 
+	       new ThreadLocal<Element>() {
+	};
+	
+	public static void setToken(Element token) {
+		threadToken.set(token);
+	}
+	
+	public static Element getToken() {
+		return threadToken.get();
+	}
 }
\ No newline at end of file

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml?rev=1329945&r1=1329944&r2=1329945&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml (original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml Tue Apr 24 19:03:39 2012
@@ -1,3 +1,5 @@
 <Context>
-        <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" issuerURL="https://localhost:9443/fedizidp/" truststoreFile="conf/stsstore.jks" truststorePassword="stsspass" trustedIssuer=".*CN=www.sts.com.*" />        
+        <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" configFile="/projects/fediz/tomcat-rp2/conf/fediz_config.xml" />
+        <!--<Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" issuerURL="https://localhost:9443/fedizidp/" truststoreFile="conf/stsstore.jks" truststorePassword="stsspass" trustedIssuer=".*CN=www.sts.com.*" />-->
+        <!--Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" issuerCallbackHandler="org.apache.cxf.fediz.tomcat.DummyIDPCallbackHandler" truststoreFile="conf/stsstore.jks" truststorePassword="stsspass" />-->        
 </Context>



Mime
View raw message