use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class NameIDMapping method initiateNameIDMappingRequest.
/**
* Parses the request parameters and builds the NameIDMappingRequest to
* sent to remote identity provider.
*
* @param session user session.
* @param realm the realm of hosted entity
* @param spEntityID entity ID of hosted service provider
* @param idpEntityID entity ID of remote idendity provider
* @param targetSPEntityID entity ID of target entity ID of service
* provider
* @param targetNameIDFormat format of target Name ID
* @param paramsMap Map of all other parameters
*
* @return the <code>NameIDMappingResponse</code>
* @throws SAML2Exception if error initiating request to remote entity.
*
* @supported.api
*/
public static NameIDMappingResponse initiateNameIDMappingRequest(Object session, String realm, String spEntityID, String idpEntityID, String targetSPEntityID, String targetNameIDFormat, Map paramsMap) throws SAML2Exception {
if (spEntityID == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nullSPEntityID"));
}
if (idpEntityID == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nullIDPEntityID"));
}
String userID = null;
try {
userID = sessionProvider.getPrincipalName(session);
} catch (SessionException e) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("NameIDMapping.createNameIDMappingRequest: ", e);
}
}
if (userID == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("invalidSSOToken"));
}
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " IDP EntityID is : " + idpEntityID);
SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " SP HOST EntityID is : " + spEntityID);
SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " target SP EntityID is : " + targetSPEntityID);
}
try {
// nameIDMappingService
String binding = SAML2Utils.getParameter(paramsMap, SAML2Constants.BINDING);
if (binding == null) {
binding = SAML2Constants.SOAP;
} else if (!binding.equals(SAML2Constants.SOAP)) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nimServiceBindingUnsupport"));
}
String nimURL = SAML2Utils.getParameter(paramsMap, "nimURL");
if (nimURL == null) {
NameIDMappingServiceElement nameIDMappingService = getNameIDMappingService(realm, idpEntityID, binding);
if (nameIDMappingService != null) {
nimURL = nameIDMappingService.getLocation();
}
}
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " nimURL" + nimURL);
}
if (nimURL == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nimServiceNotFound"));
}
NameIDMappingRequest nimRequest = createNameIDMappingRequest(userID, realm, spEntityID, idpEntityID, nimURL, targetSPEntityID, targetNameIDFormat);
signNIMRequest(nimRequest, realm, spEntityID, false);
BaseConfigType config = metaManager.getIDPSSOConfig(realm, idpEntityID);
nimURL = SAML2SDKUtils.fillInBasicAuthInfo(config, nimURL);
return doNIMBySOAP(nimRequest.toXMLString(true, true), nimURL, realm, spEntityID);
} catch (SAML2MetaException sme) {
throw new SAML2Exception(SAML2Utils.bundle.getString("metaDataError"));
}
}
use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class SAMLv2ModelImpl method getExtendedAttributeAuthorityAttributes.
/**
* Returns a map with extended AttributeAuthority attributes and values.
*
* @param realm to which the entity belongs.
* @param entityName is the entity id.
* @return Map with extended AttributeAuthority values.
* @throws AMConsoleException if unable to retrieve ext AttributeAuthority
* attributes based on the realm and entityName passed.
*/
public Map getExtendedAttributeAuthorityAttributes(String realm, String entityName) throws AMConsoleException {
String[] params = { realm, entityName, "SAMLv2", "AttribAuthority-Ext" };
logEvent("ATTEMPT_GET_ATTR_AUTH_ATTR_VALUES", params);
Map map = null;
AttributeAuthorityConfigElement attributeAuthorityConfig = null;
try {
SAML2MetaManager samlManager = getSAML2MetaManager();
attributeAuthorityConfig = samlManager.getAttributeAuthorityConfig(realm, entityName);
if (attributeAuthorityConfig != null) {
BaseConfigType baseConfig = (BaseConfigType) attributeAuthorityConfig;
map = SAML2MetaUtils.getAttributes(baseConfig);
}
logEvent("SUCCEED_GET_ATTR_AUTH_ATTR_VALUES", params);
} catch (SAML2MetaException e) {
debug.warning("SAMLv2ModelImpl.getExtendedAttributeAuthorityAttributes:", e);
String strError = getErrorString(e);
String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Ext", strError };
logEvent("FEDERATION_EXCEPTION_GET_ATTR_AUTH_ATTR_VALUES", paramsEx);
throw new AMConsoleException(strError);
}
return (map != null) ? map : Collections.EMPTY_MAP;
}
use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class SAMLv2ModelImpl method updateBaseConfig.
/**
* Updates the BaseConfigElement.
*
* @param baseConfig is the BaseConfigType passed.
* @param values the Map which contains the new attribute/value pairs.
* @param role the role of entity.
* @throws AMConsoleException if update of baseConfig object fails.
*/
private void updateBaseConfig(BaseConfigType baseConfig, Map values, String role) throws JAXBException, AMConsoleException {
List attrList = baseConfig.getAttribute();
if (role.equals(EntityModel.IDENTITY_PROVIDER)) {
attrList.clear();
baseConfig = addAttributeType(extendedMetaIdpMap, baseConfig);
attrList = baseConfig.getAttribute();
} else if (role.equals(EntityModel.SERVICE_PROVIDER)) {
attrList.clear();
baseConfig = addAttributeType(extendedMetaSpMap, baseConfig);
attrList = baseConfig.getAttribute();
} else if (role.equals(EntityModel.POLICY_ENFORCEMENT_POINT_DESCRIPTOR)) {
attrList.clear();
baseConfig = addAttributeType(xacmlPEPExtendedMeta, baseConfig);
attrList = baseConfig.getAttribute();
} else if (role.equals(EntityModel.POLICY_DECISION_POINT_DESCRIPTOR)) {
attrList.clear();
baseConfig = addAttributeType(xacmlPDPExtendedMeta, baseConfig);
attrList = baseConfig.getAttribute();
}
for (Iterator it = attrList.iterator(); it.hasNext(); ) {
AttributeElement avpnew = (AttributeElement) it.next();
String name = avpnew.getName();
if (values.keySet().contains(name)) {
Set set = (Set) values.get(name);
if (set != null) {
avpnew.getValue().clear();
avpnew.getValue().addAll(set);
}
}
}
}
use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class SAMLv2ModelImpl method updateBaseConfig.
/**
* Updates the BaseConfigElement.
*
* @param baseConfig is the BaseConfigType passed.
* @param attributeName is the attribute name
* @param list the list which contains the new values.
* @throws AMConsoleException if update of baseConfig object fails.
*/
private void updateBaseConfig(BaseConfigType baseConfig, String attributeName, List list) throws AMConsoleException {
List attrList = baseConfig.getAttribute();
for (Iterator it = attrList.iterator(); it.hasNext(); ) {
AttributeElement avpnew = (AttributeElement) it.next();
String name = avpnew.getName();
if (name.equals(attributeName)) {
avpnew.getValue().clear();
avpnew.getValue().addAll(list);
}
}
}
use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class SAMLv2ModelImpl method getExtendedIdentityProviderAttributes.
/**
* Returns a map with extended identity provider attributes and values.
*
* @param realm to which the entity belongs.
* @param entityName is the entity id.
* @return Map with extended attribute values of Identity Provider.
* @throws AMConsoleException if unable to retrieve the Identity Provider
* attrubutes based on the realm and entityName passed.
*/
public Map<String, List<String>> getExtendedIdentityProviderAttributes(String realm, String entityName) throws AMConsoleException {
String[] params = { realm, entityName, "SAMLv2", "IDP-Extended" };
logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
Map<String, List<String>> map = null;
IDPSSOConfigElement idpssoConfig = null;
try {
SAML2MetaManager samlManager = getSAML2MetaManager();
idpssoConfig = samlManager.getIDPSSOConfig(realm, entityName);
if (idpssoConfig != null) {
BaseConfigType baseConfig = (BaseConfigType) idpssoConfig;
map = SAML2MetaUtils.getAttributes(baseConfig);
}
logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
} catch (SAML2MetaException e) {
debug.warning("SAMLv2ModelImpl.getExtIdentityProviderAttributes:", e);
String strError = getErrorString(e);
String[] paramsEx = { realm, entityName, "SAMLv2", "IDP-Extended", strError };
logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
throw new AMConsoleException(strError);
}
return (map != null) ? map : Collections.EMPTY_MAP;
}
Aggregations