Search in sources :

Example 1 with X509IssuerSerialType

use of org.apache.cxf.xkms.model.xmldsig.X509IssuerSerialType in project cxf by apache.

the class X509Locator method parse.

private List<UseKeyWithType> parse(KeyInfoType keyInfo) {
    List<UseKeyWithType> keyIDs = new ArrayList<>();
    if (keyInfo == null) {
        return keyIDs;
    }
    List<Object> content = keyInfo.getContent();
    for (Object obj1 : content) {
        if (obj1 instanceof JAXBElement) {
            JAXBElement<?> keyInfoChild = (JAXBElement<?>) obj1;
            if (X509Utils.X509_KEY_NAME.equals(keyInfoChild.getName())) {
                UseKeyWithType keyDN = new UseKeyWithType();
                keyDN.setApplication(Applications.PKIX.getUri());
                keyDN.setIdentifier((String) keyInfoChild.getValue());
                keyIDs.add(keyDN);
            } else if (X509Utils.X509_DATA.equals(keyInfoChild.getName())) {
                X509DataType x509Data = (X509DataType) keyInfoChild.getValue();
                List<Object> x509DataContent = x509Data.getX509IssuerSerialOrX509SKIOrX509SubjectName();
                for (Object obj2 : x509DataContent) {
                    if (obj2 instanceof JAXBElement) {
                        JAXBElement<?> x509DataChild = (JAXBElement<?>) obj2;
                        if (X509Utils.X509_ISSUER_SERIAL.equals(x509DataChild.getName())) {
                            X509IssuerSerialType x509IssuerSerial = (X509IssuerSerialType) x509DataChild.getValue();
                            UseKeyWithType issuer = new UseKeyWithType();
                            issuer.setApplication(Applications.ISSUER.getUri());
                            issuer.setIdentifier(x509IssuerSerial.getX509IssuerName());
                            keyIDs.add(issuer);
                            UseKeyWithType serial = new UseKeyWithType();
                            serial.setApplication(Applications.SERIAL.getUri());
                            serial.setIdentifier(x509IssuerSerial.getX509SerialNumber().toString());
                            keyIDs.add(serial);
                        } else if (X509Utils.X509_SUBJECT_NAME.equals(x509DataChild.getName())) {
                            UseKeyWithType keyDN = new UseKeyWithType();
                            keyDN.setApplication(Applications.PKIX.getUri());
                            keyDN.setIdentifier((String) x509DataChild.getValue());
                            keyIDs.add(keyDN);
                        }
                    }
                }
            }
        }
    }
    return keyIDs;
}
Also used : X509DataType(org.apache.cxf.xkms.model.xmldsig.X509DataType) UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JAXBElement(javax.xml.bind.JAXBElement) X509IssuerSerialType(org.apache.cxf.xkms.model.xmldsig.X509IssuerSerialType)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 JAXBElement (javax.xml.bind.JAXBElement)1 UseKeyWithType (org.apache.cxf.xkms.model.xkms.UseKeyWithType)1 X509DataType (org.apache.cxf.xkms.model.xmldsig.X509DataType)1 X509IssuerSerialType (org.apache.cxf.xkms.model.xmldsig.X509IssuerSerialType)1