@Test public void testNoUseKeyDescriptorEntityDescriptor() throws SAML2MetaException, JAXBException { String idpMetadata = XMLUtils.print( XMLUtils.toDOMDocument(ClassLoader.getSystemResourceAsStream(XML_DOCUMENT_TO_LOAD), SAML2Utils.debug), "UTF-8"); EntityDescriptorElement element = SAML2MetaUtils.getEntityDescriptorElement(idpMetadata); List descriptors = element.getRoleDescriptorOrIDPSSODescriptorOrSPSSODescriptor(); for (Object descriptor : descriptors) { if (descriptor instanceof IDPSSODescriptorElement) { KeyDescriptorType type = KeyUtil.getKeyDescriptor((IDPSSODescriptorElement)descriptor, "signing"); Assert.assertNotNull(type); break; } } }
public static KeyDescriptorType getKeyDescriptor( RoleDescriptorType roled, String usage ) { List list = roled.getKeyDescriptor(); Iterator iter = list.iterator(); KeyDescriptorType kd = null; String use = null; KeyDescriptorType noUsageKD = null; while (iter.hasNext()) { kd = (KeyDescriptorType)iter.next(); use = kd.getUse(); if ((use == null) || (use.trim().length() == 0)) { if (noUsageKD == null) { noUsageKD = kd; } continue; } if (use.trim().toLowerCase().equals(usage)) { break; } else { kd = null; } } if (kd != null) { return kd; } else { return noUsageKD; } }
KeyUtil { public static KeyDescriptorType getKeyDescriptor( RoleDescriptorType roled, String usage ) { List list = roled.getKeyDescriptor(); Iterator iter = list.iterator(); KeyDescriptorType kd = null; String use = null; KeyDescriptorType noUsageKD = null; while (iter.hasNext()) { kd = (KeyDescriptorType)iter.next(); use = kd.getUse(); if ((use == null) || (use.trim().length() == 0)) { if (noUsageKD == null) { noUsageKD = kd; } continue; } if (use.trim().toLowerCase().equals(usage)) { break; } else { kd = null; } } if (kd != null) { return kd; } else { return noUsageKD; } } }
KeyUtil { public static KeyDescriptorType getKeyDescriptor( RoleDescriptorType roled, String usage ) { List list = roled.getKeyDescriptor(); Iterator iter = list.iterator(); KeyDescriptorType kd = null; String use = null; KeyDescriptorType noUsageKD = null; while (iter.hasNext()) { kd = (KeyDescriptorType)iter.next(); use = kd.getUse(); if ((use == null) || (use.trim().length() == 0)) { if (noUsageKD == null) { noUsageKD = kd; } continue; } if (use.trim().toLowerCase().equals(usage)) { break; } else { kd = null; } } if (kd != null) { return kd; } else { return noUsageKD; } } private  KeyUtil(); }
KeyUtil { public static KeyDescriptorType getKeyDescriptor( RoleDescriptorType roled, String usage ) { List list = roled.getKeyDescriptor(); Iterator iter = list.iterator(); KeyDescriptorType kd = null; String use = null; KeyDescriptorType noUsageKD = null; while (iter.hasNext()) { kd = (KeyDescriptorType)iter.next(); use = kd.getUse(); if ((use == null) || (use.trim().length() == 0)) { if (noUsageKD == null) { noUsageKD = kd; } continue; } if (use.trim().toLowerCase().equals(usage)) { break; } else { kd = null; } } if (kd != null) { return kd; } else { return noUsageKD; } } private  KeyUtil(); static KeyProvider getKeyProviderInstance(); static String getSigningCertAlias(BaseConfigType baseConfig); static PrivateKey getDecryptionKey(BaseConfigType baseConfig); static X509Certificate getVerificationCert(
        RoleDescriptorType roled,
        String entityID,
        String role
    ); static EncInfo getEncInfo(
        RoleDescriptorType roled,
        String entityID,
        String role
    ); static KeyDescriptorType getKeyDescriptor(
        RoleDescriptorType roled,
        String usage
    ); static java.security.cert.X509Certificate getCert(
        KeyDescriptorType kd
    ); static X509Certificate getPEPVerificationCert(
        XACMLAuthzDecisionQueryDescriptorElement pepDesc,String entityID); static KeyDescriptorType getKeyDescriptor(List kdList,String usage); static EncInfo getPEPEncInfo(
       XACMLAuthzDecisionQueryDescriptorElement pepDesc,String pepEntityID); static X509Certificate getPDPVerificationCert(
        XACMLPDPDescriptorElement pdpDesc,String entityID); static void clear(); }
KeyUtil { public static KeyDescriptorType getKeyDescriptor( RoleDescriptorType roled, String usage ) { List list = roled.getKeyDescriptor(); Iterator iter = list.iterator(); KeyDescriptorType kd = null; String use = null; KeyDescriptorType noUsageKD = null; while (iter.hasNext()) { kd = (KeyDescriptorType)iter.next(); use = kd.getUse(); if ((use == null) || (use.trim().length() == 0)) { if (noUsageKD == null) { noUsageKD = kd; } continue; } if (use.trim().toLowerCase().equals(usage)) { break; } else { kd = null; } } if (kd != null) { return kd; } else { return noUsageKD; } } private  KeyUtil(); static KeyProvider getKeyProviderInstance(); static String getSigningCertAlias(BaseConfigType baseConfig); static PrivateKey getDecryptionKey(BaseConfigType baseConfig); static X509Certificate getVerificationCert(
        RoleDescriptorType roled,
        String entityID,
        String role
    ); static EncInfo getEncInfo(
        RoleDescriptorType roled,
        String entityID,
        String role
    ); static KeyDescriptorType getKeyDescriptor(
        RoleDescriptorType roled,
        String usage
    ); static java.security.cert.X509Certificate getCert(
        KeyDescriptorType kd
    ); static X509Certificate getPEPVerificationCert(
        XACMLAuthzDecisionQueryDescriptorElement pepDesc,String entityID); static KeyDescriptorType getKeyDescriptor(List kdList,String usage); static EncInfo getPEPEncInfo(
       XACMLAuthzDecisionQueryDescriptorElement pepDesc,String pepEntityID); static X509Certificate getPDPVerificationCert(
        XACMLPDPDescriptorElement pdpDesc,String entityID); static void clear();  }