use of com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement in project OpenAM by OpenRock.
the class WSFederationMetaCache method getFederation.
/**
* Returns the standard metadata entity descriptor under the realm from
* cache.
* @param realm The realm under which the entity resides.
* @param entityId ID of the entity to be retrieved.
* @return <code>FederationElement</code> for the entity or null
* if not found.
*/
static FederationElement getFederation(String realm, String federationId) {
String cacheKey = buildCacheKey(realm, federationId);
FederationElement federation = (FederationElement) federationCache.get(cacheKey);
if (debug.messageEnabled()) {
debug.message("WSFederationMetaCache.getEntityDescriptor: " + "cacheKey = " + cacheKey + ", found = " + (federation != null));
}
return federation;
}
use of com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement 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.wsfederation.jaxb.wsfederation.FederationElement 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