Commit f224e938 authored by michael.simon's avatar michael.simon
Browse files

many more changes coming

parent 9181e7e4
...@@ -19,8 +19,13 @@ import javax.ejb.Singleton; ...@@ -19,8 +19,13 @@ import javax.ejb.Singleton;
import javax.ejb.Startup; import javax.ejb.Startup;
import javax.inject.Inject; import javax.inject.Inject;
import net.shibboleth.utilities.java.support.xml.BasicParserPool;
import net.shibboleth.utilities.java.support.xml.ParserPool;
import org.opensaml.core.config.ConfigurationService;
import org.opensaml.core.config.InitializationException; import org.opensaml.core.config.InitializationException;
import org.opensaml.core.config.InitializationService; import org.opensaml.core.config.InitializationService;
import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
import org.slf4j.Logger; import org.slf4j.Logger;
import edu.kit.scc.webreg.drools.BpmProcessService; import edu.kit.scc.webreg.drools.BpmProcessService;
...@@ -133,6 +138,7 @@ public class ApplicationBootstrap { ...@@ -133,6 +138,7 @@ public class ApplicationBootstrap {
try { try {
logger.info("OpenSAML Bootstrap..."); logger.info("OpenSAML Bootstrap...");
InitializationService.initialize(); InitializationService.initialize();
} catch (InitializationException e) { } catch (InitializationException e) {
logger.error("Serious Error happened", e); logger.error("Serious Error happened", e);
} }
......
...@@ -14,16 +14,16 @@ import javax.enterprise.context.ApplicationScoped; ...@@ -14,16 +14,16 @@ import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import org.opensaml.messaging.context.MessageContext; import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.encoder.MessageEncoder;
import org.opensaml.messaging.encoder.MessageEncodingException; import org.opensaml.messaging.encoder.MessageEncodingException;
import org.opensaml.profile.action.MessageEncoderFactory;
import org.opensaml.saml.common.SAMLObject; import org.opensaml.saml.common.SAMLObject;
import org.opensaml.saml.common.messaging.context.SAMLBindingContext; import org.opensaml.saml.common.messaging.context.SAMLEndpointContext;
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
import org.opensaml.saml.common.xml.SAMLConstants; import org.opensaml.saml.common.xml.SAMLConstants;
import org.opensaml.saml.saml2.binding.encoding.impl.HTTPRedirectDeflateEncoder; import org.opensaml.saml.saml2.binding.encoding.impl.HTTPRedirectDeflateEncoder;
import org.opensaml.saml.saml2.core.AuthnRequest; import org.opensaml.saml.saml2.core.AuthnRequest;
import org.opensaml.saml.saml2.core.NameID;
import org.opensaml.saml.saml2.metadata.EntityDescriptor; import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.opensaml.saml.saml2.metadata.SingleSignOnService; import org.opensaml.saml.saml2.metadata.SingleSignOnService;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -48,7 +48,7 @@ public class Saml2RedirectService { ...@@ -48,7 +48,7 @@ public class Saml2RedirectService {
public void redirectClient(SamlIdpMetadataEntity idpEntity, public void redirectClient(SamlIdpMetadataEntity idpEntity,
SamlSpConfigurationEntity spEntity, HttpServletResponse response) SamlSpConfigurationEntity spEntity, HttpServletResponse response)
throws MessageEncodingException { throws MessageEncodingException, ComponentInitializationException {
EntityDescriptor entityDesc = samlHelper.unmarshal( EntityDescriptor entityDesc = samlHelper.unmarshal(
idpEntity.getEntityDescriptor(), EntityDescriptor.class); idpEntity.getEntityDescriptor(), EntityDescriptor.class);
...@@ -58,15 +58,22 @@ public class Saml2RedirectService { ...@@ -58,15 +58,22 @@ public class Saml2RedirectService {
spEntity.getEntityId(), spEntity.getAcs(), SAMLConstants.SAML2_POST_BINDING_URI); spEntity.getEntityId(), spEntity.getAcs(), SAMLConstants.SAML2_POST_BINDING_URI);
logger.debug("Sending client to idp {} endpoint {}", idpEntity.getEntityId(), sso.getLocation()); logger.debug("Sending client to idp {} endpoint {}", idpEntity.getEntityId(), sso.getLocation());
MessageContext<AuthnRequest> messageContext = new MessageContext<AuthnRequest>();
SAMLBindingContext bindingContext = new SAMLBindingContext(); MessageContext<SAMLObject> messageContext = new MessageContext<SAMLObject>();
bindingContext.setBindingDescriptor(sso); messageContext.setMessage(authnRequest);
SAMLPeerEntityContext entityContext = new SAMLPeerEntityContext();
entityContext.setEntityId(idpEntity.getEntityId());
SAMLEndpointContext endpointContext = new SAMLEndpointContext();
endpointContext.setEndpoint(sso);
entityContext.addSubcontext(endpointContext);
messageContext.addSubcontext(entityContext);
HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder(); HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
messageContext.setMessage(authnRequest); encoder.setHttpServletResponse(response);
messageContext. setPeerEntityEndpoint(sso); encoder.setMessageContext(messageContext);
//messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, true)); encoder.initialize();
encoder.encode(messageContext); encoder.prepareContext();
encoder.encode();
} }
......
...@@ -25,11 +25,16 @@ import javax.inject.Named; ...@@ -25,11 +25,16 @@ import javax.inject.Named;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import net.shibboleth.utilities.java.support.xml.BasicParserPool; import net.shibboleth.utilities.java.support.xml.BasicParserPool;
import net.shibboleth.utilities.java.support.xml.ParserPool;
import net.shibboleth.utilities.java.support.xml.XMLParserException; import net.shibboleth.utilities.java.support.xml.XMLParserException;
import org.opensaml.core.config.Configuration; import org.opensaml.core.config.Configuration;
import org.opensaml.core.config.ConfigurationService;
import org.opensaml.core.xml.XMLObject; import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.XMLObjectBuilder; import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.XMLObjectBuilderFactory;
import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.io.Marshaller; import org.opensaml.core.xml.io.Marshaller;
import org.opensaml.core.xml.io.MarshallerFactory; import org.opensaml.core.xml.io.MarshallerFactory;
import org.opensaml.core.xml.io.MarshallingException; import org.opensaml.core.xml.io.MarshallingException;
...@@ -63,6 +68,7 @@ public class SamlHelper implements Serializable { ...@@ -63,6 +68,7 @@ public class SamlHelper implements Serializable {
protected MarshallerFactory marshallerFactory; protected MarshallerFactory marshallerFactory;
protected UnmarshallerFactory unmarshallerFactory; protected UnmarshallerFactory unmarshallerFactory;
protected BasicParserPool basicParserPool; protected BasicParserPool basicParserPool;
protected XMLObjectBuilderFactory builderFactory;
@PostConstruct @PostConstruct
public void init() { public void init() {
...@@ -72,10 +78,21 @@ public class SamlHelper implements Serializable { ...@@ -72,10 +78,21 @@ public class SamlHelper implements Serializable {
logger.error("No SecureRandomIdentifierGenerator available", e); logger.error("No SecureRandomIdentifierGenerator available", e);
} }
marshallerFactory = Configuration.getMarshallerFactory();
unmarshallerFactory = Configuration.getUnmarshallerFactory();
basicParserPool = new BasicParserPool(); basicParserPool = new BasicParserPool();
basicParserPool.setNamespaceAware(true); basicParserPool.setNamespaceAware(true);
XMLObjectProviderRegistry registry;
synchronized(ConfigurationService.class) {
registry = ConfigurationService.get(XMLObjectProviderRegistry.class);
if (registry == null) {
registry = new XMLObjectProviderRegistry();
ConfigurationService.register(XMLObjectProviderRegistry.class, registry);
}
}
registry.setParserPool(basicParserPool);
marshallerFactory = registry.getMarshallerFactory();
unmarshallerFactory = registry.getUnmarshallerFactory();
} }
public String getRandomId() { public String getRandomId() {
...@@ -85,15 +102,13 @@ public class SamlHelper implements Serializable { ...@@ -85,15 +102,13 @@ public class SamlHelper implements Serializable {
@SuppressWarnings ("unchecked") @SuppressWarnings ("unchecked")
public <T> T create (Class<T> cls, QName qname) public <T> T create (Class<T> cls, QName qname)
{ {
return (T) ((XMLObjectBuilder<?>) Configuration.getBuilderFactory() return (T) ((XMLObjectBuilder<?>) builderFactory.getBuilder(qname)).buildObject(qname);
.getBuilder(qname)).buildObject(qname);
} }
@SuppressWarnings ("unchecked") @SuppressWarnings ("unchecked")
public <T> T create (Class<T> cls, QName typeName, QName qname) public <T> T create (Class<T> cls, QName typeName, QName qname)
{ {
return (T) ((XMLObjectBuilder<?>) Configuration.getBuilderFactory() return (T) ((XMLObjectBuilder<?>) builderFactory.getBuilder(typeName)).buildObject(qname, typeName);
.getBuilder(typeName)).buildObject(qname, typeName);
} }
public <T extends XMLObject> String marshal(T t) { public <T extends XMLObject> String marshal(T t) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment