* @return
* @throws ConfigurationException
*/
public static SPType getSPConfiguration(EntitiesDescriptorType entitiesDescriptor, String bindingURI)
throws ConfigurationException {
SPType spType = new SPType();
List<Object> list = entitiesDescriptor.getEntityDescriptor();
IDPSSODescriptorType idpSSO = null;
SPSSODescriptorType spSSO = null;
if (list != null) {
for (Object theObject : list) {
if (theObject instanceof EntitiesDescriptorType) {
spType = getSPConfiguration((EntitiesDescriptorType) theObject, bindingURI);
} else if (theObject instanceof EntityDescriptorType) {
if (idpSSO == null) {
// Ideally we should lookup the IDP metadata considering the specs. For now the IDP metadata must be
// defined within the SP metadata file.
idpSSO = getIDPDescriptor((EntityDescriptorType) theObject);
}
if (spSSO == null) {
spSSO = getSPDescriptor((EntityDescriptorType) theObject);
}
}
}
if (idpSSO == null) {
throw logger.samlMetaDataNoIdentityProviderDefined();
}
if (spSSO == null) {
throw logger.samlMetaDataNoServiceProviderDefined();
}
String identityURL = getIdentityURL(idpSSO, bindingURI);
if (identityURL == null) {
throw logger.samlMetaDataNoIdentityProviderDefined();
}
spType.setIdentityURL(identityURL);
spType.setLogoutUrl(getLogoutURL(idpSSO, bindingURI));
spType.setLogoutResponseLocation(getLogoutResponseLocation(idpSSO, bindingURI));
String serviceURL = getServiceURL(spSSO, bindingURI);
if (serviceURL == null) {
throw logger.samlMetaDataNoServiceProviderDefined();
}
spType.setServiceURL(serviceURL);
}
return spType;
}