use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method createEntityConfig.
/**
* Creates the extended entity configuration under the realm.
*
* @param realm The realm under which the entity configuration will be
* created.
* @param entityConfig extended entity configuration to be created.
* @throws IDFFMetaException if unable to create the entity configuration.
*/
public void createEntityConfig(String realm, EntityConfigElement entityConfig) throws IDFFMetaException {
String classMethod = "IDFFMetaManager.createEntityConfig:";
String entityID = null;
if (entityConfig == null) {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_CONFIG, null);
throw new IDFFMetaException("nullEntityConfig", null);
} else {
entityID = entityConfig.getEntityID();
if (entityID == null) {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
debug.error(classMethod + "entity ID is null");
throw new IDFFMetaException("nullEntityID", null);
}
}
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
String[] args = { entityID, realm };
try {
Map attrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_ENTITY_CONFIG_ATTR, entityConfig);
Map origAttrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
if (origAttrs == null) {
if (debug.messageEnabled()) {
debug.message(classMethod + "Entity Descriptor for" + entityID + " does not exist");
}
LogUtil.error(Level.INFO, LogUtil.ENTITY_CONFIG_NOT_FOUND, args);
throw new IDFFMetaException("noEntityDescriptor", args);
}
Set origValues = (Set) origAttrs.get(IDFF_ENTITY_CONFIG_ATTR);
if (!origValues.isEmpty()) {
if (debug.messageEnabled()) {
debug.message(classMethod + "Entity Config exists. " + "Use setEntityConfig to set the configuration");
}
LogUtil.error(Level.INFO, LogUtil.ENTITY_CONFIG_EXISTS, args);
throw new IDFFMetaException("entityConfigExists", args);
}
if (debug.messageEnabled()) {
debug.message(classMethod + "Entity Config Attrs :" + attrs);
}
idffMetaConfigInstance.setConfiguration(realm, entityID, attrs);
// add entity to the circle of trust
addEntityToCOT(realm, entityID);
LogUtil.access(Level.INFO, LogUtil.CREATE_ENTITY_CONFIG_SUCCEEDED, args);
} catch (ConfigurationException ce) {
debug.error(classMethod + "Cannot create entity config", ce);
LogUtil.error(Level.INFO, LogUtil.CREATE_ENTITY_CONFIG_FAILED, args);
throw new IDFFMetaException(ce);
} catch (UnsupportedOperationException uoe) {
debug.error(classMethod + "Unsupported operation");
LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, args);
throw new IDFFMetaException(uoe);
} catch (JAXBException jaxbe) {
debug.error(classMethod, jaxbe);
LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_CONFIG, args);
throw new IDFFMetaException("invalidEntityConfig", args);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method setEntityConfig.
/**
* Sets the extended entity configuration under the realm.
* The EntityConfig should exist in order to set attributes in
* the EntityConfig.
*
* @param realm The realm under which the entity resides in
* @param entityConfig The extended entity configuration object to be set.
* @throws IDFFMetaException if unable to set the entity configuration.
*/
public void setEntityConfig(String realm, EntityConfigElement entityConfig) throws IDFFMetaException {
String classMethod = "IDFFMetaManager:setEntityConfig";
if (entityConfig != null) {
String entityID = entityConfig.getEntityID();
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
Map origEntityAttrs = null;
String[] args = { entityID, realm };
try {
if (entityID != null) {
origEntityAttrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
Map newAttrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_ENTITY_CONFIG_ATTR, entityConfig);
origEntityAttrs.put(IDFF_ENTITY_CONFIG_ATTR, newAttrs.get(IDFF_ENTITY_CONFIG_ATTR));
} else {
if (debug.messageEnabled()) {
debug.message(classMethod + "Entity Identifier is null");
}
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
throw new IDFFMetaException("nullEntityID", null);
}
idffMetaConfigInstance.setConfiguration(realm, entityID, origEntityAttrs);
LogUtil.access(Level.INFO, LogUtil.SET_ENTITY_CONFIG_SUCCEEDED, args);
} catch (ConfigurationException ce) {
debug.error("Error setting Entity Descriptor ", ce);
LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_CONFIG_FAILED, args);
throw new IDFFMetaException(ce);
} catch (JAXBException jaxbe) {
debug.error(classMethod, jaxbe);
LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_CONFIG, args);
throw new IDFFMetaException("invalidEntityConfig", args);
}
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method createEntityDescriptor.
/**
* Creates the standard metadata entity descriptor.
* The metadata is created under the realm.
*
* @param realm The realm under which the entity resides.
* @param entityDescriptor The standard entity descriptor object to
* be created.
* @throws IDFFMetaException if unable to create the entity descriptor.
*/
public void createEntityDescriptor(String realm, EntityDescriptorElement entityDescriptor) throws IDFFMetaException {
String classMethod = "IDFFMetaManager.createEntityDescriptor:";
String entityId = null;
if (entityDescriptor == null) {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_DESCRIPTOR, null);
throw new IDFFMetaException("nullEntityDescriptor", null);
} else {
entityId = entityDescriptor.getProviderID();
if (entityId == null) {
debug.error(classMethod + "Entity ID is null");
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
throw new IDFFMetaException("nullEntityID", null);
}
}
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
String[] args = { entityId, realm };
EntityDescriptorElement descriptor = getEntityDescriptor(realm, entityId);
if (descriptor != null) {
List idps = descriptor.getIDPDescriptor();
boolean hasIDP = (idps != null) && !idps.isEmpty();
List sps = descriptor.getSPDescriptor();
boolean hasSP = (sps != null) && !sps.isEmpty();
List newIDPs = entityDescriptor.getIDPDescriptor();
List newSPs = entityDescriptor.getSPDescriptor();
if ((newIDPs != null) && !newIDPs.isEmpty() && hasIDP) {
LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
throw new IDFFMetaException("idpAlreadyExisted", args);
}
if ((newSPs != null) && !newSPs.isEmpty() && hasSP) {
LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
throw new IDFFMetaException("spAlreadyExisted", args);
}
idps.addAll(newIDPs);
sps.addAll(newSPs);
setEntityDescriptor(realm, descriptor);
} else {
try {
Map attrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_METADATA_ATTR, entityDescriptor);
if (debug.messageEnabled()) {
debug.message(classMethod + attrs);
}
idffMetaConfigInstance.createConfiguration(realm, entityId, attrs);
LogUtil.access(Level.INFO, LogUtil.CREATE_ENTITY_SUCCEEDED, args);
} catch (ConfigurationException ce) {
debug.error("Cannot create entity descriptor", ce);
LogUtil.error(Level.INFO, LogUtil.CREATE_ENTITY_FAILED, args);
throw new IDFFMetaException(ce);
} catch (UnsupportedOperationException uoe) {
debug.error("Creating EntityDescriptor : Unsupported operation");
LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, null);
throw new IDFFMetaException("unsupportedOperation", null);
} catch (JAXBException jaxbe) {
debug.error(classMethod, 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 getAllHostedEntities.
/**
* Returns all remote entities under the realm.
*
* @param realm The realm under which the hosted entities reside.
* @return a <code>List</code> of entity identifiers as Strings.
* @throws IDFFMetaException if unable to retrieve the remote entity
* identifiers.
*/
public List getAllHostedEntities(String realm) throws IDFFMetaException {
List hostedEntityList = new ArrayList();
try {
Set entityIDs = idffMetaConfigInstance.getAllConfigurationNames(realm);
if (entityIDs != null && !entityIDs.isEmpty()) {
Iterator entityIterator = entityIDs.iterator();
while (entityIterator.hasNext()) {
String entityID = (String) entityIterator.next();
EntityConfigElement entityConfig = getEntityConfig(realm, entityID);
if (entityConfig != null && entityConfig.isHosted()) {
hostedEntityList.add(entityID);
}
}
}
LogUtil.access(Level.INFO, LogUtil.GET_HOSTED_ENTITIES_SUCCEEDED, null);
} catch (ConfigurationException e) {
debug.error("IDFFMetaManager.getAllHostedEntities:", e);
LogUtil.error(Level.INFO, LogUtil.GET_HOSTED_ENTITIES_FAILED, null);
throw new IDFFMetaException(e);
}
return hostedEntityList;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager method deleteEntityConfig.
/**
* Deletes the extended entity configuration.
* @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 IDFFMetaException if unable to delete the entity descriptor.
*/
public void deleteEntityConfig(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);
}
Set oldValues = (Set) oldAttrs.get(IDFF_ENTITY_CONFIG_ATTR);
if (oldValues == null || oldValues.isEmpty()) {
LogUtil.error(Level.INFO, LogUtil.NO_ENTITY_CONFIG_TO_DELETE, args);
throw new IDFFMetaException("noEntityConfig", args);
}
removeEntityFromCOT(realm, entityId);
Set attr = new HashSet();
attr.add(IDFF_ENTITY_CONFIG_ATTR);
idffMetaConfigInstance.deleteConfiguration(realm, entityId, attr);
LogUtil.access(Level.INFO, LogUtil.DELETE_ENTITY_CONFIG_SUCCEEDED, args);
IDFFMetaCache.setEntityConfig(realm, entityId, null);
} catch (ConfigurationException e) {
debug.error("IDFFMetaManager.deleteEntityConfig:", e);
LogUtil.error(Level.INFO, LogUtil.DELETE_ENTITY_CONFIG_FAILED, args);
throw new IDFFMetaException(e);
} catch (UnsupportedOperationException uoe) {
debug.error("Unsupported operation", uoe);
LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, null);
throw new IDFFMetaException("unsupportedOperation", null);
}
}
}
Aggregations