use of com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement in project OpenAM by OpenRock.
the class IDFFMetaUtils method getFirstAttributeValueFromIDPConfig.
public static String getFirstAttributeValueFromIDPConfig(IDFFMetaManager metaManager, String realm, String idpEntityID, String attrName) {
if (metaManager == null || idpEntityID == null || attrName == null) {
return null;
}
String returnVal = null;
try {
IDPDescriptorConfigElement idpConfig = metaManager.getIDPDescriptorConfig(realm, idpEntityID);
if (idpConfig != null) {
Map attributes = getAttributes(idpConfig);
returnVal = getFirstAttributeValue(attributes, attrName);
}
} catch (IDFFMetaException e) {
returnVal = null;
}
return returnVal;
}
use of com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement in project OpenAM by OpenRock.
the class FSAuthnDecisionHandler method getIDPAuthContextInfo.
private void getIDPAuthContextInfo(String realm, String entityID) {
if (metaManager == null) {
return;
}
try {
IDPDescriptorConfigElement entityConfig = metaManager.getIDPDescriptorConfig(realm, entityID);
if (entityConfig == null) {
return;
}
Map attributes = IDFFMetaUtils.getAttributes(entityConfig);
List mappings = (List) attributes.get(IFSConstants.IDP_AUTHNCONTEXT_MAPPING);
if (mappings != null && !mappings.isEmpty()) {
idpAuthContextMap = new HashMap();
Iterator iter = mappings.iterator();
while (iter.hasNext()) {
String infoString = (String) iter.next();
try {
FSIDPAuthenticationContextInfo info = new FSIDPAuthenticationContextInfo(infoString);
idpAuthContextMap.put(info.getAuthenticationContext(), info);
} catch (FSException fe) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSAuthContextHandler.getIDPAuthContextInfo: " + "info is not valid:" + infoString + " ", fe);
}
continue;
}
}
}
} catch (IDFFMetaException e) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSAuthContextHandler.getIDPAuthContextInfo: ", e);
}
}
}
use of com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement in project OpenAM by OpenRock.
the class FSDefaultAttributePlugin method getAttributeStatements.
/**
* Returns list of <code>AttributeStatement</code>s by using attribute
* map defined in the configuration.
* @param realm The realm under which the entity resides.
* @param hostEntityId Hosted identity provider entity id.
* @param remoteEntityID Remote provider's entity id
* @param subject Subject subject of the authenticated principal.
* @param token user's session.
* @return list of SAML <code>AttributeStatement<code>s.
*/
public List getAttributeStatements(String realm, String hostEntityId, String remoteEntityID, FSSubject subject, Object token) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttributeStatements");
Map attributeMap = null;
try {
IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
if (metaManager != null) {
IDPDescriptorConfigElement idpConfig = metaManager.getIDPDescriptorConfig(realm, hostEntityId);
if (idpConfig != null) {
Map attributes = IDFFMetaUtils.getAttributes(idpConfig);
attributeMap = FSServiceUtils.parseAttributeConfig((List) attributes.get(IFSConstants.IDP_ATTRIBUTE_MAP));
}
}
} catch (IDFFMetaException me) {
FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Statements: meta exception.", me);
return null;
}
if (attributeMap == null || attributeMap.isEmpty()) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: Attribute map configuration is empty.");
}
return null;
} else {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: Attribute map configuration: " + attributeMap);
}
}
List statements = new ArrayList();
List attributes = new ArrayList();
try {
Iterator iter = attributeMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String attributeName = (String) entry.getKey();
String attributeValue = getAttributeValue(token, (String) entry.getValue());
if (attributeValue != null) {
Attribute attr = new Attribute(attributeName, SAMLConstants.assertionSAMLNameSpaceURI, attributeValue);
attributes.add(attr);
}
}
AttributeStatement statement = new AttributeStatement(subject, attributes);
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: attribute statement: " + statement.toString());
}
statements.add(statement);
return statements;
} catch (SAMLException ex) {
FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Statements: SAML Exception", ex);
}
return new ArrayList();
}
use of com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement 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.federation.jaxb.entityconfig.IDPDescriptorConfigElement in project OpenAM by OpenRock.
the class IDFFMetaManager method addEntityToCOT.
/**
* Adds an entity identifier to circle of trust.
*
* @param realm The realm under which the entity resides in
* @param entityID the entity identifier.
* @throws IDFFMetaException if there is an error adding entity to circle
* of trust.
*/
private void addEntityToCOT(String realm, String entityID) throws IDFFMetaException {
IDPDescriptorConfigElement idpConfig = getIDPDescriptorConfig(realm, entityID);
if (idpConfig != null) {
addToCircleOfTrust(idpConfig, realm, entityID);
}
SPDescriptorConfigElement spConfig = getSPDescriptorConfig(realm, entityID);
if (spConfig != null) {
addToCircleOfTrust(spConfig, realm, entityID);
}
}
Aggregations