use of com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method setSPExtAttributeValues.
/**
* Saves the extended metadata attribute values for the SP.
*
* @param realm to which the entity belongs.
* @param fedId is the entity id.
* @param spExtvalues has the extended attribute value pairs of SP.
* @param location has the information whether remote or hosted.
* @throws AMConsoleException if saving of attribute value fails.
*/
public void setSPExtAttributeValues(String realm, String fedId, Map spExtvalues, String location) throws AMConsoleException {
try {
String role = EntityModel.SERVICE_PROVIDER;
//fed is the extended entity configuration object under the realm
WSFederationMetaManager metaManager = getWSFederationMetaManager();
FederationConfigElement fed = metaManager.getEntityConfig(realm, fedId);
if (fed == null) {
SPEX_DATA_MAP.put(TF_DISPNAME, Collections.EMPTY_SET);
createExtendedObject(realm, fedId, location, SERVICE_PROVIDER, SPEX_DATA_MAP);
fed = metaManager.getEntityConfig(realm, fedId);
}
SPSSOConfigElement spsso = getspsso(fed);
if (spsso != null) {
BaseConfigType baseConfig = (BaseConfigType) spsso;
updateBaseConfig(baseConfig, spExtvalues, role);
}
//saves the attributes by passing the new fed object
metaManager.setEntityConfig(realm, fed);
} catch (JAXBException e) {
debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
throw new AMConsoleException(e.getMessage());
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
throw new AMConsoleException(e.getMessage());
}
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class IPRPSignoutRequest method process.
/**
* Processes the sign-out request, returning a response via the
* HttpServletResponse passed to the constructor.
*/
public void process() throws IOException, WSFederationException {
String classMethod = "IPRPSignoutRequest.process: ";
String metaAlias = WSFederationMetaUtils.getMetaAliasByUri(request.getRequestURI());
if ((metaAlias == null) || (metaAlias.trim().length() == 0)) {
debug.error(classMethod + "Unable to get meta alias from request");
throw new WSFederationException(WSFederationUtils.bundle.getString("MetaAliasNotFound"));
}
String realm = WSFederationMetaUtils.getRealmByMetaAlias(metaAlias);
if ((realm == null) || (realm.trim().length() == 0)) {
debug.error(classMethod + "Unable to get realm from request");
throw new WSFederationException(WSFederationUtils.bundle.getString("nullRealm"));
}
WSFederationMetaManager metaManager = WSFederationUtils.getMetaManager();
// retrieve entity id from meta alias
String entityId = metaManager.getEntityByMetaAlias(metaAlias);
if ((entityId == null) || (entityId.trim().length() == 0)) {
debug.error(classMethod + "Unable to get Entity ID from metaAlias" + metaAlias);
throw new WSFederationException(WSFederationUtils.bundle.getString("nullEntityID"));
}
Object session = null;
try {
session = WSFederationUtils.sessionProvider.getSession(request);
} catch (SessionException se) {
if (debug.messageEnabled()) {
debug.message(classMethod + "Session exception" + se.getLocalizedMessage());
}
// Don't care too much about session exceptions here - usual cause
// is trying to log out after the session has expired
}
try {
// Strategy here is to do logouts in parallel via iframes, provide a
// link to wreply, if any
BaseConfigType config = metaManager.getBaseConfig(realm, entityId);
String displayName = WSFederationMetaUtils.getAttribute(config, WSFederationConstants.DISPLAY_NAME);
if (displayName == null || displayName.length() == 0) {
displayName = entityId;
}
request.setAttribute(WSFederationConstants.LOGOUT_DISPLAY_NAME, displayName);
request.setAttribute(WSFederationConstants.LOGOUT_WREPLY, wreply);
request.setAttribute(WSFederationConstants.REALM_PARAM, realm);
request.setAttribute(WSFederationConstants.ENTITYID_PARAM, entityId);
LinkedHashMap<String, String> providerList = new LinkedHashMap<String, String>();
if (session != null) {
String[] idpList = WSFederationUtils.sessionProvider.getProperty(session, WSFederationConstants.SESSION_IDP);
if (idpList != null && idpList.length > 0 && idpList[0] != null && idpList[0].length() > 0) {
FederationElement fed = metaManager.getEntityDescriptor(realm, idpList[0]);
String endpoint = metaManager.getTokenIssuerEndpoint(fed);
String url = endpoint + "?wa=" + WSFederationConstants.WSIGNOUT10;
config = metaManager.getBaseConfig(realm, idpList[0]);
displayName = WSFederationMetaUtils.getAttribute(config, WSFederationConstants.DISPLAY_NAME);
if (displayName == null) {
displayName = idpList[0];
}
if (debug.messageEnabled()) {
debug.message(classMethod + "sending signout to " + url);
}
providerList.put(url, displayName);
}
String[] spList = WSFederationUtils.sessionProvider.getProperty(session, WSFederationConstants.SESSION_SP_LIST);
if (spList != null && spList.length > 0 && spList[0] != null && spList[0].length() > 0) {
for (int i = 0; i < spList.length; i++) {
config = metaManager.getBaseConfig(realm, spList[i]);
displayName = WSFederationMetaUtils.getAttribute(config, WSFederationConstants.DISPLAY_NAME);
if (displayName == null) {
displayName = spList[i];
}
FederationElement fed = metaManager.getEntityDescriptor(realm, spList[i]);
String endpoint = metaManager.getTokenIssuerEndpoint(fed);
String url = endpoint + "?wa=" + WSFederationConstants.WSIGNOUT10;
if (debug.messageEnabled()) {
debug.message(classMethod + "sending signout to " + url);
}
providerList.put(url, displayName);
}
// Can't remove a session property, so just set it to
// an empty string
String[] empty = { "" };
WSFederationUtils.sessionProvider.setProperty(session, WSFederationConstants.SESSION_SP_LIST, empty);
}
if (debug.messageEnabled()) {
debug.message(classMethod + "destroying session " + session);
}
MultiProtocolUtils.invalidateSession(session, request, response, SingleLogoutManager.WS_FED);
}
request.setAttribute(WSFederationConstants.LOGOUT_PROVIDER_LIST, providerList);
request.getRequestDispatcher("/wsfederation/jsp/logout.jsp").forward(request, response);
} catch (ServletException se) {
if (debug.messageEnabled()) {
debug.message(classMethod + "Servlet exception" + se.getLocalizedMessage());
}
throw new WSFederationException(se);
} catch (SessionException se) {
if (debug.messageEnabled()) {
debug.message(classMethod + "Session exception" + se.getLocalizedMessage());
}
throw new WSFederationException(se);
}
// Can't pass session, since we just invalidated it!
String[] data = { wreply };
LogUtil.access(Level.INFO, LogUtil.SLO_SUCCESSFUL, data, null);
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType 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.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class WSFederationCOTUtils method updateEntityConfig.
/**
* Updates the entity config to add the circle of trust name to the
* <code>cotlist</code> attribute. The Service Provider and Identity
* Provider Configuration are updated.
*
* @param realm the realm name where the entity configuration is.
* @param name the circle of trust name.
* @param entityId the name of the Entity identifier.
* @throws WSFederationMetaException if there is a configuration error when
* updating the configuration.
* @throws JAXBException is there is an error updating the entity
* configuration.
*/
public void updateEntityConfig(String realm, String name, String entityId) throws WSFederationMetaException, JAXBException {
String classMethod = "WSFederationCOTUtils.updateEntityConfig: ";
WSFederationMetaManager metaManager = null;
if (callerSession != null) {
metaManager = new WSFederationMetaManager(callerSession);
} else {
metaManager = new WSFederationMetaManager();
}
ObjectFactory objFactory = new ObjectFactory();
// Check whether the entity id existed in the DS
FederationElement edes = metaManager.getEntityDescriptor(realm, entityId);
if (edes == null) {
debug.error(classMethod + "No such entity: " + entityId);
String[] data = { realm, entityId };
throw new WSFederationMetaException("entityid_invalid", data);
}
FederationConfigElement eConfig = metaManager.getEntityConfig(realm, entityId);
if (eConfig == null) {
BaseConfigType bctype = null;
AttributeType atype = objFactory.createAttributeType();
atype.setName(SAML2Constants.COT_LIST);
atype.getValue().add(name);
// add to eConfig
FederationConfigElement ele = objFactory.createFederationConfigElement();
ele.setFederationID(entityId);
ele.setHosted(false);
List ll = ele.getIDPSSOConfigOrSPSSOConfig();
// IdP will have UriNamedClaimTypesOffered
if (metaManager.getUriNamedClaimTypesOffered(edes) != null) {
bctype = objFactory.createIDPSSOConfigElement();
bctype.getAttribute().add(atype);
ll.add(bctype);
} else {
bctype = objFactory.createSPSSOConfigElement();
bctype.getAttribute().add(atype);
ll.add(bctype);
}
metaManager.setEntityConfig(realm, ele);
} else {
List elist = eConfig.getIDPSSOConfigOrSPSSOConfig();
for (Iterator iter = elist.iterator(); iter.hasNext(); ) {
BaseConfigType bConfig = (BaseConfigType) iter.next();
List list = bConfig.getAttribute();
boolean foundCOT = false;
for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
AttributeType avp = (AttributeType) iter2.next();
if (avp.getName().trim().equalsIgnoreCase(SAML2Constants.COT_LIST)) {
foundCOT = true;
List avpl = avp.getValue();
if (avpl.isEmpty() || !containsValue(avpl, name)) {
avpl.add(name);
metaManager.setEntityConfig(realm, eConfig);
break;
}
}
}
// no cot_list in the original entity config
if (!foundCOT) {
AttributeType atype = objFactory.createAttributeType();
atype.setName(SAML2Constants.COT_LIST);
atype.getValue().add(name);
list.add(atype);
metaManager.setEntityConfig(realm, eConfig);
}
}
}
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class WSFederationCOTUtils method removeFromEntityConfig.
/**
* Removes the circle of trust name passed from the <code>cotlist</code>
* attribute in the Entity Config. The Service Provider and Identity
* Provider Entity Configuration are updated.
*
* @param realm the realm of the provider
* @param name the circle of trust name to be removed.
* @param entityId the entity identifier of the provider.
* @throws WSFederationMetaException if there is an error updating the
* entity config.
* @throws JAXBException if there is an error updating the entity config.
*/
public void removeFromEntityConfig(String realm, String name, String entityId) throws WSFederationMetaException, JAXBException {
String classMethod = "WSFederationCOTUtils.removeFromEntityConfig: ";
WSFederationMetaManager metaManager = null;
if (callerSession != null) {
metaManager = new WSFederationMetaManager(callerSession);
} else {
metaManager = new WSFederationMetaManager();
}
// Check whether the entity id existed in the DS
FederationElement edes = metaManager.getEntityDescriptor(realm, entityId);
if (edes == null) {
debug.error(classMethod + "No such entity: " + entityId);
String[] data = { realm, entityId };
throw new WSFederationMetaException("entityid_invalid", data);
}
FederationConfigElement eConfig = metaManager.getEntityConfig(realm, entityId);
if (eConfig != null) {
List elist = eConfig.getIDPSSOConfigOrSPSSOConfig();
for (Iterator iter = elist.iterator(); iter.hasNext(); ) {
BaseConfigType bConfig = (BaseConfigType) iter.next();
List list = bConfig.getAttribute();
for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
AttributeType avp = (AttributeType) iter2.next();
if (avp.getName().trim().equalsIgnoreCase(SAML2Constants.COT_LIST)) {
List avpl = avp.getValue();
if (avpl != null && !avpl.isEmpty() && containsValue(avpl, name)) {
avpl.remove(name);
metaManager.setEntityConfig(realm, eConfig);
break;
}
}
}
}
}
}
Aggregations