use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class SAML2Utils method getAllAttributeValueFromSSOConfig.
/**
* Returns all values of specified attribute from SSOConfig.
*
* @param realm realm of hosted entity.
* @param hostEntityId name of hosted entity.
* @param entityRole role of hosted entity.
* @param attrName attribute name for the value.
* @return value of specified attribute from SSOConfig.
*/
public static List<String> getAllAttributeValueFromSSOConfig(String realm, String hostEntityId, String entityRole, String attrName) {
if (debug.messageEnabled()) {
String method = "getAllAttributeValueFromSSOConfig : ";
debug.message(method + "realm - " + realm);
debug.message(method + "hostEntityId - " + hostEntityId);
debug.message(method + "entityRole - " + entityRole);
debug.message(method + "attrName - " + attrName);
}
try {
BaseConfigType config = null;
if (entityRole.equalsIgnoreCase(SAML2Constants.SP_ROLE)) {
config = saml2MetaManager.getSPSSOConfig(realm, hostEntityId);
} else if (entityRole.equalsIgnoreCase(SAML2Constants.IDP_ROLE)) {
config = saml2MetaManager.getIDPSSOConfig(realm, hostEntityId);
} else if (entityRole.equalsIgnoreCase(SAML2Constants.ATTR_AUTH_ROLE)) {
config = saml2MetaManager.getAttributeAuthorityConfig(realm, hostEntityId);
} else if (entityRole.equalsIgnoreCase(SAML2Constants.AUTHN_AUTH_ROLE)) {
config = saml2MetaManager.getAuthnAuthorityConfig(realm, hostEntityId);
} else if (entityRole.equalsIgnoreCase(SAML2Constants.ATTR_QUERY_ROLE)) {
config = saml2MetaManager.getAttributeQueryConfig(realm, hostEntityId);
}
if (config == null) {
return null;
}
Map attrs = SAML2MetaUtils.getAttributes(config);
if (attrs == null) {
return null;
}
return (List) attrs.get(attrName);
} catch (SAML2MetaException e) {
debug.message("get SSOConfig failed:", e);
}
return null;
}
use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class SAML2COTUtils method removeFromEntityConfig.
/**
* Removes the circle trust name passed from the <code>cotlist</code>
* attribute in the Entity Config. The Service Provider and Identity
* Provider Entity Configuration are updated.
*
* @param name the circle of trust name to be removed.
* @param entityId the entity identifier of the provider.
* @throws SAML2MetaException 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 SAML2MetaException, JAXBException {
String classMethod = "SAML2COTUtils.removeFromEntityConfig: ";
SAML2MetaManager metaManager = null;
if (callerSession == null) {
metaManager = new SAML2MetaManager();
} else {
metaManager = new SAML2MetaManager(callerSession);
}
// Check whether the entity id existed in the DS
EntityDescriptorElement edes = metaManager.getEntityDescriptor(realm, entityId);
if (edes == null) {
debug.error(classMethod + "No such entity: " + entityId);
String[] data = { realm, entityId };
throw new SAML2MetaException("entityid_invalid", data);
}
EntityConfigElement eConfig = metaManager.getEntityConfig(realm, entityId);
boolean isAffiliation = false;
if (metaManager.getAffiliationDescriptor(realm, entityId) != null) {
isAffiliation = true;
}
if (debug.messageEnabled()) {
debug.message(classMethod + "is " + entityId + " in realm " + realm + " an affiliation? " + isAffiliation);
}
if (eConfig != null) {
List elist = null;
if (isAffiliation) {
AffiliationConfigElement affiliationCfgElm = metaManager.getAffiliationConfig(realm, entityId);
elist = new ArrayList();
elist.add(affiliationCfgElm);
} else {
elist = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
}
boolean needToSave = false;
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);
needToSave = true;
break;
}
}
}
}
if (needToSave) {
metaManager.setEntityConfig(realm, eConfig);
}
}
}
use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class SAML2MetaManager method addToCircleOfTrust.
private void addToCircleOfTrust(String realm, String entityId, EntityConfigElement eConfig) {
try {
if (eConfig != null) {
List elist = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
// use first one to add the entity to COT
BaseConfigType config = (BaseConfigType) elist.iterator().next();
Map attr = SAML2MetaUtils.getAttributes(config);
List cotAttr = (List) attr.get(SAML2Constants.COT_LIST);
List cotList = new ArrayList(cotAttr);
if ((cotList != null) && !cotList.isEmpty()) {
for (Iterator iter = cotList.iterator(); iter.hasNext(); ) {
String cotName = ((String) iter.next()).trim();
if ((cotName != null) && (!cotName.equals(""))) {
cotm.addCircleOfTrustMember(realm, cotName, COTConstants.SAML2, entityId, false);
}
}
}
}
} catch (Exception e) {
debug.error("SAML2MetaManager.addToCircleOfTrust:" + "Error while adding entity" + entityId + "to COT.", e);
}
}
Aggregations