[localhost-startStop-1] DEBUG s.exe.StSBroker - StSBroker.init ()
[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - --cfg.getKeystoreResource () != null-- true
[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - --cfg.getPrivateKeyPassword ()-- pac4j-demo-passwd
[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - cfg.getIdentityProviderMetadataResource ().exists () 0 -> true
[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - cfg.getServiceProviderMetadataResource ().exists () -> true
[localhost-startStop-1] INFO org.pac4j.saml.util.Configuration - Bootstrapping OpenSAML configuration via Pac4j...
[localhost-startStop-1] INFO org.opensaml.core.config.InitializationService - Initializing OpenSAML using the Java Services API
[localhost-startStop-1] DEBUG org.opensaml.core.config.InitializationService - Initializing module initializer implementation: org.opensaml.core.xml.config.XMLObjectProviderInitializer
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - XMLObjectProviderRegistry did not exist in ConfigurationService, will be created
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer - Loading XMLObject provider configuration from resource 'default-config.xml'
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Loading configuration from XML Document
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Schema validating configuration Document
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Configuration document validated
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Preparing to load ObjectProviders
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - ObjectProviders load complete
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer - Loading XMLObject provider configuration from resource 'schema-config.xml'
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Loading configuration from XML Document
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Schema validating configuration Document
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Configuration document validated
[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - Preparing to load ObjectProviders
[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.MarshallerFactory - Registering marshaller, org.opensaml.core.xml.schema.impl.XSAnyMarshaller, for object type {
http://www.w3.org/2001/XMLSchema}anyType[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSAnyUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}anyType[localhost-startStop-1] DEBUG org.opensaml.core.xml.XMLObjectBuilderFactory - Registering builder org.opensaml.core.xml.schema.impl.XSStringBuilder under key {
http://www.w3.org/2001/XMLSchema}string[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.MarshallerFactory - Registering marshaller, org.opensaml.core.xml.schema.impl.XSStringMarshaller, for object type {
http://www.w3.org/2001/XMLSchema}string[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSStringUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}string[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.MarshallerFactory - Registering marshaller, org.opensaml.core.xml.schema.impl.XSDateTimeMarshaller, for object type {
http://www.w3.org/2001/XMLSchema}dateTime[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSDateTimeUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}dateTime[localhost-startStop-1] DEBUG org.opensaml.core.xml.XMLObjectBuilderFactory - Registering builder org.opensaml.core.xml.schema.impl.XSQNameBuilder under key {
http://www.w3.org/2001/XMLSchema}QName[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.MarshallerFactory - Registering marshaller, org.opensaml.core.xml.schema.impl.XSQNameMarshaller, for object type {
http://www.w3.org/2001/XMLSchema}QName[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSQNameUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}QName[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSBase64BinaryUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}base64Binary[localhost-startStop-1] DEBUG org.opensaml.core.xml.XMLObjectBuilderFactory - Registering builder org.opensaml.core.xml.schema.impl.XSIntegerBuilder under key {
http://www.w3.org/2001/XMLSchema}integer[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.MarshallerFactory - Registering marshaller, org.opensaml.core.xml.schema.impl.XSIntegerMarshaller, for object type {
http://www.w3.org/2001/XMLSchema}integer[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSIntegerUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}integer[localhost-startStop-1] DEBUG org.opensaml.core.xml.XMLObjectBuilderFactory - Registering builder org.opensaml.core.xml.schema.impl.XSURIBuilder under key {
http://www.w3.org/2001/XMLSchema}anyURI[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.MarshallerFactory - Registering marshaller, org.opensaml.core.xml.schema.impl.XSURIMarshaller, for object type {
http://www.w3.org/2001/XMLSchema}anyURI[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSURIUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}anyURI[localhost-startStop-1] DEBUG org.opensaml.core.xml.XMLObjectBuilderFactory - Registering builder org.opensaml.core.xml.schema.impl.XSBooleanBuilder under key {
http://www.w3.org/2001/XMLSchema}boolean[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.MarshallerFactory - Registering marshaller, org.opensaml.core.xml.schema.impl.XSBooleanMarshaller, for object type {
http://www.w3.org/2001/XMLSchema}boolean[localhost-startStop-1] DEBUG org.opensaml.core.xml.io.UnmarshallerFactory - Registering unmarshaller, org.opensaml.core.xml.schema.impl.XSBooleanUnmarshaller, for object type, {
http://www.w3.org/2001/XMLSchema}boolean[localhost-startStop-1] DEBUG org.opensaml.core.xml.config.XMLConfigurator - ObjectProviders load complete
[localhost-startStop-1] DEBUG org.opensaml.core.config.InitializationService - Initializing module initializer implementation: org.opensaml.core.xml.config.GlobalParserPoolInitializer
[localhost-startStop-1] DEBUG org.opensaml.core.config.InitializationService - Initializing module initializer implementation: org.opensaml.core.metrics.impl.MetricRegistryInitializer
[localhost-startStop-1] DEBUG org.opensaml.core.metrics.impl.MetricRegistryInitializer - MetricRegistry did not exist in ConfigurationService, a disabled one will be created
(saml2Client.getServiceProviderMetadataResolver () == null)
[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - (saml2Client.getServiceProviderMetadataResolver () == null)
[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - [[[[[[[[[[[[[[[[ **** ]]]]]]]]]]]]]]] ServiceProviderEntityId -> urn:mace:saml:
pac4j.org[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - [[[[[[[[[[[[[[[[ **** ]]]]]]]]]]]]]]] ServiceProviderMetadataResource != null
(saml2Client.getServiceProviderMetadataResolver () == null)
[localhost-startStop-1] DEBUG s.exe.SAMLConfigFactory - (saml2Client.getServiceProviderMetadataResolver () == null)
nov 19, 2017 8:33:51 PM org.apache.catalina.core.ApplicationContext log
INFORMACIÓN: No Spring WebApplicationInitializer types detected on classpath
nov 19, 2017 8:33:51 PM org.apache.coyote.AbstractProtocol start
INFORMACIÓN: Starting ProtocolHandler ["http-bio-8080"]
nov 19, 2017 8:33:51 PM org.apache.coyote.AbstractProtocol start
INFORMACIÓN: Starting ProtocolHandler ["ajp-bio-8009"]
nov 19, 2017 8:33:51 PM org.apache.catalina.startup.Catalina start
INFORMACIÓN: Server startup in 11368 ms
StSBroker.doFilter
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - StSBroker.doFilter ()
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () -> PARAMETER -> client_name -> VALOR -> SAML2Client
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () -> config != null
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () -> (saml2Client != null)
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () - saml2Client.getConfiguration ().getServiceProviderEntityId () -> urn:mace:saml:
pac4j.org[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () - saml2Client.getConfiguration ().getKeyStoreAlias () -> saml2clientconfiguration
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () - saml2Client.getConfiguration ().getKeystorePassword () -> pac4j-demo-passwd
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () - saml2Client.getIdentityProviderMetadataResolver () != null -> false
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () - saml2Client.getConfiguration ().getIdentityProviderMetadataResource () != null -> true
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - profile.isPresent () -> false
[http-bio-8080-exec-4] DEBUG s.exe.StSBroker - En StSBroker.doFilter () -> No profile -> redirect
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.impl.KeyStoreCredentialResolver - Building credential from keystore entry for entityID saml2clientconfiguration, usage type UNSPECIFIED
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.impl.KeyStoreCredentialResolver - Processing PrivateKeyEntry from keystore
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Loading default evaluable credential criteria mappings
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableX509DigestCredentialCriterion as evaluator for class org.opensaml.security.x509.X509DigestCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluablePublicKeyCredentialCriterion as evaluator for class org.opensaml.security.criteria.PublicKeyCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableX509IssuerSerialCredentialCriterion as evaluator for class org.opensaml.security.x509.X509IssuerSerialCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableX509SubjectKeyIdentifierCredentialCriterion as evaluator for class org.opensaml.security.x509.X509SubjectKeyIdentifierCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableKeyNameCredentialCriterion as evaluator for class org.opensaml.security.criteria.KeyNameCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableKeyAlgorithmCredentialCriterion as evaluator for class org.opensaml.security.criteria.KeyAlgorithmCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableEntityIDCredentialCriterion as evaluator for class org.opensaml.core.criterion.EntityIdCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableUsageCredentialCriterion as evaluator for class org.opensaml.security.criteria.UsageCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableKeyLengthCredentialCriterion as evaluator for class org.opensaml.security.criteria.KeyLengthCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registering class org.opensaml.security.credential.criteria.impl.EvaluableX509SubjectNameCredentialCriterion as evaluator for class org.opensaml.security.x509.X509SubjectNameCriterion
[http-bio-8080-exec-4] DEBUG org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry - Registry located evaluable criteria class org.opensaml.security.credential.criteria.impl.EvaluableEntityIDCredentialCriterion for criteria class org.opensaml.core.criterion.EntityIdCriterion
[http-bio-8080-exec-4] DEBUG org.apache.xml.security.Init - Registering default algorithms
java.lang.NullPointerException
at org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver.initMetadataResolver(DOMMetadataResolver.java:68)
at org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver.doInitialize(AbstractMetadataResolver.java:287)
at net.shibboleth.utilities.java.support.component.AbstractInitializableComponent.initialize(AbstractInitializableComponent.java:61)
at org.pac4j.saml.metadata.SAML2IdentityProviderMetadataResolver.resolve(SAML2IdentityProviderMetadataResolver.java:76)
at org.pac4j.saml.client.SAML2Client.initIdentityProviderMetadataResolver(SAML2Client.java:155)
at org.pac4j.saml.client.SAML2Client.clientInit(SAML2Client.java:100)
at org.pac4j.core.client.IndirectClient.internalInit(IndirectClient.java:51)
at org.pac4j.core.util.InitializableObject.init(InitializableObject.java:20)
at org.pac4j.core.client.IndirectClient.getRedirectAction(IndirectClient.java:82)
at org.pac4j.core.client.IndirectClient.redirect(IndirectClient.java:68)
at s.exe.StSBroker.doFilter(StSBroker.java:296)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[SAMLConfigFactory]
public Config build (Object...arg0)
{
final SAML2ClientConfiguration cfg = new SAML2ClientConfiguration ();
cfg.setKeystorePath ("file:samlKeystore.jks");
cfg.setKeystoreType ("jks");
//cfg.setKeystoreAlias ("pac4j-demo");
cfg.setKeystoreAlias ("saml2clientconfiguration"); // I don`t know why
cfg.setKeystorePassword ("pac4j-demo-passwd");
cfg.setPrivateKeyPassword ("pac4j-demo-passwd");
cfg.setIdentityProviderMetadataPath ("testshib-providers.xml");
logger.debug ("cfg.getIdentityProviderMetadataResource ().exists () 0 -> " + cfg.getIdentityProviderMetadataResource ().exists ());
cfg.setServiceProviderEntityId ("urn:mace:saml:
pac4j.org");
cfg.setForceServiceProviderMetadataGeneration (true);
cfg.setForceAuth (true);
cfg.setMaximumAuthenticationLifetime (600);
cfg.setDestinationBindingType (urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect");
final BasicSignatureSigningConfiguration signConfig = DefaultSecurityConfigurationBootstrap.buildDefaultSignatureSigningConfiguration ();
cfg.setBlackListedSignatureSigningAlgorithms (new ArrayList <> (signConfig.getBlacklistedAlgorithms ()));
cfg.setSignatureAlgorithms (new ArrayList <> (signConfig.getSignatureAlgorithms ()));
cfg.setSignatureReferenceDigestMethods (new ArrayList <> (signConfig.getSignatureReferenceDigestMethods ()));
cfg.setSignatureCanonicalizationAlgorithm (signConfig.getSignatureCanonicalizationAlgorithm ());
cfg.setWantsAssertionsSigned (false);
cfg.setForceSignRedirectBindingAuthnRequest (false);
cfg.setServiceProviderMetadataPath ("sp-metadata.xml");
cfg.setAttributeConsumingServiceIndex (1);
cfg.setAssertionConsumerServiceIndex (1);
cfg.setForceServiceProviderMetadataGeneration (true);
final SAML2Client saml2Client = new SAML2Client (cfg);
saml2Client.setName ("SAML2Client");
if (saml2Client.getServiceProviderMetadataResolver () != null)
{
System.out.println ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getEntityId ());
logger.debug ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getEntityId ());
System.out.println ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getMetadata ());
logger.debug ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getMetadata ());
}
else
{
System.out.println ("(saml2Client.getServiceProviderMetadataResolver () == null)");
logger.debug ("(saml2Client.getServiceProviderMetadataResolver () == null)");
}
final Config config = new Config (clients);
config.addAuthorizer("mustBeAuth", new IsAuthenticatedAuthorizer<>("/?mustBeAuth"));
return (config);
}
public class MySAMLConfigFactory implements ConfigFactory
{
@Override
public Config build (Object...arg0)
{
return (this.getConfig ());
}
public Config getConfig ()
{
final SAML2ClientConfiguration cfg = new SAML2ClientConfiguration ();
cfg.setKeystorePath ("file:samlKeystore.jks");
cfg.setKeystoreType ("jks");
//cfg.setKeystoreAlias ("pac4j-demo");
cfg.setKeystoreAlias ("saml2clientconfiguration"); // I don`t know why
cfg.setKeystorePassword ("pac4j-demo-passwd");
cfg.setPrivateKeyPassword ("pac4j-demo-passwd");
cfg.setIdentityProviderMetadataPath ("testshib-providers.xml");
logger.debug ("cfg.getIdentityProviderMetadataResource ().exists () 0 -> " + cfg.getIdentityProviderMetadataResource ().exists ());
cfg.setServiceProviderEntityId ("urn:mace:saml:
pac4j.org");
cfg.setForceServiceProviderMetadataGeneration (true);
cfg.setForceAuth (true);
cfg.setMaximumAuthenticationLifetime (600);
cfg.setDestinationBindingType ("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect");
final BasicSignatureSigningConfiguration signConfig = DefaultSecurityConfigurationBootstrap.buildDefaultSignatureSigningConfiguration ();
cfg.setBlackListedSignatureSigningAlgorithms (new ArrayList <> (signConfig.getBlacklistedAlgorithms ()));
cfg.setSignatureAlgorithms (new ArrayList <> (signConfig.getSignatureAlgorithms ()));
cfg.setSignatureReferenceDigestMethods (new ArrayList <> (signConfig.getSignatureReferenceDigestMethods ()));
cfg.setSignatureCanonicalizationAlgorithm (signConfig.getSignatureCanonicalizationAlgorithm ());
cfg.setWantsAssertionsSigned (false);
cfg.setForceSignRedirectBindingAuthnRequest (false);
cfg.setServiceProviderMetadataPath ("sp-metadata.xml");
cfg.setAttributeConsumingServiceIndex (1);
cfg.setAssertionConsumerServiceIndex (1);
cfg.setForceServiceProviderMetadataGeneration (true);
final SAML2Client saml2Client = new SAML2Client (cfg);
saml2Client.setName ("SAML2Client");
if (saml2Client.getServiceProviderMetadataResolver () != null)
{
System.out.println ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getEntityId ());
logger.debug ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getEntityId ());
System.out.println ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getMetadata ());
logger.debug ("getServiceProviderMetadataResolver -> " + saml2Client.getServiceProviderMetadataResolver ().getMetadata ());
}
else
{
System.out.println ("(saml2Client.getServiceProviderMetadataResolver () == null)");
logger.debug ("(saml2Client.getServiceProviderMetadataResolver () == null)");
}
final Config config = new Config (clients);
config.addAuthorizer("mustBeAuth", new IsAuthenticatedAuthorizer<>("/?mustBeAuth"));
return (config);
}
}
public class StSBroker implements javax.servlet.Filter
{
FilterConfig filterConfig = null;
ServletContext servletContext = null;
org.pac4j.core.config.Config config = null;
public void init (FilterConfig filterConfig) throws ServletException
{
try
{
this.filterConfig = filterConfig;
this.servletContext = filterConfig.getServletContext ();
this.initLog ();
logger.debug ("StSBroker.init ()");
this.config = getConfig ();
}
catch (Exception e)
{
System.out.println ("ECXEPTION StSBroker.init () -> " + e.toString ());
logger.debug ("ECXEPTION StSBroker.init () -> " + e.toString ());
e.printStackTrace();
}
}
public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
HttpServletRequest req = null;
HttpServletResponse res = null;
try
{
req = (HttpServletRequest)request;
res = (HttpServletResponse)response;
logger.debug ("StSBroker.doFilter ()");
System.out.println ("StSBroker.doFilter () - 3");
Enumeration p = request.getParameterNames ();
while (p.hasMoreElements ())
{
String key = (String)p.nextElement ();
String value = request.getParameter (key);
logger.debug (" ");
logger.debug ("StSBroker.doFilter () -> PARAMETER -> " + key + " -> VALUE -> " + value);
logger.debug (" ");
}
WebContext context = null;
if (config == null)
config = getConfig ();
try
{
////client = config.getClients ().findClient (req.getParameter ("client_name"));
////SAML2Client saml2Client = (SAML2Client)client;
SAML2Client saml2Client = (SAML2Client)(ConfigSingleton.getConfig ().getClients ().findClient (req.getParameter ("client_name")));
context = new J2EContext (req, res);
ProfileManager <CommonProfile> manager = new ProfileManager <CommonProfile> (context);
Optional<CommonProfile> profile = manager.get (true);
if (profile.isPresent ())
{
String clientName = null;
String clientId = null;
clientName = profile.get ().getClientName ();
clientId = profile.get ().getId ();
logger.debug ("StSBroker.doFilter () -> clientName -> " + clientName);
logger.debug ("StSBroker.doFilter () -> clientId -> " + clientId);
}
else
{
logger.debug ("profile.isPresent () -> " + profile.isPresent ());
logger.debug ("StSBroker.doFilter () -> No profile - redirect");
saml2Client.redirect (context);
}
}
catch (HttpAction e)
{
logger.debug ("StSBroker HttpAction Exception");
}
chain.doFilter (request, response);
return;
}
catch (Exception e)
{
logger.debug ("StSBroker Exception");
}
}
private Config getConfig ()
{
logger.debug ("StSBroker.v1 - getConfig ()");
if (config == null)
{
logger.debug ("StSBroker.v1 - getConfig () - (config == null)");
if (ConfigSingleton.getConfig ().getClients () == null)
{
logger.debug ("StSBroker.v1 - ConfigSingleton.getConfig () == null");
config = new SAMLConfigFactory ().getConfig ();
ConfigSingleton.setConfig (config);
logger.debug ("StSBroker.v1 - config = new SAMLConfigFactory ().getConfig ()");
}
else
config = ConfigSingleton.getConfig ();
}
return (config);
}
return (config);
}
}
Thank you
JON