use of com.sun.identity.saml2.jaxb.assertion.AttributeValueElement in project OpenAM by OpenRock.
the class AttributeQueryUtil method isValueValid.
private static boolean isValueValid(Attribute desiredAttr, AttributeElement supportedAttr) {
List valuesD = desiredAttr.getAttributeValueString();
if ((valuesD == null) || (valuesD.isEmpty())) {
return true;
}
List attrValuesS = supportedAttr.getAttributeValue();
if ((attrValuesS == null) || (attrValuesS.isEmpty())) {
return true;
}
List valuesS = new ArrayList();
for (Iterator iter = attrValuesS.iterator(); iter.hasNext(); ) {
AttributeValueElement attrValueElem = (AttributeValueElement) iter.next();
valuesS.addAll(attrValueElem.getContent());
}
try {
return valuesS.containsAll(valuesD);
} catch (Exception ex) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AttributeQueryUtil.isValueValid:", ex);
}
return false;
}
}
use of com.sun.identity.saml2.jaxb.assertion.AttributeValueElement in project OpenAM by OpenRock.
the class AttributeQueryUtil method convertAttributes.
private static List convertAttributes(List jaxbAttrs) throws SAML2Exception {
List resultAttrs = new ArrayList();
for (Iterator iter = jaxbAttrs.iterator(); iter.hasNext(); ) {
AttributeElement jaxbAttr = (AttributeElement) iter.next();
Attribute attr = AssertionFactory.getInstance().createAttribute();
attr.setName(jaxbAttr.getName());
attr.setNameFormat(jaxbAttr.getNameFormat());
attr.setFriendlyName(jaxbAttr.getFriendlyName());
List jaxbValues = jaxbAttr.getAttributeValue();
if ((jaxbValues != null) && (!jaxbValues.isEmpty())) {
List newValues = new ArrayList();
for (Iterator iterV = jaxbValues.iterator(); iterV.hasNext(); ) {
AttributeValueElement jaxbValeu = (AttributeValueElement) iter.next();
List content = jaxbValeu.getContent();
if ((content != null) && (!content.isEmpty())) {
newValues.add(content.get(0));
}
}
if (!newValues.isEmpty()) {
attr.setAttributeValueString(newValues);
}
}
resultAttrs.add(attr);
}
return resultAttrs;
}
use of com.sun.identity.saml2.jaxb.assertion.AttributeValueElement in project OpenAM by OpenRock.
the class SAML2IDPProxyFRImpl method selectIDPBasedOnLOA.
private String selectIDPBasedOnLOA(List<String> idpList, String realm, AuthnRequest authnRequest) {
String classMethod = "selectIdPBasedOnLOA";
EntityDescriptorElement idpDesc = null;
Set authnRequestContextSet = null;
String idps = "";
try {
RequestedAuthnContext requestedAuthnContext = authnRequest.getRequestedAuthnContext();
if (requestedAuthnContext == null) {
//In this case we just simply return all the IdPs as each one should support a default AuthnContext.
return StringUtils.join(idpList, " ");
}
List listOfAuthnContexts = requestedAuthnContext.getAuthnContextClassRef();
debugMessage(classMethod, "listofAuthnContexts: " + listOfAuthnContexts);
try {
authnRequestContextSet = new HashSet(listOfAuthnContexts);
} catch (Exception ex1) {
authnRequestContextSet = new HashSet();
}
if ((idpList != null) && (!idpList.isEmpty())) {
Iterator idpI = idpList.iterator();
while (idpI.hasNext()) {
String idp = (String) idpI.next();
debugMessage(classMethod, "IDP is: " + idp);
idpDesc = SAML2Utils.getSAML2MetaManager().getEntityDescriptor(realm, idp);
if (idpDesc != null) {
ExtensionsType et = idpDesc.getExtensions();
if (et != null) {
debugMessage(classMethod, "Extensions found for idp: " + idp);
List idpExtensions = et.getAny();
if (idpExtensions != null || !idpExtensions.isEmpty()) {
debugMessage(classMethod, "Extensions content found for idp: " + idp);
Iterator idpExtensionsI = idpExtensions.iterator();
while (idpExtensionsI.hasNext()) {
EntityAttributesElement eael = (EntityAttributesElement) idpExtensionsI.next();
if (eael != null) {
debugMessage(classMethod, "Entity Attributes found for idp: " + idp);
List attribL = eael.getAttributeOrAssertion();
if (attribL != null || !attribL.isEmpty()) {
Iterator attrI = attribL.iterator();
while (attrI.hasNext()) {
AttributeElement ae = (AttributeElement) attrI.next();
// TODO: Verify what type of element this is (Attribute or assertion)
// For validation purposes
List av = ae.getAttributeValue();
if (av != null || !av.isEmpty()) {
debugMessage(classMethod, "Attribute Values found for idp: " + idp);
Iterator avI = av.iterator();
while (avI.hasNext()) {
AttributeValueElement ave = (AttributeValueElement) avI.next();
if (ave != null) {
List contentL = ave.getContent();
debugMessage(classMethod, "Attribute Value Elements found for idp: " + idp + "-->" + contentL);
if (contentL != null || !contentL.isEmpty()) {
Set idpContextSet = trimmedListToSet(contentL);
debugMessage(classMethod, "idpContextSet = " + idpContextSet);
idpContextSet.retainAll(authnRequestContextSet);
if (idpContextSet != null && !idpContextSet.isEmpty()) {
idps = idp + " " + idps;
debugMessage(classMethod, "Extension Values found for idp " + idp + ": " + idpContextSet);
}
}
}
}
}
}
}
}
}
}
} else {
debugMessage(classMethod, " No extensions found for IdP " + idp);
}
} else {
debugMessage(classMethod, "Configuration for the idp " + idp + " was not found in this system");
}
}
}
} catch (SAML2MetaException me) {
debugMessage(classMethod, "SOmething went wrong: " + me);
}
debugMessage(classMethod, " IDPList returns: " + idps);
return idps.trim();
}
Aggregations