Search in sources :

Example 1 with EncryptionMethodElement

use of com.sun.identity.saml2.jaxb.metadata.EncryptionMethodElement 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

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