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;
import javax.ejb.Startup;
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.InitializationService;
import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
import org.slf4j.Logger;
import edu.kit.scc.webreg.drools.BpmProcessService;
......@@ -133,6 +138,7 @@ public class ApplicationBootstrap {
try {
logger.info("OpenSAML Bootstrap...");
InitializationService.initialize();
} catch (InitializationException e) {
logger.error("Serious Error happened", e);
}
......
......@@ -14,16 +14,16 @@ import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.encoder.MessageEncoder;
import org.opensaml.messaging.encoder.MessageEncodingException;
import org.opensaml.profile.action.MessageEncoderFactory;
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.saml2.binding.encoding.impl.HTTPRedirectDeflateEncoder;
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.SingleSignOnService;
import org.slf4j.Logger;
......@@ -48,7 +48,7 @@ public class Saml2RedirectService {
public void redirectClient(SamlIdpMetadataEntity idpEntity,
SamlSpConfigurationEntity spEntity, HttpServletResponse response)
throws MessageEncodingException {
throws MessageEncodingException, ComponentInitializationException {
EntityDescriptor entityDesc = samlHelper.unmarshal(
idpEntity.getEntityDescriptor(), EntityDescriptor.class);
......@@ -58,15 +58,22 @@ public class Saml2RedirectService {
spEntity.getEntityId(), spEntity.getAcs(), SAMLConstants.SAML2_POST_BINDING_URI);
logger.debug("Sending client to idp {} endpoint {}", idpEntity.getEntityId(), sso.getLocation());
MessageContext<AuthnRequest> messageContext = new MessageContext<AuthnRequest>();
SAMLBindingContext bindingContext = new SAMLBindingContext();
bindingContext.setBindingDescriptor(sso);
MessageContext<SAMLObject> messageContext = new MessageContext<SAMLObject>();
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();
messageContext.setMessage(authnRequest);
messageContext. setPeerEntityEndpoint(sso);
//messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, true));
encoder.encode(messageContext);
encoder.setHttpServletResponse(response);
encoder.setMessageContext(messageContext);
encoder.initialize();
encoder.prepareContext();
encoder.encode();
}
......
......@@ -25,11 +25,16 @@ import javax.inject.Named;
import javax.xml.namespace.QName;
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 org.opensaml.core.config.Configuration;
import org.opensaml.core.config.ConfigurationService;
import org.opensaml.core.xml.XMLObject;
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.MarshallerFactory;
import org.opensaml.core.xml.io.MarshallingException;
......@@ -63,6 +68,7 @@ public class SamlHelper implements Serializable {
protected MarshallerFactory marshallerFactory;
protected UnmarshallerFactory unmarshallerFactory;
protected BasicParserPool basicParserPool;
protected XMLObjectBuilderFactory builderFactory;
@PostConstruct
public void init() {
......@@ -72,10 +78,21 @@ public class SamlHelper implements Serializable {
logger.error("No SecureRandomIdentifierGenerator available", e);
}
marshallerFactory = Configuration.getMarshallerFactory();
unmarshallerFactory = Configuration.getUnmarshallerFactory();
basicParserPool = new BasicParserPool();
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() {
......@@ -85,15 +102,13 @@ public class SamlHelper implements Serializable {
@SuppressWarnings ("unchecked")
public <T> T create (Class<T> cls, QName qname)
{
return (T) ((XMLObjectBuilder<?>) Configuration.getBuilderFactory()
.getBuilder(qname)).buildObject(qname);
return (T) ((XMLObjectBuilder<?>) builderFactory.getBuilder(qname)).buildObject(qname);
}
@SuppressWarnings ("unchecked")
public <T> T create (Class<T> cls, QName typeName, QName qname)
{
return (T) ((XMLObjectBuilder<?>) Configuration.getBuilderFactory()
.getBuilder(typeName)).buildObject(qname, typeName);
return (T) ((XMLObjectBuilder<?>) builderFactory.getBuilder(typeName)).buildObject(qname, typeName);
}
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