use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method getEntityIDByMetaAlias.
/**
* Returns entity ID associated with the metaAlias.
*
* @param metaAlias The Meta Alias of the provider.
* @return entity ID associated with the metaAlias or null if not found.
* @throws IDFFMetaException if unable to retrieve the entity id.
*/
public String getEntityIDByMetaAlias(String metaAlias) throws IDFFMetaException {
try {
if (metaAlias == null || metaAlias.length() == 0) {
return null;
}
// check cache first
String entityId = IDFFMetaCache.getEntityByMetaAlias(metaAlias);
if (entityId != null) {
if (debug.messageEnabled()) {
debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " found entity in cache, metaAlias=" + metaAlias + ", ID=" + entityId);
}
return entityId;
}
String realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
Set entityIds = idffMetaConfigInstance.getAllConfigurationNames(realm);
if (entityIds == null || entityIds.isEmpty()) {
return null;
}
for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
String tmpId = (String) iter.next();
if (debug.messageEnabled()) {
debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " process entity cache for metaAlias=" + metaAlias + ", ID=" + tmpId);
}
SPDescriptorConfigElement spconfig = getSPDescriptorConfig(realm, tmpId);
if (spconfig != null) {
String tmpMetaAlias = spconfig.getMetaAlias();
if (tmpMetaAlias != null && tmpMetaAlias.length() > 0) {
if (metaAlias.equals(tmpMetaAlias)) {
// remember this and continue to process others,
entityId = tmpId;
}
IDFFMetaCache.setMetaAliasEntityMapping(tmpMetaAlias, tmpId);
IDFFMetaCache.setMetaAliasRoleMapping(tmpMetaAlias, IFSConstants.SP);
if (debug.messageEnabled()) {
debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " save to cache, metaAlias=" + tmpMetaAlias + ", ID=" + tmpId + ", role=" + IFSConstants.SP);
}
}
}
IDPDescriptorConfigElement idpconfig = getIDPDescriptorConfig(realm, tmpId);
if (idpconfig != null) {
String tmpMetaAlias = idpconfig.getMetaAlias();
if (tmpMetaAlias != null && tmpMetaAlias.length() > 0) {
if (metaAlias.equals(tmpMetaAlias)) {
// remember this and continue to process others,
entityId = tmpId;
}
IDFFMetaCache.setMetaAliasEntityMapping(tmpMetaAlias, tmpId);
IDFFMetaCache.setMetaAliasRoleMapping(tmpMetaAlias, IFSConstants.IDP);
if (debug.messageEnabled()) {
debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " save to cache, metaAlias=" + tmpMetaAlias + ", ID=" + tmpId + ", role=" + IFSConstants.IDP);
}
}
}
}
return entityId;
} catch (ConfigurationException e) {
debug.error("IDFFMetaManager.getEntityByMetaAlias:", e);
throw new IDFFMetaException(e);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method getEntityDescriptor.
/**
* Returns the standard metadata entity descriptor under the realm.
* @param realm The realm under which the entity resides.
* @param entityID identifier of the entity to be retrieved.
* @return <code>EntityDescriptorElement</code> for the entity or null if
* not found.
* @throws IDFFMetaException if unable to retrieve the entity descriptor.
*/
public EntityDescriptorElement getEntityDescriptor(String realm, String entityID) throws IDFFMetaException {
String classMethod = "IDFFMetaManager.getEntityDescriptor:";
if (debug.messageEnabled()) {
debug.message(classMethod + " Retreiving EntityDescriptor");
}
EntityDescriptorElement entityDescriptor = null;
if (entityID != null) {
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
String[] args = { entityID, realm };
// retrieve from cache
if (callerSession == null) {
entityDescriptor = IDFFMetaCache.getEntityDescriptor(realm, entityID);
}
if (entityDescriptor == null) {
try {
Map attrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
if (attrs != null) {
Set metaValues = (Set) attrs.get(IDFF_METADATA_ATTR);
if (metaValues != null && !metaValues.isEmpty()) {
String metaValue = (String) metaValues.iterator().next();
Object object = IDFFMetaUtils.convertStringToJAXB(metaValue);
if (object instanceof EntityDescriptorElement) {
entityDescriptor = (EntityDescriptorElement) object;
IDFFMetaCache.setEntityDescriptor(realm, entityID, entityDescriptor);
} else {
debug.error(classMethod + "Invalid standard " + " meta value for : " + entityID);
}
}
}
} catch (ConfigurationException ce) {
debug.error("Cannot retrieve entity descriptor", ce);
LogUtil.error(Level.INFO, LogUtil.GET_ENTITY_FAILED, args);
throw new IDFFMetaException("cannotRetreiveEntityDescriptor", null);
} catch (JAXBException jaxbe) {
debug.error(classMethod, jaxbe);
LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_DESCRIPTOR, args);
throw new IDFFMetaException("invalidEntityDescriptor", args);
}
}
if (entityDescriptor != null) {
LogUtil.access(Level.INFO, LogUtil.GET_ENTITY_SUCCEEDED, args);
}
} else {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
throw new IDFFMetaException("nullEntityID", null);
}
return entityDescriptor;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method setEntityDescriptor.
/**
* Sets the standard metadata entity descriptor under the realm.
* The EntiyDescriptor to be set should exist otherwise an error is
* thrown.
*
* @param realm The realm under which the entity resides.
* @param entityDescriptor The standard entity descriptor object to be set.
* @throws IDFFMetaException if there is an error setting the entity
* descriptor.
* @see #createEntityDescriptor(String, EntityDescriptorElement)
*/
public void setEntityDescriptor(String realm, EntityDescriptorElement entityDescriptor) throws IDFFMetaException {
String classMethod = "IDFFMetaManager:setEntityDescriptor";
if (entityDescriptor != null) {
String entityID = entityDescriptor.getProviderID();
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
String[] args = { entityID, realm };
try {
Map origEntityAttrs = null;
if (entityID != null) {
origEntityAttrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
Map newAttrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_METADATA_ATTR, entityDescriptor);
origEntityAttrs.put(IDFF_METADATA_ATTR, newAttrs.get(IDFF_METADATA_ATTR));
} else {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, args);
throw new IDFFMetaException("nullEntityID", null);
}
idffMetaConfigInstance.setConfiguration(realm, entityID, origEntityAttrs);
LogUtil.access(Level.INFO, LogUtil.SET_ENTITY_SUCCEEDED, args);
} catch (ConfigurationException ce) {
debug.error("Error setting Entity Descriptor ", ce);
LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
throw new IDFFMetaException(ce);
} catch (JAXBException jaxbe) {
debug.error(classMethod + "Invalid EntityID" + entityID, jaxbe);
LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_DESCRIPTOR, args);
throw new IDFFMetaException("invalidEntityDescriptor", args);
}
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method getEntityConfig.
/**
* Returns extended entity configuration under the realm.
*
* @param realm The realm under which the entity resides.
* @param entityID identifier of the entity whose config is to be
* retrieved.
* @return <code>EntityConfigElement</code> object of the entity or null
* if the entity configuration does not exist.
* @throws IDFFMetaException if unable to retrieve the entity
* configuration.
*/
public EntityConfigElement getEntityConfig(String realm, String entityID) throws IDFFMetaException {
String classMethod = "IDFFMetaManager:getEntityConfig:";
EntityConfigElement entityConfig = null;
if (entityID != null) {
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
String[] args = { entityID, realm };
if (callerSession == null) {
// retrieve config from cache
entityConfig = IDFFMetaCache.getEntityConfig(realm, entityID);
}
if (entityConfig == null) {
try {
Map attrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
if (attrs != null) {
Set cfgValues = (Set) attrs.get(IDFF_ENTITY_CONFIG_ATTR);
if (cfgValues != null && !cfgValues.isEmpty()) {
String cfgValue = (String) cfgValues.iterator().next();
Object object = IDFFMetaUtils.convertStringToJAXB(cfgValue);
if (object instanceof EntityConfigElement) {
entityConfig = (EntityConfigElement) object;
IDFFMetaCache.setEntityConfig(realm, entityID, entityConfig);
} else {
debug.error(classMethod + "Invalid entityID" + entityID);
}
}
}
} catch (ConfigurationException ce) {
debug.error(classMethod + "Cannot retrieve entity config", ce);
LogUtil.error(Level.INFO, LogUtil.GET_ENTITY_CONFIG_FAILED, args);
throw new IDFFMetaException("cannotRetreiveEntityConfig", null);
} catch (JAXBException jaxbe) {
debug.error(classMethod, jaxbe);
LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_CONFIG, args);
throw new IDFFMetaException("invalidEntityConfig", args);
}
}
if (entityConfig != null) {
LogUtil.access(Level.INFO, LogUtil.GET_ENTITY_CONFIG_SUCCEEDED, args);
}
} else {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
throw new IDFFMetaException("nullEntityID", null);
}
return entityConfig;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method deleteEntityDescriptor.
/**
* Deletes the standard metadata entity descriptor under the realm.
* @param realm The realm under which the entity resides.
* @param entityID identifier of the entity to be deleted.
* @throws IDFFMetaException if there is an error deleting the entity
* descriptor.
*/
public void deleteEntityDescriptor(String realm, String entityID) throws IDFFMetaException {
if (entityID == null) {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
throw new IDFFMetaException("nullEntityID", null);
} else {
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
String[] args = { entityID, realm };
try {
Map oldAttrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
if (oldAttrs == null || oldAttrs.isEmpty()) {
LogUtil.error(Level.INFO, LogUtil.ENTITY_DOES_NOT_EXISTS, args);
throw new IDFFMetaException("entityDoesNotExists", args);
}
removeEntityFromCOT(realm, entityID);
idffMetaConfigInstance.deleteConfiguration(realm, entityID, null);
LogUtil.access(Level.INFO, LogUtil.DELETE_ENTITY_SUCCEEDED, args);
IDFFMetaCache.setEntityDescriptor(realm, entityID, null);
} catch (ConfigurationException ce) {
debug.error("Error deleting Entity Descriptor" + entityID, ce);
LogUtil.error(Level.INFO, LogUtil.DELETE_ENTITY_FAILED, args);
throw new IDFFMetaException(ce);
} catch (UnsupportedOperationException uoe) {
debug.error("Unsupported operation", uoe);
LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, null);
throw new IDFFMetaException("unsupportedOperation", null);
}
}
}
Aggregations