use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager method getEntityDescriptor.
/**
* Returns the standard metadata federation element under the realm.
*
* @param realm The realm under which the federation resides.
* @param entityId ID of the federation to be retrieved.
* @return <code>FederationElement</code> for the entity or null if
* not found.
* @throws WSFederationMetaException if unable to retrieve the entity
* descriptor.
*/
public FederationElement getEntityDescriptor(String realm, String entityId) throws WSFederationMetaException {
if (entityId == null) {
return null;
}
if (realm == null) {
realm = "/";
}
String[] objs = { entityId, realm };
FederationElement federation = null;
if (callerSession == null) {
federation = WSFederationMetaCache.getFederation(realm, entityId);
if (federation != null) {
LogUtil.access(Level.FINE, LogUtil.GOT_FEDERATION, objs, null);
return federation;
}
}
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 = WSFederationMetaUtils.convertStringToJAXB(value);
if (obj instanceof FederationElement) {
federation = (FederationElement) obj;
WSFederationMetaCache.putFederation(realm, entityId, federation);
LogUtil.access(Level.FINE, LogUtil.GOT_FEDERATION, objs, null);
return federation;
}
debug.error("WSFederationMetaManager.getFederation: " + "invalid descriptor");
LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
throw new WSFederationMetaException("invalid_descriptor", objs);
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.getFederation:", e);
String[] data = { e.getMessage(), entityId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ENTITY_DESCRIPTOR, data, null);
throw new WSFederationMetaException(e);
} catch (JAXBException jaxbe) {
debug.error("WSFederationMetaManager.getFederation:", jaxbe);
LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
throw new WSFederationMetaException("invalid_descriptor", objs);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager method getAllHostedEntities.
/**
* Returns all hosted 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 WSFederationMetaException if unable to retrieve the entity ids.
*/
public List<String> getAllHostedEntities(String realm) throws WSFederationMetaException {
List<String> hostedEntityIds = new ArrayList<String>();
try {
Set entityIds = configInst.getAllConfigurationNames(realm);
if (entityIds != null && !entityIds.isEmpty()) {
for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
String federationId = (String) iter.next();
FederationConfigElement config = getEntityConfig(realm, federationId);
if (config != null && config.isHosted()) {
hostedEntityIds.add(federationId);
}
}
}
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.getAllHostedEntities:", e);
String[] data = { e.getMessage(), realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_HOSTED_ENTITIES, data, null);
throw new WSFederationMetaException(e);
}
String[] objs = { realm };
LogUtil.access(Level.FINE, LogUtil.GOT_ALL_HOSTED_ENTITIES, objs, null);
return hostedEntityIds;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager 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 WSFederationMetaException if unable to retrieve the entity ids.
*/
public List<String> getAllHostedMetaAliasesByRealm(String realm) throws WSFederationMetaException {
List<String> metaAliases = new ArrayList<String>();
try {
Set<String> entityIds = configInst.getAllConfigurationNames(realm);
if (entityIds == null || entityIds.isEmpty()) {
return metaAliases;
}
for (String entityId : entityIds) {
FederationConfigElement config = getEntityConfig(realm, entityId);
if (config == null || !config.isHosted()) {
continue;
}
List<BaseConfigType> configList = config.getIDPSSOConfigOrSPSSOConfig();
for (BaseConfigType bConfigType : configList) {
String curMetaAlias = bConfigType.getMetaAlias();
if (curMetaAlias != null && !curMetaAlias.isEmpty()) {
metaAliases.add(curMetaAlias);
}
}
}
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.getAllHostedMetaAliasesByRealm: Error getting " + "hostedMetaAliases for realm: " + realm, e);
throw new WSFederationMetaException(e);
}
return metaAliases;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager method setEntityConfig.
/**
* Sets the extended entity configuration under the realm.
*
* @param realm The realm under which the entity resides.
* @param config The extended entity configuration object to be set.
* @throws WSFederationMetaException if unable to set the entity
* configuration.
*/
public void setEntityConfig(String realm, FederationConfigElement config) throws WSFederationMetaException {
String federationId = config.getFederationID();
if (federationId == null) {
debug.error("WSFederationMetaManager.setEntityConfig: " + "entity ID is null");
String[] data = { realm };
LogUtil.error(Level.INFO, LogUtil.NO_ENTITY_ID_SET_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);
oldAttrs.put(ATTR_ENTITY_CONFIG, attrs.get(ATTR_ENTITY_CONFIG));
configInst.setConfiguration(realm, federationId, oldAttrs);
LogUtil.access(Level.INFO, LogUtil.SET_ENTITY_CONFIG, objs, null);
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.setEntityConfig:", e);
String[] data = { e.getMessage(), federationId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_SET_ENTITY_CONFIG, data, null);
throw new WSFederationMetaException(e);
} catch (JAXBException jaxbe) {
debug.error("WSFederationMetaManager.setEntityConfig:", jaxbe);
LogUtil.error(Level.INFO, LogUtil.SET_INVALID_ENTITY_CONFIG, objs, null);
throw new WSFederationMetaException("invalid_config", objs);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager method getEntityByTokenIssuerName.
/**
* Returns entity ID associated with the token issuer name.
*
* @param issuer Token issuer name.
* @return entity ID associated with the metaAlias or null if not found.
* @throws WSFederationMetaException if unable to retrieve the entity ids.
*/
public String getEntityByTokenIssuerName(String realm, String issuer) throws WSFederationMetaException {
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();
FederationElement fed = getEntityDescriptor(realm, federationId);
if (issuer.equals(getTokenIssuerName(fed))) {
return federationId;
}
}
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.getEntityByMetaAlias:", e);
throw new WSFederationMetaException(e);
}
return null;
}
Aggregations