Author: anil.saldhana(a)jboss.com
Date: 2009-06-09 19:21:28 -0400 (Tue, 09 Jun 2009)
New Revision: 598
Added:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/wstrust/JBossSTS.java
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/SOAPSAMLXACMLServletUnitTestCase.java
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/response/SAML2Response.java
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/plugins/saml/SAMLUtil.java
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/xmlenc/factories/XMLEncryptionFactory.java
Log:
refactor
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/wstrust/JBossSTS.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/wstrust/JBossSTS.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/wstrust/JBossSTS.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -25,7 +25,6 @@
import java.net.URL;
import javax.annotation.Resource;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.transform.Source;
import javax.xml.ws.Service;
@@ -41,6 +40,7 @@
import org.jboss.identity.federation.api.wstrust.WSTrustJAXBFactory;
import org.jboss.identity.federation.api.wstrust.WSTrustRequestHandler;
import org.jboss.identity.federation.bindings.config.STSType;
+import org.jboss.identity.federation.core.util.JAXBUtil;
import org.jboss.identity.federation.core.wstrust.BaseRequestSecurityToken;
import org.jboss.identity.federation.core.wstrust.RequestSecurityToken;
import org.jboss.identity.federation.core.wstrust.RequestSecurityTokenCollection;
@@ -162,10 +162,10 @@
try
{
+ String pkgName = "org.jboss.identity.federation.bindings.config";
InputStream stream = configurationFile.openStream();
- JAXBContext context =
JAXBContext.newInstance("org.jboss.identity.federation.bindings.config");
- JAXBElement element = (JAXBElement)
context.createUnmarshaller().unmarshal(stream);
- STSType stsConfig = (STSType) element.getValue();
+ JAXBElement<STSType> element = (JAXBElement<STSType>)
JAXBUtil.getUnmarshaller(pkgName).unmarshal(stream);
+ STSType stsConfig = element.getValue();
return new JBossSTSConfiguration(stsConfig);
}
catch (Exception e)
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -47,6 +47,7 @@
import org.jboss.identity.federation.core.saml.v2.util.DocumentUtil;
import org.jboss.identity.federation.core.saml.v2.util.JAXBElementMappingUtil;
import org.jboss.identity.federation.core.saml.v2.util.SOAPSAMLXACMLUtil;
+import org.jboss.identity.federation.core.util.JAXBUtil;
import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Body;
import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Envelope;
import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Fault;
@@ -135,7 +136,7 @@
if(debug)
log.trace("Received
SOAP:"+DocumentUtil.getDocumentAsString(inputDoc));
- Unmarshaller un = SOAPSAMLXACMLUtil.getUnmarshaller();
+ Unmarshaller un = JAXBUtil.getUnmarshaller(SOAPSAMLXACMLUtil.getPackage());
if(debug)
un.setEventHandler(new DefaultValidationEventHandler());
@@ -228,7 +229,7 @@
if(envelope == null)
throw new IllegalStateException("SOAPEnvelope is null");
JAXBElement<?> jaxbEnvelope = JAXBElementMappingUtil.get(envelope);
- Marshaller marshaller = SOAPSAMLXACMLUtil.getMarshaller();
+ Marshaller marshaller =
JAXBUtil.getMarshaller(SOAPSAMLXACMLUtil.getPackage());
marshaller.marshal(jaxbEnvelope, os);
}
catch (JAXBException e)
Added:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.identity.federation.bindings.tomcat.sp;
+
+import java.io.InputStream;
+
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.authenticator.FormAuthenticator;
+import org.apache.log4j.Logger;
+import org.jboss.identity.federation.bindings.config.SPType;
+import org.jboss.identity.federation.bindings.util.ValveUtil;
+
+/**
+ * Base Class for Form Authenticators
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jun 9, 2009
+ */
+public class BaseFormAuthenticator extends FormAuthenticator
+{
+ private static Logger log = Logger.getLogger(BaseFormAuthenticator.class);
+
+ protected SPType spConfiguration = null;
+
+ protected String serviceURL = null;
+ protected String identityURL = null;
+
+ protected String configFile = "/WEB-INF/jboss-idfed.xml";
+
+ public BaseFormAuthenticator()
+ {
+ super();
+ }
+
+ public String getConfigFile()
+ {
+ return configFile;
+ }
+
+ public void setConfigFile(String configFile)
+ {
+ this.configFile = configFile;
+ }
+
+ @Override
+ public void start() throws LifecycleException
+ {
+ super.start();
+
+ InputStream is = context.getServletContext().getResourceAsStream(configFile);
+ if(is == null)
+ throw new RuntimeException(configFile + " missing");
+ try
+ {
+ spConfiguration = ValveUtil.getSPConfiguration(is);
+ this.identityURL = spConfiguration.getIdentityURL();
+ this.serviceURL = spConfiguration.getServiceURL();
+ log.trace("Identity Provider URL=" + this.identityURL);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -31,12 +31,9 @@
import javax.servlet.ServletException;
import javax.xml.bind.JAXBException;
-import javax.xml.datatype.DatatypeConfigurationException;
-import org.apache.catalina.LifecycleException;
import org.apache.catalina.Session;
import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.authenticator.FormAuthenticator;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.deploy.LoginConfig;
@@ -44,7 +41,6 @@
import org.apache.log4j.Logger;
import org.jboss.identity.federation.api.saml.v2.request.SAML2Request;
import org.jboss.identity.federation.api.saml.v2.response.SAML2Response;
-import org.jboss.identity.federation.bindings.config.SPType;
import org.jboss.identity.federation.bindings.config.TrustType;
import
org.jboss.identity.federation.bindings.tomcat.sp.holder.ServiceProviderSAMLContext;
import org.jboss.identity.federation.bindings.util.PostBindingUtil;
@@ -65,41 +61,14 @@
* @author Anil.Saldhana(a)redhat.com
* @since Dec 12, 2008
*/
-public class SPPostFormAuthenticator extends FormAuthenticator
-{
+public class SPPostFormAuthenticator extends BaseFormAuthenticator
+{
private static Logger log = Logger.getLogger(SPPostFormAuthenticator.class);
- protected SPType spConfiguration = null;
-
- private String serviceURL = null;
- private String identityURL = null;
-
public SPPostFormAuthenticator()
{
super();
}
-
- @Override
- public void start() throws LifecycleException
- {
- String configFile = "/WEB-INF/jboss-idfed.xml";
- super.start();
-
- InputStream is = context.getServletContext().getResourceAsStream(configFile);
- if(is == null)
- throw new RuntimeException(configFile + " missing");
- try
- {
- spConfiguration = ValveUtil.getSPConfiguration(is);
- this.identityURL = spConfiguration.getIdentityURL();
- this.serviceURL = spConfiguration.getServiceURL();
- log.trace("Identity Provider URL=" + this.identityURL);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
@Override
public boolean authenticate(Request request, Response response, LoginConfig
loginConfig) throws IOException
@@ -239,7 +208,7 @@
private Principal process(Request request, Response response)
throws JAXBException, SAXException, IssuerNotTrustedException,
- AssertionExpiredException, DatatypeConfigurationException, ConfigurationException
+ AssertionExpiredException, ConfigurationException
{
Principal userPrincipal = null;
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -32,12 +32,9 @@
import javax.servlet.ServletException;
import javax.xml.bind.JAXBException;
-import javax.xml.datatype.DatatypeConfigurationException;
-import org.apache.catalina.LifecycleException;
import org.apache.catalina.Session;
import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.authenticator.FormAuthenticator;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.deploy.LoginConfig;
@@ -47,7 +44,6 @@
import org.jboss.identity.federation.api.saml.v2.response.SAML2Response;
import org.jboss.identity.federation.api.util.Base64;
import org.jboss.identity.federation.api.util.DeflateUtil;
-import org.jboss.identity.federation.bindings.config.SPType;
import org.jboss.identity.federation.bindings.config.TrustType;
import
org.jboss.identity.federation.bindings.tomcat.sp.holder.ServiceProviderSAMLContext;
import org.jboss.identity.federation.bindings.util.HTTPRedirectUtil;
@@ -70,41 +66,14 @@
* @author Anil.Saldhana(a)redhat.com
* @since Dec 12, 2008
*/
-public class SPRedirectFormAuthenticator extends FormAuthenticator
+public class SPRedirectFormAuthenticator extends BaseFormAuthenticator
{
private static Logger log = Logger.getLogger(SPRedirectFormAuthenticator.class);
- protected SPType spConfiguration = null;
-
- private String serviceURL = null;
- private String identityURL = null;
-
public SPRedirectFormAuthenticator()
{
super();
}
-
- @Override
- public void start() throws LifecycleException
- {
- String configFile = "/WEB-INF/jboss-idfed.xml";
- super.start();
-
- InputStream is = context.getServletContext().getResourceAsStream(configFile);
- if(is == null)
- throw new RuntimeException(configFile + " missing");
- try
- {
- spConfiguration = ValveUtil.getSPConfiguration(is);
- this.identityURL = spConfiguration.getIdentityURL();
- this.serviceURL = spConfiguration.getServiceURL();
- log.trace("Identity Provider URL=" + this.identityURL);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
@Override
public boolean authenticate(Request request, Response response, LoginConfig
loginConfig) throws IOException
@@ -258,8 +227,7 @@
private Principal process(Request request, Response response)
throws IOException, GeneralSecurityException,
- JAXBException, SAXException, ConfigurationException,
- ParsingException, DatatypeConfigurationException
+ ConfigurationException, ParsingException
{
Principal userPrincipal = null;
@@ -274,7 +242,19 @@
SAML2Response saml2Response = new SAML2Response();
- ResponseType responseType = saml2Response.getResponseType(is);
+ ResponseType responseType;
+ try
+ {
+ responseType = saml2Response.getResponseType(is);
+ }
+ catch (JAXBException e)
+ {
+ throw new ParsingException(e);
+ }
+ catch (SAXException e)
+ {
+ throw new ParsingException(e);
+ }
this.isTrusted(responseType.getIssuer().getValue());
Modified:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -22,7 +22,6 @@
package org.jboss.test.identity.federation.bindings.servlets;
import java.io.InputStream;
-import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
@@ -33,6 +32,7 @@
import junit.framework.TestCase;
import org.jboss.identity.federation.core.saml.v2.util.SOAPSAMLXACMLUtil;
+import org.jboss.identity.federation.core.util.JAXBUtil;
import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Envelope;
import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Fault;
import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
@@ -82,7 +82,7 @@
{
JAXBElement<?> jb =
getResponse("xacml/requests/himss-soap-request.xml");
Envelope env = (Envelope) jb.getValue();
- Marshaller marshaller = SOAPSAMLXACMLUtil.getMarshaller();
+ Marshaller marshaller = JAXBUtil.getMarshaller(SOAPSAMLXACMLUtil.getPackage());
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
marshaller.marshal(jb, System.out);
@@ -96,7 +96,7 @@
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
InputStream is = tcl.getResourceAsStream("xacml/requests/samlxacml.xml");
- Unmarshaller um = SOAPSAMLXACMLUtil.getUnmarshaller();
+ Unmarshaller um = JAXBUtil.getUnmarshaller(SOAPSAMLXACMLUtil.getPackage());
um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
JAXBElement<?> obj = (JAXBElement<?>) um.unmarshal(is);
@@ -134,10 +134,10 @@
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
InputStream is = tcl.getResourceAsStream(fileName);
- Unmarshaller um = SOAPSAMLXACMLUtil.getUnmarshaller();
+ Unmarshaller um = JAXBUtil.getUnmarshaller(SOAPSAMLXACMLUtil.getPackage());
Object soapRequest = um.unmarshal(is);
- Marshaller m = SOAPSAMLXACMLUtil.getMarshaller();
+ Marshaller m = JAXBUtil.getMarshaller(SOAPSAMLXACMLUtil.getPackage());
URL url = new URL(endpoint);
URLConnection conn = url.openConnection();
Modified:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/SOAPSAMLXACMLServletUnitTestCase.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/SOAPSAMLXACMLServletUnitTestCase.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/SOAPSAMLXACMLServletUnitTestCase.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -36,6 +36,7 @@
import org.jboss.identity.federation.bindings.servlets.SOAPSAMLXACMLServlet;
import org.jboss.identity.federation.core.saml.v2.util.SOAPSAMLXACMLUtil;
+import org.jboss.identity.federation.core.util.JAXBUtil;
import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Envelope;
import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Fault;
import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
@@ -80,7 +81,7 @@
sresp.flushBuffer(); //Flush the servlet response ServletOutputStream to our baos
bis = new ByteArrayInputStream(baos.toByteArray());
- Unmarshaller un = SOAPSAMLXACMLUtil.getUnmarshaller();
+ Unmarshaller un = JAXBUtil.getUnmarshaller(SOAPSAMLXACMLUtil.getPackage());
JAXBElement<Envelope> jax = (JAXBElement<Envelope>) un.unmarshal(bis);
Envelope envelope = jax.getValue();
assertNotNull("Envelope is not null", envelope);
@@ -110,7 +111,7 @@
sresp.flushBuffer(); //Flush the servlet response ServletOutputStream to our baos
ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
- Unmarshaller un = SOAPSAMLXACMLUtil.getUnmarshaller();
+ Unmarshaller un = JAXBUtil.getUnmarshaller(SOAPSAMLXACMLUtil.getPackage());
JAXBElement<Envelope> jax = (JAXBElement<Envelope>) un.unmarshal(bis);
Envelope envelope = jax.getValue();
assertNotNull("Envelope is not null", envelope);
Modified:
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/response/SAML2Response.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/response/SAML2Response.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/response/SAML2Response.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -177,7 +177,7 @@
if(is == null)
throw new IllegalArgumentException("inputstream is null");
- Unmarshaller un = JBossSAMLAuthnResponseFactory.getValidatingUnmarshaller();
+ Unmarshaller un = JBossSAMLAuthnResponseFactory.getUnmarshaller();
JAXBElement<EncryptedElementType> jaxb =
(JAXBElement<EncryptedElementType>) un.unmarshal(is);
return jaxb.getValue();
}
@@ -195,7 +195,7 @@
if(is == null)
throw new IllegalArgumentException("inputstream is null");
- Unmarshaller un = JBossSAMLAuthnResponseFactory.getValidatingUnmarshaller();
+ Unmarshaller un = JBossSAMLAuthnResponseFactory.getUnmarshaller();
JAXBElement<AssertionType> jaxb = (JAXBElement<AssertionType>)
un.unmarshal(is);
return jaxb.getValue();
}
@@ -208,12 +208,12 @@
* @throws JAXBException
*/
@SuppressWarnings("unchecked")
- public ResponseType getResponseType(InputStream is) throws JAXBException, SAXException
+ public ResponseType getResponseType(InputStream is) throws JAXBException,
SAXException
{
if(is == null)
throw new IllegalArgumentException("inputstream is null");
- Unmarshaller un = JBossSAMLAuthnResponseFactory.getValidatingUnmarshaller();
+ Unmarshaller un = JBossSAMLAuthnResponseFactory.getUnmarshaller();
JAXBElement<ResponseType> jaxbAuthnRequestType =
(JAXBElement<ResponseType>) un.unmarshal(is);
return jaxbAuthnRequestType.getValue();
}
@@ -266,7 +266,7 @@
*/
public void marshall(ResponseType responseType, OutputStream os) throws JAXBException,
SAXException
{
- Marshaller marshaller = JBossSAMLAuthnResponseFactory.getValidatingMarshaller();
+ Marshaller marshaller = JBossSAMLAuthnResponseFactory.getMarshaller();
JAXBElement<ResponseType> jaxb =
SAMLProtocolFactory.getObjectFactory().createResponse(responseType);
marshaller.marshal(jaxb, os);
}
@@ -280,7 +280,7 @@
*/
public void marshall(ResponseType responseType, Writer writer) throws JAXBException,
SAXException
{
- Marshaller marshaller = JBossSAMLAuthnResponseFactory.getValidatingMarshaller();
+ Marshaller marshaller = JBossSAMLAuthnResponseFactory.getMarshaller();
JAXBElement<ResponseType> jaxb =
SAMLProtocolFactory.getObjectFactory().createResponse(responseType);
marshaller.marshal(jaxb, writer);
}
Modified:
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/plugins/saml/SAMLUtil.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/plugins/saml/SAMLUtil.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/plugins/saml/SAMLUtil.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -21,7 +21,6 @@
*/
package org.jboss.identity.federation.api.wstrust.plugins.saml;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -30,6 +29,7 @@
import javax.xml.transform.dom.DOMResult;
import org.jboss.identity.federation.api.wstrust.WSTrustConstants;
+import org.jboss.identity.federation.core.util.JAXBUtil;
import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
import org.jboss.identity.federation.saml.v2.assertion.ObjectFactory;
import org.w3c.dom.Document;
@@ -66,8 +66,7 @@
Document document = null;
document =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
DOMResult result = new DOMResult(document);
- JAXBContext jaxbContext =
JAXBContext.newInstance("org.jboss.identity.federation.saml.v2.assertion");
- Marshaller marshaller = jaxbContext.createMarshaller();
+ Marshaller marshaller =
JAXBUtil.getMarshaller("org.jboss.identity.federation.saml.v2.assertion");
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new
DefaultPrefixMapper());
marshaller.marshal(new ObjectFactory().createAssertion(assertion), result);
@@ -84,9 +83,8 @@
* @throws JAXBException if an error occurs while unmarshaling the document.
*/
public static AssertionType fromDocument(Document document) throws JAXBException
- {
- JAXBContext jaxbContext =
JAXBContext.newInstance("org.jboss.identity.federation.saml.v2.assertion");
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ {
+ Unmarshaller unmarshaller =
JAXBUtil.getUnmarshaller("org.jboss.identity.federation.saml.v2.assertion");
Object object = unmarshaller.unmarshal(document);
if (object instanceof AssertionType)
return (AssertionType) object;
Modified:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -180,6 +180,28 @@
* @throws JAXBException
* @throws SAXException
*/
+ public static Marshaller getMarshaller() throws SAXException, JAXBException
+ {
+ return JAXBUtil.getMarshaller(pkgName);
+ }
+
+ /**
+ * Get the JAXB2 Unmarshaller
+ * @return
+ * @throws SAXException
+ * @throws JAXBException
+ */
+ public static Unmarshaller getUnmarshaller() throws JAXBException, SAXException
+ {
+ return JAXBUtil.getUnmarshaller(pkgName);
+ }
+
+ /**
+ * Get the JAXB2 marshaller
+ * @return
+ * @throws JAXBException
+ * @throws SAXException
+ */
public static Marshaller getValidatingMarshaller() throws SAXException, JAXBException
{
return JAXBUtil.getValidatingMarshaller(pkgName, schemaLocation);
Modified:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -23,14 +23,13 @@
import java.io.StringReader;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
+import org.jboss.identity.federation.core.util.JAXBUtil;
import org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.ObjectFactory;
import
org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.XACMLAuthzDecisionStatementType;
import
org.jboss.identity.federation.saml.v2.profiles.xacml.protocol.XACMLAuthzDecisionQueryType;
@@ -54,18 +53,6 @@
private static String collectivePackage = getPackage();
- public static Marshaller getMarshaller() throws JAXBException
- {
- JAXBContext jaxb = JAXBContext.newInstance(collectivePackage);
- return jaxb.createMarshaller();
- }
- public static Unmarshaller getUnmarshaller() throws JAXBException
- {
- JAXBContext jaxb = JAXBContext.newInstance(collectivePackage);
- Unmarshaller un = jaxb.createUnmarshaller();
- return un;
- }
-
/**
* Parse the XACML Authorization Decision Query from the Dom Element
* @param samlRequest
@@ -79,7 +66,7 @@
{
//We reparse it because the document may have issues with namespaces
String elementString = DocumentUtil.getDOMElementAsString(samlRequest);
- Unmarshaller um = SOAPSAMLXACMLUtil.getUnmarshaller();
+ Unmarshaller um = JAXBUtil.getUnmarshaller(collectivePackage);
um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
JAXBElement<?> obj = (JAXBElement<?>) um.unmarshal(new
StringReader(elementString));
@@ -95,7 +82,7 @@
return of.createXACMLAuthzDecisionStatementType();
}
- private static String getPackage()
+ public static String getPackage()
{
StringBuffer buf = new StringBuffer();
buf.append(SOAP_PKG).append(COLON).append(SAML_PROTO_PKG).append(COLON);
Modified:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/xmlenc/factories/XMLEncryptionFactory.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/xmlenc/factories/XMLEncryptionFactory.java 2009-06-09
15:15:52 UTC (rev 597)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/xmlenc/factories/XMLEncryptionFactory.java 2009-06-09
23:21:28 UTC (rev 598)
@@ -21,10 +21,6 @@
*/
package org.jboss.identity.federation.core.xmlenc.factories;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
import org.jboss.identity.xmlsec.w3.xmlenc.ObjectFactory;
@@ -41,12 +37,4 @@
{
return factory;
}
-
- public static Marshaller getMarshaller() throws JAXBException
- {
- JAXBContext jc =
JAXBContext.newInstance("org.jboss.identity.xmlsec.w3.xmlenc");
- Marshaller marshaller = jc.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
- return marshaller;
- }
}
\ No newline at end of file