use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class DefaultAttributeMapper method getConfigAttributeMap.
/**
* Returns the attribute map by parsing the configured map in hosted
* provider configuration
* @param realm realm name.
* @param hostEntityID <code>EntityID</code> of the hosted provider.
* @return a map of local attributes configuration map.
* This map will have a key as the SAML attribute name and the value
* is the local attribute.
* @exception <code>WSFederationException</code> if any failured.
*/
public Map getConfigAttributeMap(String realm, String hostEntityID) throws WSFederationException {
if (realm == null) {
throw new WSFederationException(bundle.getString("nullRealm"));
}
if (hostEntityID == null) {
throw new WSFederationException(bundle.getString("nullHostEntityID"));
}
try {
BaseConfigType config = null;
if (role.equals(SP)) {
config = WSFederationUtils.getMetaManager().getSPSSOConfig(realm, hostEntityID);
} else {
config = WSFederationUtils.getMetaManager().getIDPSSOConfig(realm, hostEntityID);
}
if (config == null) {
if (debug.warningEnabled()) {
debug.warning("DefaultAttributeMapper.getConfigAttribute" + "Map: configuration is not defined.");
}
return Collections.EMPTY_MAP;
}
Map attribConfig = WSFederationMetaUtils.getAttributes(config);
List mappedAttributes = (List) attribConfig.get(SAML2Constants.ATTRIBUTE_MAP);
if (mappedAttributes == null || mappedAttributes.size() == 0) {
if (debug.messageEnabled()) {
debug.message("DefaultAttributeMapper.getConfigAttributeMap:" + "Attribute map is not defined for entity: " + hostEntityID);
}
return Collections.EMPTY_MAP;
}
Map map = new HashMap();
for (Iterator iter = mappedAttributes.iterator(); iter.hasNext(); ) {
String entry = (String) iter.next();
if (entry.indexOf("=") == -1) {
if (debug.messageEnabled()) {
debug.message("DefaultAttributeMapper.getConfig" + "AttributeMap: Invalid entry." + entry);
}
continue;
}
StringTokenizer st = new StringTokenizer(entry, "=");
map.put(st.nextToken(), st.nextToken());
}
return map;
} catch (WSFederationMetaException sme) {
debug.error("DefaultAttributeMapper.getConfigAttributeMap: " + "Meta Exception", sme);
throw new WSFederationException(sme);
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method setGenAttributeValues.
/**
* Saves the attribute values from the General page.
*
* @param realm to which the entity belongs.
* @param fedId is the entity id.
* @param idpStdValues has the General standard attribute value pairs.
* @param role of the entity ID.
* @param location specifies if the entity is remote or local.
* @throws AMConsoleException if saving of attribute value fails.
*/
public void setGenAttributeValues(String realm, String fedId, Map idpStdValues, String role, String location) throws AMConsoleException {
String tknissEndPt = null;
String tknissName = null;
Iterator it = idpStdValues.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
if (key.equals(TFTOKENISSUER_ENDPT)) {
HashSet set = (HashSet) idpStdValues.get(key);
Iterator i = set.iterator();
while ((i != null) && (i.hasNext())) {
tknissEndPt = (String) i.next();
}
} else if (key.equals(TFTOKENISSUER_NAME)) {
HashSet set = (HashSet) idpStdValues.get(key);
Iterator i = set.iterator();
while ((i != null) && (i.hasNext())) {
tknissName = (String) i.next();
}
} else if (key.equals(TF_DISPNAME)) {
if (role.equals(EntityModel.SERVICE_PROVIDER)) {
HashSet set = (HashSet) idpStdValues.get(key);
// Get the current map of extended SP values
Map tmpMap = getExtendedValues(role, realm, fedId);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setSPExtAttributeValues(realm, fedId, tmpMap, location);
} else if (role.equals(EntityModel.IDENTITY_PROVIDER)) {
HashSet set = (HashSet) idpStdValues.get(key);
// Get the current map of extended IDP values
Map tmpMap = getExtendedValues(role, realm, fedId);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setIDPExtAttributeValues(realm, fedId, tmpMap, location);
} else if (role.equals(DUAL)) {
HashSet set = (HashSet) idpStdValues.get(key);
// Get the current map of extended SP values
Map tmpMap = getExtendedValues(EntityModel.SERVICE_PROVIDER, realm, fedId);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setSPExtAttributeValues(realm, fedId, tmpMap, location);
// Get the current map of extended IDP values
tmpMap = getExtendedValues(EntityModel.IDENTITY_PROVIDER, realm, fedId);
set = (HashSet) idpStdValues.get(TFIDPDISP_NAME);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setIDPExtAttributeValues(realm, fedId, tmpMap, location);
}
}
}
try {
//fedElem is standard metadata federation element under the realm.
WSFederationMetaManager metaManager = getWSFederationMetaManager();
FederationElement fedElem = metaManager.getEntityDescriptor(realm, fedId);
if (fedElem == null) {
if (debug.warningEnabled()) {
debug.warning("WSFedPropertiesModelImpl.setGenAttributeValues:" + " found invalid federation element " + fedId);
}
throw new AMConsoleException("invalid.federation.element");
} else {
for (Iterator iter = fedElem.getAny().iterator(); iter.hasNext(); ) {
Object o = iter.next();
if (o instanceof TokenIssuerEndpointElement) {
((TokenIssuerEndpointElement) o).getAddress().setValue(tknissEndPt);
} else if (o instanceof TokenIssuerNameElement) {
((TokenIssuerNameElement) o).setValue(tknissName);
}
}
metaManager.setFederation(realm, fedElem);
}
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.setGenAttributeValues", e);
throw new AMConsoleException(e.getMessage());
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method setIDPExtAttributeValues.
/**
* Saves the standard attribute values for the SP.
*
* @param realm to which the entity belongs.
* @param fedId is the entity id.
* @param idpExtValues has the extended attribute value pairs of IDP.
* @param location has the information whether remote or hosted.
* @throws AMConsoleException if saving of attribute value fails.
*/
public void setIDPExtAttributeValues(String realm, String fedId, Map idpExtValues, String location) throws AMConsoleException {
try {
String role = EntityModel.IDENTITY_PROVIDER;
// fed is the extended entity configuration under the realm
WSFederationMetaManager metaManager = getWSFederationMetaManager();
FederationConfigElement fed = metaManager.getEntityConfig(realm, fedId);
if (fed == null) {
IDPEX_DATA_MAP.put(TF_DISPNAME, Collections.EMPTY_SET);
createExtendedObject(realm, fedId, location, IDENTITY_PROVIDER, IDPEX_DATA_MAP);
fed = metaManager.getEntityConfig(realm, fedId);
}
IDPSSOConfigElement idpsso = getidpsso(fed);
if (idpsso != null) {
BaseConfigType baseConfig = (BaseConfigType) idpsso;
updateBaseConfig(idpsso, idpExtValues, role);
}
//saves the new configuration by passing new fed element created
metaManager.setEntityConfig(realm, fed);
} catch (JAXBException e) {
debug.warning("WSFedPropertiesModelImpl.setIDPExtAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.setIDPExtAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class ImportEntityModelImpl method createWSFedEntity.
private void createWSFedEntity() throws AMConsoleException {
try {
com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement configElt = null;
if (extendedMetaData != null) {
configElt = getWSFedEntityConfigElement();
/*
* see note at the end of this class for how we decide
* the realm value
*/
if (configElt != null && configElt.isHosted()) {
List config = configElt.getIDPSSOConfigOrSPSSOConfig();
if (!config.isEmpty()) {
com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType bConfig = (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) config.iterator().next();
realm = WSFederationMetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
}
}
}
if (standardMetaData != null) {
importWSFedMetaData();
}
if (configElt != null) {
(new WSFederationMetaManager()).createEntityConfig(realm, configElt);
}
} catch (WSFederationMetaException e) {
debug.error("ImportEntityModel.createWSFedEntity", e);
throw new AMConsoleException(e);
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class CircleOfTrustManager method updateWSFedEntityConfig.
/**
* Updates the WSFederation Entity Configuration.
*
* @param realm the realm name.
* @param cotName the circle of trust name.
* @param trustedProviders set of trusted provider names.
* @throws COTException if there is an error updating the configuration.
*/
void updateWSFedEntityConfig(String realm, String cotName, Set trustedProviders) throws COTException {
String classMethod = "COTManager:updateWSFedEntityConfig";
String entityId = null;
WSFederationCOTUtils wsfedCotUtils = new WSFederationCOTUtils(callerSession);
if (trustedProviders != null && !trustedProviders.isEmpty()) {
for (Iterator iter = trustedProviders.iterator(); iter.hasNext(); ) {
entityId = (String) iter.next();
try {
wsfedCotUtils.updateEntityConfig(realm, cotName, entityId);
} catch (WSFederationMetaException sme) {
throw new COTException(sme);
} catch (JAXBException e) {
debug.error(classMethod, e);
String[] data = { e.getMessage(), cotName, entityId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_CREATE_COT_DESCRIPTOR, data);
throw new COTException(e);
}
}
}
}
Aggregations