public List<EntityDescriptor> filterEntityCategory( List<EntityDescriptor> entities, String category) { List<EntityDescriptor> returnList = new ArrayList<EntityDescriptor>(); for (EntityDescriptor entity : entities) { Extensions extensions = entity.getExtensions(); List<XMLObject> extObjs = extensions.getOrderedChildren(); for (XMLObject xmlObject : extObjs) { if (xmlObject instanceof EntityAttributes) { EntityAttributes entityAttrs = (EntityAttributes) xmlObject; for (Attribute attr : entityAttrs.getAttributes()) { if ("http://macedir.org/entity-category".equals(attr.getName())) { for (XMLObject value : attr.getAttributeValues()) { if (value instanceof XSAny) { XSAny any = (XSAny) value; if (category.equals(any.getTextContent())) { returnList.add(entity); } } } } } } } } return returnList; }
public Set<SamlIdpScopeEntity> getScopes(EntityDescriptor entityDesc, SamlIdpMetadataEntity idp) { Set<SamlIdpScopeEntity> scopeList = new HashSet<SamlIdpScopeEntity>(); IDPSSODescriptor idpsso = entityDesc.getIDPSSODescriptor(SAMLConstants.SAML20P_NS); if (idpsso != null) { Extensions extensions = idpsso.getExtensions(); List<XMLObject> scopes = extensions.getUnknownXMLObjects(new QName("urn:mace:shibboleth:metadata:1.0", "Scope")); for (XMLObject xmlObject : scopes) { if (xmlObject instanceof XSAny) { XSAny any = (XSAny) xmlObject; SamlIdpScopeEntity scope = new SamlIdpScopeEntity(); scope.setScope(any.getTextContent()); scope.setRegex(false); scope.setIdp(idp); scopeList.add(scope); } } } return scopeList; }