use of com.sun.identity.saml2.plugins.IDPAttributeMapper in project OpenAM by OpenRock.
the class IDPSSOUtil method getIDPAttributeMapper.
/**
* Returns an <code>IDPAttributeMapper</code>
*
* @param realm the realm name
* @param idpEntityID the entity id of the identity provider
* @return the <code>IDPAttributeMapper</code>
* @throws SAML2Exception if the operation is not successful
*/
static IDPAttributeMapper getIDPAttributeMapper(String realm, String idpEntityID) throws SAML2Exception {
String classMethod = "IDPSSOUtil.getIDPAttributeMapper: ";
String idpAttributeMapperName = null;
IDPAttributeMapper idpAttributeMapper = null;
try {
idpAttributeMapperName = getAttributeValueFromIDPSSOConfig(realm, idpEntityID, SAML2Constants.IDP_ATTRIBUTE_MAPPER);
if (idpAttributeMapperName == null) {
idpAttributeMapperName = SAML2Constants.DEFAULT_IDP_ATTRIBUTE_MAPPER_CLASS;
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message(classMethod + "use " + SAML2Constants.DEFAULT_IDP_ATTRIBUTE_MAPPER_CLASS);
}
}
idpAttributeMapper = (IDPAttributeMapper) IDPCache.idpAttributeMapperCache.get(idpAttributeMapperName);
if (idpAttributeMapper == null) {
idpAttributeMapper = (IDPAttributeMapper) Class.forName(idpAttributeMapperName).newInstance();
IDPCache.idpAttributeMapperCache.put(idpAttributeMapperName, idpAttributeMapper);
} else {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message(classMethod + "got the IDPAttributeMapper from cache");
}
}
} catch (Exception ex) {
SAML2Utils.debug.error(classMethod + "Unable to get IDP Attribute Mapper.", ex);
throw new SAML2Exception(ex);
}
return idpAttributeMapper;
}
use of com.sun.identity.saml2.plugins.IDPAttributeMapper in project OpenAM by OpenRock.
the class IDPSSOUtil method getAttributeStatement.
/**
* Returns a <code>SAML AttributeStatement</code> object
*
* @param session the user's session
* @param idpEntityID the entity id of the identity provider
* @param recipientEntityID the entity id of the response recipient
* @param realm the realm name
* @return the <code>SAML AttributeStatement</code> object
* @throws SAML2Exception if the operation is not successful
*/
private static AttributeStatement getAttributeStatement(Object session, String idpEntityID, String recipientEntityID, String realm) throws SAML2Exception {
IDPAttributeMapper idpAttrMapper = getIDPAttributeMapper(realm, idpEntityID);
List attributes = idpAttrMapper.getAttributes(session, idpEntityID, recipientEntityID, realm);
if ((attributes == null) || (attributes.isEmpty())) {
return null;
}
AttributeStatement attrStatement = AssertionFactory.getInstance().createAttributeStatement();
attrStatement.setAttribute(attributes);
return attrStatement;
}
Aggregations