use of com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType in project OpenAM by OpenRock.
the class WSFederationMetaSecurityUtils method setExtendedAttributeValue.
private static void setExtendedAttributeValue(BaseConfigType config, String attrName, Set attrVal) throws WSFederationMetaException {
try {
List attributes = config.getAttribute();
for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
AttributeType avp = (AttributeType) iter.next();
if (avp.getName().trim().equalsIgnoreCase(attrName)) {
iter.remove();
}
}
if (attrVal != null) {
ObjectFactory factory = new ObjectFactory();
AttributeType atype = factory.createAttributeType();
atype.setName(attrName);
atype.getValue().addAll(attrVal);
config.getAttribute().add(atype);
}
} catch (JAXBException e) {
throw new WSFederationMetaException(e);
}
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType in project OpenAM by OpenRock.
the class WSFederationMetaUtils method getAttributes.
/**
* Gets attribute value pairs from <code>BaseConfigType</code> and
* put in a <code>Map</code>. The key is attribute name and the value is
* a <code>List</code> of attribute values;
* @param config the <code>BaseConfigType</code> object
* @return a attrbute value <code>Map</code>
*/
public static Map<String, List<String>> getAttributes(BaseConfigType config) {
Map<String, List<String>> attrMap = new HashMap<String, List<String>>();
List list = config.getAttribute();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
AttributeType avp = (AttributeType) iter.next();
attrMap.put(avp.getName(), avp.getValue());
}
return attrMap;
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType 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.AttributeType 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