Search in sources :

Example 1 with KeyDescriptorElement

use of com.sun.identity.saml2.jaxb.metadata.KeyDescriptorElement in project OpenAM by OpenRock.

the class SAML2MetaSecurityUtils method removeKeyDescriptor.

private static void removeKeyDescriptor(RoleDescriptorType desp, boolean isSigningUse) {
    List keys = desp.getKeyDescriptor();
    for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
        KeyDescriptorElement key = (KeyDescriptorElement) iter.next();
        String keyUse = "encryption";
        if (isSigningUse) {
            keyUse = "signing";
        }
        if ((key.getUse() != null) && key.getUse().equalsIgnoreCase(keyUse)) {
            iter.remove();
        }
    }
}
Also used : Iterator(java.util.Iterator) NodeList(org.w3c.dom.NodeList) List(java.util.List) KeyDescriptorElement(com.sun.identity.saml2.jaxb.metadata.KeyDescriptorElement)

Example 2 with KeyDescriptorElement

use of com.sun.identity.saml2.jaxb.metadata.KeyDescriptorElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method getKeyandAlgorithm.

/**
     * retrieves the encryption key size and algorithm
     *
     * @param ssodescriptor the SSODescriptorType which can be idpsso/spsso.
     * @param map the Map which contains the attribute/value pairs.
     */
private void getKeyandAlgorithm(SSODescriptorType ssodescriptor, Map map) {
    List keyList = ssodescriptor.getKeyDescriptor();
    for (int i = 0; i < keyList.size(); i++) {
        KeyDescriptorElement keyOne = (KeyDescriptorElement) keyList.get(i);
        String type = keyOne.getUse();
        if ((type == null) || (type.length() == 0) || type.equals("encryption")) {
            List encryptMethod = keyOne.getEncryptionMethod();
            if (!encryptMethod.isEmpty()) {
                EncryptionMethodElement encrptElement = (EncryptionMethodElement) encryptMethod.get(0);
                String alg = encrptElement.getAlgorithm();
                String size = null;
                List keySizeList = encrptElement.getContent();
                if (!keySizeList.isEmpty()) {
                    for (Iterator itt = keySizeList.listIterator(); itt.hasNext(); ) {
                        Object encrptType = (Object) itt.next();
                        if (encrptType.getClass().getName().contains("KeySizeImpl")) {
                            EncryptionMethodType.KeySize keysizeElem = (EncryptionMethodType.KeySize) keySizeList.get(0);
                            BigInteger keysize = keysizeElem.getValue();
                            size = Integer.toString(keysize.intValue());
                        }
                    }
                }
                map.put(TF_KEY_NAME, returnEmptySetIfValueIsNull(size));
                map.put(TF_ALGORITHM, returnEmptySetIfValueIsNull(alg));
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) EncryptionMethodType(com.sun.identity.saml2.jaxb.xmlenc.EncryptionMethodType) BigInteger(java.math.BigInteger) List(java.util.List) ArrayList(java.util.ArrayList) KeyDescriptorElement(com.sun.identity.saml2.jaxb.metadata.KeyDescriptorElement) EncryptionMethodElement(com.sun.identity.saml2.jaxb.metadata.EncryptionMethodElement)

Aggregations

KeyDescriptorElement (com.sun.identity.saml2.jaxb.metadata.KeyDescriptorElement)2 Iterator (java.util.Iterator)2 List (java.util.List)2 EncryptionMethodElement (com.sun.identity.saml2.jaxb.metadata.EncryptionMethodElement)1 EncryptionMethodType (com.sun.identity.saml2.jaxb.xmlenc.EncryptionMethodType)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 NodeList (org.w3c.dom.NodeList)1