Author: jonananas
Date: 2011-05-03 04:28:09 -0400 (Tue, 03 May 2011)
New Revision: 922
Added:
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/identity/
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/identity/seam/
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/ConfigurationTestCase.java
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java
picketlink-seam/trunk/picketlink-seam/src/test/resources/external-authentication-config.out.xml
picketlink-seam/trunk/picketlink-seam/src/test/resources/external-authentication-config.xml
picketlink-seam/trunk/picketlink-seam/src/test/resources/picketlink_test_keystore.jks
Removed:
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java
Modified:
picketlink-seam/trunk/
picketlink-seam/trunk/picketlink-seam/
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/Configuration.java
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/OpenIdConfiguration.java
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlConfiguration.java
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/ServiceProvider.java
Log:
PLFED-180
seam-sp crashes on missing defaultIdentityProvider even though it is marked as optional
PLFED-181
Leading slash of saml-entitites.xml, external-authentication.xml and
external-authentication.xsd does not work in ear (or unit test)
- New ConfigurationTestCase
- defaultIdentityProvider is now optional
- defaultOpenIdProvider is now optional
- Path to external-authentication-config.xml now has no leading /
- Path to external-authentication-config.xsd now has no leading /
- Path to saml-entities.xml now has no leading /
Property changes on: picketlink-seam/trunk
___________________________________________________________________
Modified: svn:ignore
- .classpath
.settings
target
target-eclipse
eclipse-target
generated-source
+ .classpath
.settings
target
target-eclipse
eclipse-target
generated-source
.project
Property changes on: picketlink-seam/trunk/picketlink-seam
___________________________________________________________________
Added: svn:ignore
+ target
.classpath
.project
.settings
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/Configuration.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/Configuration.java 2011-05-03
07:04:35 UTC (rev 921)
+++
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/Configuration.java 2011-05-03
08:28:09 UTC (rev 922)
@@ -45,6 +45,7 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.web.ServletContexts;
+import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.util.StringUtil;
import
org.picketlink.identity.seam.federation.jaxb.config.ExternalAuthenticationConfigType;
import org.picketlink.identity.seam.federation.jaxb.config.ServiceProviderType;
@@ -62,14 +63,16 @@
@Import("org.picketlink.identity.seam.federation")
public class Configuration
{
- private final static String CONFIGURATION_FILE =
"/external-authentication-config.xml";
+ private static final String SCHEMA_CONFIG_EXTERNAL_AUTHENTICATION_CONFIG_XSD =
"schema/config/external-authentication-config.xsd";
+ private final static String CONFIGURATION_FILE =
"external-authentication-config.xml";
+
private String contextRoot;
private Map<String, ServiceProvider> serviceProviderMap = new HashMap<String,
ServiceProvider>();
@Create
- public void init()
+ public void init() throws ConfigurationException
{
List<ServiceProvider> serviceProviders = new
LinkedList<ServiceProvider>();
ExternalAuthenticationConfigType externalAuthenticationConfig =
readConfigurationFile();
@@ -90,14 +93,14 @@
}
}
- private ExternalAuthenticationConfigType readConfigurationFile()
+ private ExternalAuthenticationConfigType readConfigurationFile() throws
ConfigurationException
{
ExternalAuthenticationConfigType externalAuthenticationConfig;
try
{
JAXBContext jaxbContext =
JAXBContext.newInstance("org.picketlink.identity.seam.federation.jaxb.config");
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- URL schemaURL = PicketLinkSeamUtil.loadResource(getClass(),
"/schema/config/external-authentication-config.xsd" );
+ URL schemaURL =
loadResourceThrowIfNotFound(SCHEMA_CONFIG_EXTERNAL_AUTHENTICATION_CONFIG_XSD);
Schema schema;
try
{
@@ -109,7 +112,7 @@
}
unmarshaller.setSchema(schema);
- JAXBElement<?> o = (JAXBElement<?>) unmarshaller.unmarshal(
PicketLinkSeamUtil.loadResource( getClass(), CONFIGURATION_FILE));
+ JAXBElement<?> o = (JAXBElement<?>) unmarshaller.unmarshal(
loadResourceThrowIfNotFound(CONFIGURATION_FILE));
externalAuthenticationConfig = (ExternalAuthenticationConfigType) o.getValue();
}
catch (JAXBException e)
@@ -119,6 +122,14 @@
return externalAuthenticationConfig;
}
+ private URL loadResourceThrowIfNotFound(String resource) throws
ConfigurationException
+ {
+ URL url = PicketLinkSeamUtil.loadResource(getClass(), resource );
+ if (url == null)
+ throw new ConfigurationException("Resource \"" + resource +
"\" could not be loaded");
+ return url;
+ }
+
public static Configuration instance()
{
return (Configuration) Component.getInstance(Configuration.class);
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/OpenIdConfiguration.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/OpenIdConfiguration.java 2011-05-03
07:04:35 UTC (rev 921)
+++
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/OpenIdConfiguration.java 2011-05-03
08:28:09 UTC (rev 922)
@@ -40,7 +40,8 @@
public OpenIdConfiguration(OpenIdConfigType openIdConfig)
{
attributes = openIdConfig.getAttribute();
- defaultOpenIdProvider = StringUtil.getSystemPropertyAsString(
openIdConfig.getDefaultOpenIdProvider() );
+ if (openIdConfig.getDefaultOpenIdProvider() != null)
+ defaultOpenIdProvider =
StringUtil.getSystemPropertyAsString(openIdConfig.getDefaultOpenIdProvider());
}
public List<OpenIdAttributeType> getAttributes()
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlConfiguration.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlConfiguration.java 2011-05-03
07:04:35 UTC (rev 921)
+++
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlConfiguration.java 2011-05-03
08:28:09 UTC (rev 922)
@@ -37,6 +37,7 @@
import java.util.List;
import java.util.Map;
+import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
import org.picketlink.identity.federation.core.util.StringUtil;
import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntitiesDescriptorType;
@@ -55,7 +56,7 @@
*/
public class SamlConfiguration
{
- private static final String SAML_ENTITIES_FILE = "/saml-entities.xml";
+ private static final String SAML_ENTITIES_FILE = "saml-entities.xml";
private Map<String, IDPSSODescriptorType> idpMetaInfo = new HashMap<String,
IDPSSODescriptorType>();
@@ -73,24 +74,24 @@
private X509Certificate certificate;
- public SamlConfiguration(SamlConfigType samlConfig)
+ public SamlConfiguration(SamlConfigType samlConfig) throws ConfigurationException
{
readSamlMetaInformation();
- this.entityId = StringUtil.getSystemPropertyAsString(
samlConfig.getServiceProviderEntityId() );
+ this.entityId =
StringUtil.getSystemPropertyAsString(samlConfig.getServiceProviderEntityId());
this.authnRequestsSigned = samlConfig.isAuthnRequestsSigned();
this.wantAssertionsSigned = samlConfig.isWantAssertionsSigned();
for (SamlIdentityProviderType samlIdp : samlConfig.getSamlIdentityProvider())
{
- String entityID = StringUtil.getSystemPropertyAsString( samlIdp.getEntityId()
);
- IDPSSODescriptorType idpSsoDescriptor = idpMetaInfo.get( entityID );
+ String entityID = StringUtil.getSystemPropertyAsString(samlIdp.getEntityId());
+ IDPSSODescriptorType idpSsoDescriptor = idpMetaInfo.get(entityID);
if (idpSsoDescriptor == null)
{
throw new RuntimeException("Saml identity provider with entity id
\"" + entityID
+ "\" not found in metadata.");
}
- SamlIdentityProvider samlIdentityProvider = new SamlIdentityProvider( entityID,
idpSsoDescriptor);
+ SamlIdentityProvider samlIdentityProvider = new SamlIdentityProvider(entityID,
idpSsoDescriptor);
identityProviders.add(samlIdentityProvider);
samlIdentityProvider.setWantSingleLogoutMessagesSigned(samlIdp.isWantSingleLogoutMessagesSigned());
@@ -108,8 +109,9 @@
wantAuthnRequestsSigned = true;
}
}
- String entityID = StringUtil.getSystemPropertyAsString(
identityProvider.getEntityId() );
- if ( entityID.equals( StringUtil.getSystemPropertyAsString(
samlConfig.getDefaultIdentityProvider() )))
+ String entityID =
StringUtil.getSystemPropertyAsString(identityProvider.getEntityId());
+ if (samlConfig.getDefaultIdentityProvider() != null
+ &&
entityID.equals(StringUtil.getSystemPropertyAsString(samlConfig.getDefaultIdentityProvider())))
{
defaultIdentityProvider = identityProvider;
}
@@ -121,10 +123,10 @@
"Configuration error: at least one identity provider wants the
authentication requests signed, but the service provider doesn't sign authentication
requests.");
}
- String keyStoreUrl = StringUtil.getSystemPropertyAsString(
samlConfig.getKeyStoreUrl() );
- String keyStorePass = StringUtil.getSystemPropertyAsString(
samlConfig.getKeyStorePass() );
- String signingKeyAlias = StringUtil.getSystemPropertyAsString(
samlConfig.getSigningKeyAlias() );
- String signingKeyPass = StringUtil.getSystemPropertyAsString(
samlConfig.getSigningKeyPass() );
+ String keyStoreUrl =
StringUtil.getSystemPropertyAsString(samlConfig.getKeyStoreUrl());
+ String keyStorePass =
StringUtil.getSystemPropertyAsString(samlConfig.getKeyStorePass());
+ String signingKeyAlias =
StringUtil.getSystemPropertyAsString(samlConfig.getSigningKeyAlias());
+ String signingKeyPass =
StringUtil.getSystemPropertyAsString(samlConfig.getSigningKeyPass());
if (signingKeyPass == null)
{
signingKeyPass = keyStorePass;
@@ -137,13 +139,13 @@
{
try
{
- InputStream samlEntitiesStream = PicketLinkSeamUtil.loadResourceAsStream(
getClass(), SAML_ENTITIES_FILE );
- if( samlEntitiesStream == null )
- throw new RuntimeException( "SAML Entities File is missing" );
-
+ InputStream samlEntitiesStream =
PicketLinkSeamUtil.loadResourceAsStream(getClass(), SAML_ENTITIES_FILE);
+ if (samlEntitiesStream == null)
+ throw new RuntimeException("SAML Entities File is missing");
+
SAMLParser samlParser = new SAMLParser();
- EntitiesDescriptorType entitiesDescriptor = (EntitiesDescriptorType)
samlParser.parse( samlEntitiesStream );
-
+ EntitiesDescriptorType entitiesDescriptor = (EntitiesDescriptorType)
samlParser.parse(samlEntitiesStream);
+
/*JAXBContext jaxbContext =
JAXBContext.newInstance("org.picketlink.identity.federation.saml.v2.metadata");
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
JAXBElement<?> o = (JAXBElement<?>)
unmarshaller.unmarshal(getClass().getResource(SAML_ENTITIES_FILE));
@@ -151,7 +153,7 @@
*/
readEntitiesDescriptor(entitiesDescriptor);
}
- catch ( Exception e)
+ catch (Exception e)
{
throw new RuntimeException(e);
}
@@ -159,23 +161,23 @@
private void readEntitiesDescriptor(EntitiesDescriptorType entitiesDescriptor)
{
- for (Object object : entitiesDescriptor.getEntityDescriptor() )
+ for (Object object : entitiesDescriptor.getEntityDescriptor())
{
if (object instanceof EntityDescriptorType)
{
EntityDescriptorType entityDescriptor = (EntityDescriptorType) object;
String entityId = entityDescriptor.getEntityID();
-
- for( EDTChoiceType edt: entityDescriptor.getChoiceType() )
+
+ for (EDTChoiceType edt : entityDescriptor.getChoiceType())
{
List<EDTDescriptorChoiceType> descriptors = edt.getDescriptors();
- for( EDTDescriptorChoiceType edtDesc : descriptors )
+ for (EDTDescriptorChoiceType edtDesc : descriptors)
{
IDPSSODescriptorType idpSSODesc = edtDesc.getIdpDescriptor();
- if( idpSSODesc != null )
- {
+ if (idpSSODesc != null)
+ {
idpMetaInfo.put(entityId, idpSSODesc);
- }
+ }
}
}
@@ -197,7 +199,7 @@
}
}
- private void getSigningKeyPair(String keyStoreUrl, String keyStorePass, String
signingKeyAlias, String signingKeyPass)
+ private void getSigningKeyPair(String keyStoreUrl, String keyStorePass, String
signingKeyAlias, String signingKeyPass) throws ConfigurationException
{
final String classPathPrefix = "classpath:";
@@ -207,13 +209,15 @@
InputStream keyStoreStream;
if (keyStoreUrl.startsWith(classPathPrefix))
{
- keyStoreStream = PicketLinkSeamUtil.loadResourceAsStream( getClass(),
+ keyStoreStream = PicketLinkSeamUtil.loadResourceAsStream(getClass(),
keyStoreUrl.substring(classPathPrefix.length()));
}
else
{
keyStoreStream = new URL(keyStoreUrl).openStream();
}
+ if (keyStoreStream == null)
+ throw new ConfigurationException("Could not load keystore resource
\"" + keyStoreUrl + "\"");
char[] keyStorePwd = keyStorePass != null ? keyStorePass.toCharArray() : null;
keyStore.load(keyStoreStream, keyStorePwd);
@@ -291,7 +295,7 @@
if (identityProvider instanceof SamlIdentityProvider)
{
SamlIdentityProvider samlIdentityProvider = (SamlIdentityProvider)
identityProvider;
- if ( StringUtil.getSystemPropertyAsString( samlIdentityProvider.getEntityId()
).equals(entityId))
+ if
(StringUtil.getSystemPropertyAsString(samlIdentityProvider.getEntityId()).equals(entityId))
{
return samlIdentityProvider;
}
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/ServiceProvider.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/ServiceProvider.java 2011-05-03
07:04:35 UTC (rev 921)
+++
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/ServiceProvider.java 2011-05-03
08:28:09 UTC (rev 922)
@@ -28,6 +28,7 @@
import org.jboss.seam.core.Expressions;
import org.jboss.seam.core.Expressions.MethodExpression;
+import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.util.StringUtil;
import org.picketlink.identity.seam.federation.ExternalAuthenticationService;
import org.picketlink.identity.seam.federation.jaxb.config.ServiceProviderType;
@@ -60,7 +61,7 @@
private MethodExpression<Boolean> internalAuthenticationMethod;
- public ServiceProvider(Configuration configuration, ServiceProviderType
serviceProvider)
+ public ServiceProvider(Configuration configuration, ServiceProviderType
serviceProvider) throws ConfigurationException
{
this.configuration = configuration;
Added:
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/ConfigurationTestCase.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/ConfigurationTestCase.java
(rev 0)
+++
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/ConfigurationTestCase.java 2011-05-03
08:28:09 UTC (rev 922)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.picketlink.test.identity.seam.federation;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.picketlink.identity.seam.federation.configuration.Configuration;
+import org.picketlink.identity.seam.federation.configuration.SamlConfiguration;
+import org.picketlink.identity.seam.federation.configuration.ServiceProvider;
+
+/**
+ * @author Jonas Andersson
+ * @since 29 apr 2011
+ */
+public class ConfigurationTestCase
+{
+ @Test
+ public void shouldReadSamlEntitiesWithoutDefaultIDP() throws Exception
+ {
+ Configuration config = new Configuration();
+ config.init();
+ ServiceProvider serviceProvider =
config.getServiceProvider("localhost");
+ assertNull(serviceProvider.getSamlConfiguration().getDefaultIdentityProvider());
+ assertNull(serviceProvider.getOpenIdConfiguration().getDefaultOpenIdProvider());
+ }
+}
Deleted:
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java 2011-05-03
07:04:35 UTC (rev 921)
+++
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java 2011-05-03
08:28:09 UTC (rev 922)
@@ -1,103 +0,0 @@
-/*
- * 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.picketlink.test.identity.seam.federation;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
-import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntitiesDescriptorType;
-import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
-import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType.EDTChoiceType;
-import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType.EDTDescriptorChoiceType;
-import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.IDPSSODescriptorType;
-import org.picketlink.identity.seam.federation.configuration.SamlConfiguration;
-
-/**
- * Unit test the {@link SamlConfiguration} class
- * @author Anil.Saldhana(a)redhat.com
- * @since Feb 7, 2011
- */
-public class SamlConfigurationUnitTestCase
-{
- private Map<String, IDPSSODescriptorType> idpMetaInfo = new HashMap<String,
IDPSSODescriptorType>();
-
- @Test
- public void testSamlConfig() throws Exception
- {
- InputStream samlEntitiesStream =
Thread.currentThread().getContextClassLoader().getResourceAsStream(
"saml-entities.xml" );
- if( samlEntitiesStream == null )
- throw new RuntimeException( "SAML Entities File is missing" );
-
- SAMLParser samlParser = new SAMLParser();
- EntitiesDescriptorType entitiesDescriptor = (EntitiesDescriptorType)
samlParser.parse( samlEntitiesStream );
- assertNotNull( entitiesDescriptor );
- readEntitiesDescriptor(entitiesDescriptor);
- assertTrue( idpMetaInfo.keySet().size() > 0 );
- }
-
- private void readEntitiesDescriptor(EntitiesDescriptorType entitiesDescriptor)
- {
- for (Object object : entitiesDescriptor.getEntityDescriptor() )
- {
- if (object instanceof EntityDescriptorType)
- {
- EntityDescriptorType entityDescriptor = (EntityDescriptorType) object;
- String entityId = entityDescriptor.getEntityID();
-
- for( EDTChoiceType edt: entityDescriptor.getChoiceType() )
- {
- List<EDTDescriptorChoiceType> descriptors = edt.getDescriptors();
- for( EDTDescriptorChoiceType edtDesc : descriptors )
- {
- IDPSSODescriptorType idpSSODesc = edtDesc.getIdpDescriptor();
- if( idpSSODesc != null )
- {
- idpMetaInfo.put(entityId, idpSSODesc);
- }
- }
- }
-
- /*for (RoleDescriptorType roleDescriptor : entityDescriptor.getC
- .getRoleDescriptorOrIDPSSODescriptorOrSPSSODescriptor())
- {
- if (roleDescriptor instanceof IDPSSODescriptorType)
- {
- IDPSSODescriptorType IDPSSODescriptor = (IDPSSODescriptorType)
roleDescriptor;
- idpMetaInfo.put(entityId, IDPSSODescriptor);
- }
- }*/
- }
- else
- {
- EntitiesDescriptorType descriptor = (EntitiesDescriptorType) object;
- readEntitiesDescriptor(descriptor);
- }
- }
- }
-}
\ No newline at end of file
Added:
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java
(rev 0)
+++
picketlink-seam/trunk/picketlink-seam/src/test/java/org/picketlink/test/identity/seam/federation/SamlConfigurationUnitTestCase.java 2011-05-03
08:28:09 UTC (rev 922)
@@ -0,0 +1,110 @@
+/*
+ * 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.picketlink.test.identity.seam.federation;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import static org.hamcrest.CoreMatchers.*;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntitiesDescriptorType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType.EDTChoiceType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType.EDTDescriptorChoiceType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.IDPSSODescriptorType;
+import org.picketlink.identity.seam.federation.configuration.Configuration;
+import org.picketlink.identity.seam.federation.configuration.SamlConfiguration;
+import org.picketlink.identity.seam.federation.configuration.SamlIdentityProvider;
+import org.picketlink.identity.seam.federation.configuration.ServiceProvider;
+import org.picketlink.identity.seam.federation.jaxb.config.SamlConfigType;
+
+/**
+ * Unit test the {@link SamlConfiguration} class
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 7, 2011
+ */
+public class SamlConfigurationUnitTestCase
+{
+ private Map<String, IDPSSODescriptorType> idpMetaInfo = new HashMap<String,
IDPSSODescriptorType>();
+
+ @Test
+ public void testSamlConfig() throws Exception
+ {
+ InputStream samlEntitiesStream =
Thread.currentThread().getContextClassLoader().getResourceAsStream(
"saml-entities.xml" );
+ if( samlEntitiesStream == null )
+ throw new RuntimeException( "SAML Entities File is missing" );
+
+ SAMLParser samlParser = new SAMLParser();
+ EntitiesDescriptorType entitiesDescriptor = (EntitiesDescriptorType)
samlParser.parse( samlEntitiesStream );
+ assertNotNull( entitiesDescriptor );
+ readEntitiesDescriptor(entitiesDescriptor);
+ assertTrue( idpMetaInfo.keySet().size() > 0 );
+ }
+
+ private void readEntitiesDescriptor(EntitiesDescriptorType entitiesDescriptor)
+ {
+ for (Object object : entitiesDescriptor.getEntityDescriptor() )
+ {
+ if (object instanceof EntityDescriptorType)
+ {
+ EntityDescriptorType entityDescriptor = (EntityDescriptorType) object;
+ String entityId = entityDescriptor.getEntityID();
+
+ for( EDTChoiceType edt: entityDescriptor.getChoiceType() )
+ {
+ List<EDTDescriptorChoiceType> descriptors = edt.getDescriptors();
+ for( EDTDescriptorChoiceType edtDesc : descriptors )
+ {
+ IDPSSODescriptorType idpSSODesc = edtDesc.getIdpDescriptor();
+ if( idpSSODesc != null )
+ {
+ idpMetaInfo.put(entityId, idpSSODesc);
+ }
+ }
+ }
+
+ /*for (RoleDescriptorType roleDescriptor : entityDescriptor.getC
+ .getRoleDescriptorOrIDPSSODescriptorOrSPSSODescriptor())
+ {
+ if (roleDescriptor instanceof IDPSSODescriptorType)
+ {
+ IDPSSODescriptorType IDPSSODescriptor = (IDPSSODescriptorType)
roleDescriptor;
+ idpMetaInfo.put(entityId, IDPSSODescriptor);
+ }
+ }*/
+ }
+ else
+ {
+ EntitiesDescriptorType descriptor = (EntitiesDescriptorType) object;
+ readEntitiesDescriptor(descriptor);
+ }
+ }
+ }
+}
\ No newline at end of file
Added:
picketlink-seam/trunk/picketlink-seam/src/test/resources/external-authentication-config.out.xml
===================================================================
Added:
picketlink-seam/trunk/picketlink-seam/src/test/resources/external-authentication-config.xml
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/test/resources/external-authentication-config.xml
(rev 0)
+++
picketlink-seam/trunk/picketlink-seam/src/test/resources/external-authentication-config.xml 2011-05-03
08:28:09 UTC (rev 922)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ExternalAuthenticationConfig
+ xmlns="urn:picketlink:identity-federation:seam:config:1.0"
xmlns:tns="urn:picketlink:identity-federation:seam:config:1.0">
+ <!--
+ Service provider running at localhost. Uses an IDP selected by the
+ user (SAML or OpenID)
+ -->
+ <ServiceProvider protocol="http" hostname="localhost"
+ unsolicitedAuthenticationUrl="http://saml.picketlink.org:8080/seam-sp/PublicPage.seam"
+ loggedOutUrl="http://localhost:8080/seam-sp/PublicPage.seam"
+ failedAuthenticationUrl="http://localhost:8080/seam-sp/FailedAuthenticationPage.seam"
+ internalAuthenticationMethod="#{authenticator.internalAuthenticate}">
+ <SamlConfig serviceProviderEntityId="http://localhost:8080/seam-sp"
+ keyStoreUrl="classpath:picketlink_test_keystore.jks"
keyStorePass="store456"
+ signingKeyAlias="servercert" signingKeyPass="pass456">
+ <SamlIdentityProvider entityId="http://idp.ssocircle.com" />
+ <SamlIdentityProvider entityId="http://localhost:8888/opensso" />
+ </SamlConfig>
+ <OpenIdConfig>
+ <Attribute Alias="name"
TypeUri="http://schema.openid.net/namePerson"
+ Required="true" />
+ <Attribute Alias="email"
TypeUri="http://schema.openid.net/contact/email"
+ Required="true" />
+ </OpenIdConfig>
+ </ServiceProvider>
+ <!--
+ Service provider running at
saml.picketlink.org (map this hostname to
+ 127.0.0.1 in /etc/hosts). Uses one SAML identity provider: SSOCircle.
+ -->
+ <ServiceProvider protocol="http" hostname="saml.picketlink.org"
+ unsolicitedAuthenticationUrl="http://saml.picketlink.org:8080/seam-sp/PublicPage.seam"
+ loggedOutUrl="http://saml.picketlink.org:8080/seam-sp/PublicPage.seam"
+ failedAuthenticationUrl="http://saml.picketlink.org:8080/seam-sp/FailedAuthenticationPage.seam"
+ internalAuthenticationMethod="#{authenticator.internalAuthenticate}">
+ <SamlConfig
serviceProviderEntityId="http://saml.picketlink.org:8080/seam-sp"
+ authnRequestsSigned="false"
defaultIdentityProvider="http://idp.ssocircle.com"
+ keyStoreUrl="classpath:picketlink_test_keystore.jks"
keyStorePass="store456"
+ signingKeyAlias="servercert" signingKeyPass="pass456">
+ <SamlIdentityProvider entityId="http://idp.ssocircle.com" />
+ </SamlConfig>
+ </ServiceProvider>
+ <!--
+ Service provider running at
openid.picketlink.org (map this hostname
+ to 127.0.0.1 in /etc/hosts). Uses one OpenID identity provider:
+ Google.
+ -->
+ <ServiceProvider protocol="http"
hostname="openid.picketlink.org"
+ unsolicitedAuthenticationUrl="http://saml.picketlink.org:8080/seam-sp/PublicPage.seam"
+ loggedOutUrl="http://openid.picketlink.org:8080/seam-sp/PublicPage.seam"
+ failedAuthenticationUrl="http://openid.picketlink.org:8080/seam-sp/FailedAuthenticationPage.seam"
+ internalAuthenticationMethod="#{authenticator.internalAuthenticate}">
+ <OpenIdConfig
defaultOpenIdProvider="https://www.google.com/accounts/o8/id" />
+ </ServiceProvider>
+ <ServiceProvider protocol="http"
hostname="facebook.picketlink.org"
+ unsolicitedAuthenticationUrl="http://facebook.picketlink.org:8080/seam-sp/PublicPage.seam"
+ loggedOutUrl="http://facebook.picketlink.org:8080/seam-sp/PublicPage.seam"
+ failedAuthenticationUrl="http://facebook.picketlink.org:8080/seam-sp/FailedAuthenticationPage.seam"
+ internalAuthenticationMethod="#{authenticator.internalAuthenticate}">
+ <FacebookConfig clientId="156872394341240"
+ clientSecret="7b6919b80e544f0faf2ee05875f48f46" scope="email
publish_stream"/>
+ </ServiceProvider>
+</ExternalAuthenticationConfig>
Added:
picketlink-seam/trunk/picketlink-seam/src/test/resources/picketlink_test_keystore.jks
===================================================================
(Binary files differ)
Property changes on:
picketlink-seam/trunk/picketlink-seam/src/test/resources/picketlink_test_keystore.jks
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream