use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SAML2MetaManager method getAllHostedMetaAliasesByRealm.
/**
* Returns all the hosted entity metaAliases for a realm.
*
* @param realm The given realm.
* @return all the hosted entity metaAliases for a realm or an empty arrayList if not found.
* @throws SAML2MetaException if unable to retrieve the entity ids.
*/
public List<String> getAllHostedMetaAliasesByRealm(String realm) throws SAML2MetaException {
List<String> metaAliases = new ArrayList<String>();
try {
Set<String> entityIds = configInst.getAllConfigurationNames(realm);
if (entityIds == null || entityIds.isEmpty()) {
return metaAliases;
}
for (String entityId : entityIds) {
EntityConfigElement config = getEntityConfig(realm, entityId);
if (config == null || !config.isHosted()) {
continue;
}
List<BaseConfigType> configList = config.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
for (BaseConfigType bConfigType : configList) {
String curMetaAlias = bConfigType.getMetaAlias();
if (curMetaAlias != null && !curMetaAlias.isEmpty()) {
metaAliases.add(curMetaAlias);
}
}
}
} catch (ConfigurationException e) {
debug.error("SAML2MetaManager.getAllHostedMetaAliasesByRealm:", e);
throw new SAML2MetaException(e);
}
return metaAliases;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SAML2MetaManager method getEntityDescriptor.
/**
* Returns the standard metadata entity descriptor under the realm.
* @param realm The realm under which the entity resides.
* @param entityId ID of the entity to be retrieved.
* @return <code>EntityDescriptorElement</code> for the entity or null if
* not found.
* @throws SAML2MetaException if unable to retrieve the entity descriptor.
*/
public EntityDescriptorElement getEntityDescriptor(String realm, String entityId) throws SAML2MetaException {
if (entityId == null) {
return null;
}
if (realm == null) {
realm = "/";
}
String[] objs = { entityId, realm };
EntityDescriptorElement descriptor = null;
if (callerSession == null) {
descriptor = SAML2MetaCache.getEntityDescriptor(realm, entityId);
if (descriptor != null) {
if (debug.messageEnabled()) {
debug.message("SAML2MetaManager.getEntityDescriptor: got " + "descriptor from SAML2MetaCache " + entityId);
}
LogUtil.access(Level.FINE, LogUtil.GOT_ENTITY_DESCRIPTOR, objs, null);
return descriptor;
}
}
try {
Map attrs = configInst.getConfiguration(realm, entityId);
if (attrs == null) {
return null;
}
Set values = (Set) attrs.get(ATTR_METADATA);
if ((values == null) || values.isEmpty()) {
return null;
}
String value = (String) values.iterator().next();
Object obj = SAML2MetaUtils.convertStringToJAXB(value);
if (obj instanceof EntityDescriptorElement) {
descriptor = (EntityDescriptorElement) obj;
SAML2MetaCache.putEntityDescriptor(realm, entityId, descriptor);
if (debug.messageEnabled()) {
debug.message("SAML2MetaManager.getEntityDescriptor: got " + "descriptor from SMS " + entityId);
}
LogUtil.access(Level.FINE, LogUtil.GOT_ENTITY_DESCRIPTOR, objs, null);
return descriptor;
}
debug.error("SAML2MetaManager.getEntityDescriptor: invalid descriptor");
LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
throw new SAML2MetaException("invalid_descriptor", objs);
} catch (ConfigurationException e) {
debug.error("SAML2MetaManager.getEntityDescriptor", e);
String[] data = { e.getMessage(), entityId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ENTITY_DESCRIPTOR, data, null);
throw new SAML2MetaException(e);
} catch (JAXBException jaxbe) {
debug.error("SAML2MetaManager.getEntityDescriptor", jaxbe);
LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
throw new SAML2MetaException("invalid_descriptor", objs);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SAML2MetaManager method getAllEntities.
/**
* Returns all entities under the realm.
* @param realm The realm under which the entities reside.
* @return a <code>Set</code> of entity ID <code>String</code>.
* @throws SAML2MetaException if unable to retrieve the entity ids.
*/
public Set getAllEntities(String realm) throws SAML2MetaException {
Set ret = new HashSet();
String[] objs = { realm };
try {
Set entityIds = configInst.getAllConfigurationNames(realm);
if (entityIds != null && !entityIds.isEmpty()) {
ret.addAll(entityIds);
}
} catch (ConfigurationException e) {
debug.error("SAML2MetaManager.getAllEntities:", e);
String[] data = { e.getMessage(), realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_ENTITIES, data, null);
throw new SAML2MetaException(e);
}
LogUtil.access(Level.FINE, LogUtil.GOT_ALL_ENTITIES, objs, null);
return ret;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SAML2MetaManager method deleteEntityConfig.
/**
* Deletes the extended entity configuration under the realm.
* @param realm The realm under which the entity resides.
* @param entityId The ID of the entity for whom the extended entity
* configuration will be deleted.
* @throws SAML2MetaException if unable to delete the entity descriptor.
*/
public void deleteEntityConfig(String realm, String entityId) throws SAML2MetaException {
if (entityId == null) {
return;
}
if (realm == null) {
realm = "/";
}
String[] objs = { entityId, realm };
try {
Map oldAttrs = configInst.getConfiguration(realm, entityId);
Set oldValues = (Set) oldAttrs.get(ATTR_ENTITY_CONFIG);
if (oldValues == null || oldValues.isEmpty()) {
LogUtil.error(Level.INFO, LogUtil.NO_ENTITY_DESCRIPTOR_DELETE_ENTITY_CONFIG, objs, null);
throw new SAML2MetaException("entity_config_not_exist", objs);
}
// Remove the entity from cot
removeFromCircleOfTrust(realm, entityId);
Set attr = new HashSet();
attr.add(ATTR_ENTITY_CONFIG);
configInst.deleteConfiguration(realm, entityId, attr);
LogUtil.access(Level.INFO, LogUtil.ENTITY_CONFIG_DELETED, objs, null);
SAML2MetaCache.putEntityConfig(realm, entityId, null);
} catch (ConfigurationException e) {
debug.error("SAML2MetaManager.deleteEntityConfig:", e);
String[] data = { e.getMessage(), entityId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_DELETE_ENTITY_CONFIG, data, null);
throw new SAML2MetaException(e);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SAML2MetaManager method getEntityByMetaAlias.
/**
* Returns entity ID associated with the metaAlias.
* @param metaAlias The metaAlias.
* @return entity ID associated with the metaAlias or null if not found.
* @throws SAML2MetaException if unable to retrieve the entity ids.
*/
public String getEntityByMetaAlias(String metaAlias) throws SAML2MetaException {
String realm = SAML2MetaUtils.getRealmByMetaAlias(metaAlias);
try {
Set entityIds = configInst.getAllConfigurationNames(realm);
if (entityIds == null || entityIds.isEmpty()) {
return null;
}
for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
String entityId = (String) iter.next();
EntityConfigElement config = getEntityConfig(realm, entityId);
if ((config == null) || !config.isHosted()) {
continue;
}
List list = config.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
BaseConfigType bConfig = (BaseConfigType) iter2.next();
String cMetaAlias = bConfig.getMetaAlias();
if (cMetaAlias != null && cMetaAlias.equals(metaAlias)) {
return entityId;
}
}
}
} catch (ConfigurationException e) {
debug.error("SAML2MetaManager.getEntityByMetaAlias:", e);
throw new SAML2MetaException(e);
}
return null;
}
Aggregations