use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.
the class SAML2MetaManager method getAuthnAuthorityConfig.
/**
* Returns first authentication authority configuration in an entity under
* the realm.
* @param realm The realm under which the entity resides.
* @param entityId ID of the entity to be retrieved.
* @return <code>AuthnAuthorityConfigElement</code> for the entity or
* null if not found.
* @throws SAML2MetaException if unable to retrieve the first authentication
* authority configuration.
*/
public AuthnAuthorityConfigElement getAuthnAuthorityConfig(String realm, String entityId) throws SAML2MetaException {
EntityConfigElement eConfig = getEntityConfig(realm, entityId);
if (eConfig == null) {
return null;
}
List list = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
Object obj = iter.next();
if (obj instanceof AuthnAuthorityConfigElement) {
return (AuthnAuthorityConfigElement) obj;
}
}
return null;
}
use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.
the class SAML2MetaManager method getAllRemoteEntities.
/**
* Returns all remote entities under the realm.
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of entity ID <code>String</code>.
* @throws SAML2MetaException if unable to retrieve the entity ids.
*/
public List getAllRemoteEntities(String realm) throws SAML2MetaException {
List remoteEntityIds = new ArrayList();
String[] objs = { realm };
try {
Set entityIds = configInst.getAllConfigurationNames(realm);
if (entityIds != null && !entityIds.isEmpty()) {
for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
String entityId = (String) iter.next();
EntityConfigElement config = getEntityConfig(realm, entityId);
if (config == null || !config.isHosted()) {
remoteEntityIds.add(entityId);
}
}
}
} catch (ConfigurationException e) {
debug.error("SAML2MetaManager.getAllRemoteEntities:", e);
String[] data = { e.getMessage(), realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_REMOTE_ENTITIES, data, null);
throw new SAML2MetaException(e);
}
LogUtil.access(Level.FINE, LogUtil.GOT_ALL_REMOTE_ENTITIES, objs, null);
return remoteEntityIds;
}
use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.
the class SAML2MetaManager method addToCircleOfTrust.
private void addToCircleOfTrust(String realm, String entityId, EntityConfigElement eConfig) {
try {
if (eConfig != null) {
List elist = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
// use first one to add the entity to COT
BaseConfigType config = (BaseConfigType) elist.iterator().next();
Map attr = SAML2MetaUtils.getAttributes(config);
List cotAttr = (List) attr.get(SAML2Constants.COT_LIST);
List cotList = new ArrayList(cotAttr);
if ((cotList != null) && !cotList.isEmpty()) {
for (Iterator iter = cotList.iterator(); iter.hasNext(); ) {
String cotName = ((String) iter.next()).trim();
if ((cotName != null) && (!cotName.equals(""))) {
cotm.addCircleOfTrustMember(realm, cotName, COTConstants.SAML2, entityId, false);
}
}
}
}
} catch (Exception e) {
debug.error("SAML2MetaManager.addToCircleOfTrust:" + "Error while adding entity" + entityId + "to COT.", e);
}
}
use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.
the class SAML2MetaManager method getAttributeAuthorityConfig.
/**
* Returns first attribute authority configuration in an entity under
* the realm.
* @param realm The realm under which the entity resides.
* @param entityId ID of the entity to be retrieved.
* @return <code>AttributeAuthorityConfigElement</code> for the entity or
* null if not found.
* @throws SAML2MetaException if unable to retrieve the first attribute
* authority configuration.
*/
public AttributeAuthorityConfigElement getAttributeAuthorityConfig(String realm, String entityId) throws SAML2MetaException {
EntityConfigElement eConfig = getEntityConfig(realm, entityId);
if (eConfig == null) {
return null;
}
List list = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
Object obj = iter.next();
if (obj instanceof AttributeAuthorityConfigElement) {
return (AttributeAuthorityConfigElement) obj;
}
}
return null;
}
use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.
the class SAML2MetaManager method getEntityConfig.
/**
* Returns extended entity configuration under the realm.
* @param realm The realm under which the entity resides.
* @param entityId ID of the entity to be retrieved.
* @return <code>EntityConfigElement</code> object for the entity or null
* if not found.
* @throws SAML2MetaException if unable to retrieve the entity
* configuration.
*/
public EntityConfigElement getEntityConfig(String realm, String entityId) throws SAML2MetaException {
if (entityId == null) {
return null;
}
if (realm == null) {
realm = "/";
}
String[] objs = { entityId, realm };
EntityConfigElement config = null;
if (callerSession == null) {
config = SAML2MetaCache.getEntityConfig(realm, entityId);
if (config != null) {
if (debug.messageEnabled()) {
debug.message("SAML2MetaManager.getEntityConfig: got entity" + " config from SAML2MetaCache: " + entityId);
}
LogUtil.access(Level.FINE, LogUtil.GOT_ENTITY_CONFIG, objs, null);
return config;
}
}
try {
Map attrs = configInst.getConfiguration(realm, entityId);
if (attrs == null) {
return null;
}
Set values = (Set) attrs.get(ATTR_ENTITY_CONFIG);
if (values == null || values.isEmpty()) {
return null;
}
String value = (String) values.iterator().next();
Object obj = SAML2MetaUtils.convertStringToJAXB(value);
if (obj instanceof EntityConfigElement) {
config = (EntityConfigElement) obj;
if (debug.messageEnabled()) {
debug.message("SAML2MetaManager.getEntityConfig: got " + "entity config from SMS: " + entityId);
}
SAML2MetaCache.putEntityConfig(realm, entityId, config);
LogUtil.access(Level.FINE, LogUtil.GOT_ENTITY_CONFIG, objs, null);
return config;
}
debug.error("SAML2MetaManager.getEntityConfig: invalid config");
LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_CONFIG, objs, null);
throw new SAML2MetaException("invalid_config", objs);
} catch (ConfigurationException e) {
debug.error("SAML2MetaManager.getEntityConfig:", e);
String[] data = { e.getMessage(), entityId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ENTITY_CONFIG, data, null);
throw new SAML2MetaException(e);
} catch (JAXBException jaxbe) {
debug.error("SAML2MetaManager.getEntityConfig:", jaxbe);
LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_CONFIG, objs, null);
throw new SAML2MetaException("invalid_config", objs);
}
}
Aggregations