use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class GetIDPSPPairingInCOT method getEntities.
private List getEntities(String realm, String cotName, boolean bIDP, boolean hosted) throws WorkflowException {
try {
SAML2MetaManager mgr = new SAML2MetaManager();
Set entities = getEntities(realm, cotName);
List results = new ArrayList();
for (Iterator i = entities.iterator(); i.hasNext(); ) {
String entityId = (String) i.next();
EntityConfigElement elm = mgr.getEntityConfig(realm, entityId);
if (elm.isHosted() == hosted) {
EntityDescriptorElement desc = mgr.getEntityDescriptor(realm, entityId);
if (bIDP) {
if (SAML2MetaUtils.getIDPSSODescriptor(desc) != null) {
results.add(entityId);
}
} else {
if (SAML2MetaUtils.getSPSSODescriptor(desc) != null) {
results.add(entityId);
}
}
}
}
return results;
} catch (SAML2MetaException ex) {
throw new WorkflowException(ex.getMessage());
}
}
use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class GetIDPSPPairingInCOT method getHostedSPMetaAlias.
private List getHostedSPMetaAlias(String realm, List hostedSP) throws WorkflowException {
try {
List list = new ArrayList();
SAML2MetaManager mgr = new SAML2MetaManager();
for (Iterator i = hostedSP.iterator(); i.hasNext(); ) {
String e = (String) i.next();
SPSSOConfigElement cfg = mgr.getSPSSOConfig(realm, e);
list.add(e + "(" + cfg.getMetaAlias() + ")");
}
return list;
} catch (SAML2MetaException ex) {
throw new WorkflowException(ex.getMessage());
}
}
use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class GetIDPSPPairingInCOT method getHostedIDPMetaAlias.
private List getHostedIDPMetaAlias(String realm, List hostedIDP) throws WorkflowException {
try {
List list = new ArrayList();
SAML2MetaManager mgr = new SAML2MetaManager();
for (Iterator i = hostedIDP.iterator(); i.hasNext(); ) {
String e = (String) i.next();
IDPSSOConfigElement cfg = mgr.getIDPSSOConfig(realm, e);
list.add(e + "(" + cfg.getMetaAlias() + ")");
}
return list;
} catch (SAML2MetaException ex) {
throw new WorkflowException(ex.getMessage());
}
}
use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class ImportSAML2MetaData method importData.
/**
* Imports meta and extended metadata.
*
* @param realm Realm of the entity.
* @param metadata Meta data.
* @param extended extended data.
* @return realm and entity ID.
*/
public static String[] importData(String realm, String metadata, String extended) throws WorkflowException {
String entityID = null;
try {
SAML2MetaManager metaManager = new SAML2MetaManager();
EntityConfigElement configElt = null;
if (extended != null) {
Object obj = SAML2MetaUtils.convertStringToJAXB(extended);
configElt = (obj instanceof EntityConfigElement) ? (EntityConfigElement) obj : null;
if (configElt != null && configElt.isHosted()) {
List config = configElt.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
if (!config.isEmpty()) {
BaseConfigType bConfig = (BaseConfigType) config.iterator().next();
realm = SAML2MetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
}
}
}
// Load the metadata if it has been provided
if (metadata != null) {
entityID = importSAML2MetaData(metaManager, realm, metadata);
}
// Load the extended metadata if it has been provided
if (configElt != null) {
metaManager.createEntityConfig(realm, configElt);
}
} catch (SAML2MetaException e) {
DEBUG.error("An error occurred while importing the SAML metadata", e);
throw new WorkflowException(e.getMessage());
} catch (JAXBException e) {
DEBUG.error("An error occurred while importing the SAML metadata", e);
throw new WorkflowException(e.getMessage());
}
String[] results = { realm, entityID };
return results;
}
use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class Task method generateMetaAliasForIDP.
static String generateMetaAliasForIDP(String realm) throws WorkflowException {
try {
Set metaAliases = new HashSet();
SAML2MetaManager mgr = new SAML2MetaManager();
metaAliases.addAll(mgr.getAllHostedIdentityProviderMetaAliases(realm));
metaAliases.addAll(mgr.getAllHostedServiceProviderMetaAliases(realm));
String metaAliasBase = (realm.equals("/")) ? "/idp" : realm + "/idp";
String metaAlias = metaAliasBase;
int counter = 1;
while (metaAliases.contains(metaAlias)) {
metaAlias = metaAliasBase + Integer.toString(counter);
counter++;
}
return metaAlias;
} catch (SAML2MetaException e) {
throw new WorkflowException(e.getMessage());
}
}
Aggregations