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);
}
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class IDFFMetaManager 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 identifiers as Strings.
* @throws IDFFMetaException if unable to retrieve the remote entity
* identifiers.
*/
public List getAllRemoteEntities(String realm) throws IDFFMetaException {
List remoteEntityList = 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()) {
remoteEntityList.add(entityID);
}
}
}
LogUtil.access(Level.INFO, LogUtil.GET_REMOTE_ENTITIES_SUCCEEDED, null);
} catch (ConfigurationException e) {
debug.error("IDFFMetaManager.getAllRemoteEntities:", e);
LogUtil.error(Level.INFO, LogUtil.GET_REMOTE_ENTITIES_FAILED, null);
throw new IDFFMetaException(e);
}
return remoteEntityList;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager 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 WSFederationMetaException if unable to retrieve the entity ids.
*/
public String getEntityByMetaAlias(String metaAlias) throws WSFederationMetaException {
String realm = WSFederationMetaUtils.getRealmByMetaAlias(metaAlias);
try {
Set entityIds = configInst.getAllConfigurationNames(realm);
if (entityIds == null || entityIds.isEmpty()) {
return null;
}
for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
String federationId = (String) iter.next();
FederationConfigElement config = getEntityConfig(realm, federationId);
if (config == null) {
continue;
}
List list = config.getIDPSSOConfigOrSPSSOConfig();
for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
BaseConfigType bConfig = (BaseConfigType) iter2.next();
String cMetaAlias = bConfig.getMetaAlias();
if (cMetaAlias != null && cMetaAlias.equals(metaAlias)) {
return federationId;
}
}
}
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.getEntityByMetaAlias:", e);
throw new WSFederationMetaException(e);
}
return null;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager method createEntityConfig.
/**
* Creates the extended entity configuration under the realm.
*
* @param realm The realm under which the entity configuration will be
* created.
* @param config The extended entity configuration object to be created.
* @throws WSFederationMetaException if unable to create the entity
* configuration.
*/
public void createEntityConfig(String realm, FederationConfigElement config) throws WSFederationMetaException {
String federationId = config.getFederationID();
if (federationId == null) {
debug.error("WSFederationMetaManager.createEntityConfig: " + "entity ID is null");
String[] data = { realm };
LogUtil.error(Level.INFO, LogUtil.NO_ENTITY_ID_CREATE_ENTITY_CONFIG, data, null);
throw new WSFederationMetaException("empty_entityid", null);
}
if (realm == null) {
realm = "/";
}
String[] objs = { federationId, realm };
try {
Map attrs = WSFederationMetaUtils.convertJAXBToAttrMap(ATTR_ENTITY_CONFIG, config);
Map oldAttrs = configInst.getConfiguration(realm, federationId);
if (oldAttrs == null) {
LogUtil.error(Level.INFO, LogUtil.NO_ENTITY_DESCRIPTOR_CREATE_ENTITY_CONFIG, objs, null);
throw new WSFederationMetaException("entity_descriptor_not_exist", objs);
}
Set oldValues = (Set) oldAttrs.get(ATTR_ENTITY_CONFIG);
if (oldValues != null && !oldValues.isEmpty()) {
LogUtil.error(Level.INFO, LogUtil.ENTITY_CONFIG_EXISTS, objs, null);
throw new WSFederationMetaException("entity_config_exists", objs);
}
configInst.setConfiguration(realm, federationId, attrs);
LogUtil.access(Level.INFO, LogUtil.ENTITY_CONFIG_CREATED, objs, null);
// Add the entity to cot
SPSSOConfigElement spconfig = getSPSSOConfig(realm, federationId);
if (spconfig != null) {
addToCircleOfTrust(spconfig, realm, federationId);
}
IDPSSOConfigElement idpconfig = getIDPSSOConfig(realm, federationId);
if (idpconfig != null) {
addToCircleOfTrust(idpconfig, realm, federationId);
}
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.createEntityConfig:", e);
String[] data = { e.getMessage(), federationId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_CREATE_ENTITY_CONFIG, data, null);
throw new WSFederationMetaException(e);
} catch (JAXBException jaxbe) {
debug.error("WSFederationMetaManager.createEntityConfig:", jaxbe);
LogUtil.error(Level.INFO, LogUtil.CREATE_INVALID_ENTITY_CONFIG, objs, null);
throw new WSFederationMetaException("invalid_config", objs);
}
}
Aggregations