Examples of KeyInfoType


Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier("CN=Test Testarsson");

        registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
        rsaKeyValueType.setExponent(((RSAPublicKey) pkCert.getPublicKey()).getPublicExponent().toByteArray());
        rsaKeyValueType.setModulus(((RSAPublicKey) pkCert.getPublicKey()).getModulus().toByteArray());
        JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
        keyInfoType.getContent().add(rsaKeyValue);
        PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
        prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
        prototypeKeyBindingType.setKeyInfo(keyInfoType);
        prototypeKeyBindingType.setId("100231");
        registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier("CN=Test Testarsson");

        registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
        rsaKeyValueType.setExponent(((RSAPublicKey) keyPair.getPublic()).getPublicExponent().toByteArray());
        rsaKeyValueType.setModulus(((RSAPublicKey) keyPair.getPublic()).getModulus().toByteArray());
        JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
        keyInfoType.getContent().add(rsaKeyValue);
        PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
        prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
        prototypeKeyBindingType.setKeyInfo(keyInfoType);
        prototypeKeyBindingType.setId("100231");
        registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("130");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        X509DataType x509DataType = sigFactory.createX509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(cert1.getEncoded()));
        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
        queryKeyBindingType.setKeyInfo(keyInfoType);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        LocateResultType locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertEquals("Wrong number of UnverifiedKeyBinding.", 1, locateResultType.getUnverifiedKeyBinding().size());
        List<UnverifiedKeyBindingType> numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        Iterator<UnverifiedKeyBindingType> iter = numberOfUnverifiedKeyBindings.iterator();
        KeyInfoType keyInfoType;
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            assertTrue(keyInfoType.getContent().size() > 0);
            JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyInfoType.getContent().get(0);
            Iterator iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();
            while (iter2.hasNext()) {
                JAXBElement next = (JAXBElement) iter2.next();
                assertTrue(next.getName().getLocalPart().equals("X509Certificate"));
                byte[] encoded = (byte[]) next.getValue();
                Certificate nextCert = CertTools.getCertfromByteArray(encoded);
                assertTrue(CertTools.stringToBCDNString(CertTools.getSubjectDN(nextCert)).equals(CertTools.stringToBCDNString(dn2)));
            }

        }
        // Test with return with values, first check that certificate chain is
        // returning
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("132");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
        numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        iter = numberOfUnverifiedKeyBindings.iterator();
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            log.info("keyInfoType: " + keyInfoType.getContent().size());
            /*
             * <?xml version="1.0" ?> <S:Envelope xmlns:S =
             * "http://schemas.xmlsoap.org/soap/envelope/"> <S:Body>
             * <LocateResult xmlns = "http://www.w3.org/2002/03/xkms#" xmlns:ds
             * = "http://www.w3.org/2000/09/xmldsig#" xmlns:xenc =
             * "http://www.w3.org/2001/04/xmlenc#" Id = "_8571741123489298416"
             * RequestId = "132" ResultMajor =
             * "http://www.w3.org/2002/03/xkms#Success" Service =
             * "http://localhost:8080/ejbca/xkms/xkms"> <UnverifiedKeyBinding Id
             * = "_77028bb8eacaafcc"> <ds:KeyInfo> <ds:X509Data>
             * <ds:X509Certificate>
             * MIIDUzCCAjugAwIBAgIISnDjPdYPdp0wDQYJKoZIhvcNAQELBQAwNzERMA8GA1UEAwwIQWRtaW5DQTExFTATBgNVBAoMDEVKQkNBIFNhbXBsZTELMAkGA1UEBhMCU0UwHhcNMDkwMjA5MDM0NzE1WhcNMTkwMjA3MDM0NzE1WjA3MREwDwYDVQQDDAhBZG1pbkNBMTEVMBMGA1UECgwMRUpCQ0EgU2FtcGxlMQswCQYDVQQGEwJTRTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJIgd
             * +/tqTi3MD1QQsxMZG4uFBK3tp1B8LfFreomTz/
             * xewxii8IpfdQCKxIi7YxzNztLE9v6YWZwrgRJNby8ryDE
             * +mbUWJPu+i66gr6qQy6BYgWNxVMhOKE6d3hmmo5js31sXQ
             * +KY8qz+pM7ukh56xm0GpiNo8t34R7IOZz25KwH
             * +cqrBLDQbkwB/dCQIZmu4/cNxsAJ4lxEsmHkSU6xbRBM5gHLY
             * /mHHuMSptexSeGSC9B7bhMBj31TX4gUmOTz08WA
             * +g7mh4H4QJky0uuHMOJelGTvjdzuiNBImpUendw82llHgbo0zp
             * +wDB9SeHSTC9NnyWbw06O4/
             * CN2vtVZO0UCAwEAAaNjMGEwHQYDVR0OBBYEFMGhHG8TfrEn4kK3ilLiz4zac4tuMA8GA1UdEwEB
             * /
             * wQFMAMBAf8wHwYDVR0jBBgwFoAUwaEcbxN+sSfiQreKUuLPjNpzi24wDgYDVR0PAQH
             * /BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQBX+aHR4T/AeBtoFQdOCdJlvOV9yu/
             * FUTmvogCTG
             * +WDfueVhx7Iap3ZJvPX/h4Q46ax3dy2s0hJMHH6ZA9ve9OANgntIMVP00Ly0Mf
             * +EnTmYkIF34hUk6UoEvTUUUAHJP1m
             * /v8Gm03f+f0QzSpw3AB0ydYTGUHp3cAM6LCE1mgcOMcaxcZBdm
             * +XwyXRUrnuWrKiINhtHjVTm04kgQJIq8lxOrxTVJIBNsgXGjbVkAX0
             * /BXckCLo28Ma70F99kmOz4SBOaqWvl
             * +w8kKwbKgXEp4VXmKSJ4QA6Fugdp20PcUey0EnRnb8CmlGBePOYcM7Lu8Xnqqzd
             * +S3CA9ME5kAYK+j</ds:X509Certificate><ds:X509Certificate>
             * MIIDYjCCAkqgAwIBAgIIdwKLuOrKr8wwDQYJKoZIhvcNAQELBQAwNzERMA8GA1UEAwwIQWRtaW5DQTExFTATBgNVBAoMDEVKQkNBIFNhbXBsZTELMAkGA1UEBhMCU0UwHhcNMDkwMjA5MDU0OTE5WhcNMTEwMjA5MDU0OTE5WjA7MRswGQYDVQQDDBJ4a21zdGVzdHVzZXItOTk1LTIxDzANBgNVBAoMBkFuYVRvbTELMAkGA1UEBhMCU0UwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJdUlNuxmqUHuHRHXaER3DdHvjSxIBjdxoA7oiDnaKJNGLCKf3P2f42I0Musqnu0Fisl7v063b
             * +6DjH5MWeyif2/dZlCtrJS+
             * Gikf6mKyspE139XnoFsYtAq4R5aj01o52cXOGOgslbSdwoPcGKaqTmMR7TLQvMXZwQOc0hBhEtNAgMBAAGjgfEwge4wHQYDVR0OBBYEFDz8G13jKOWsCQ8ywBc7AQw1BR1VMAwGA1UdEwEB
             * /wQCMAAwHwYDVR0jBBgwFoAUwaEcbxN+sSfiQreKUuLPjNpzi24wDgYDVR0PAQH/
             * BAQDAgZAMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDBDBvBgNVHREEaDBmgRl4a21zdGVzdHVzZXItOTk1LTJAZm9vLnNlght4a21zdGVzdHVzZXItOTk1LTIudGVzdC5jb22GJmh0dHA6Ly93d3cudGVzdC5jb20veGttc3Rlc3R1c2VyLTk5NS0yhwQKAAABMA0GCSqGSIb3DQEBCwUAA4IBAQAgDS5TOV7sza9ZD8l6UWxkffBvLF8JuHbVDyDYhukehTWKPn6JyLQOut17PedGykvwBQrP3lBeoHxzd9kVw906IiI
             * +SoIoNGR9HkNdBQksqZu9Stt0F3qbK69qBtZLlA2mwUPxIrI0iLTZ+
             * Qm46zG0Ixsj8ux8UbomH6JYdDsTwuePJFurkYxQmTdx
             * /cGwltp49q+FqoMIL4RjpM1R5WguIKuEvk9E51EA59GOMEbXI374lrlxcvmjSbvv4
             * /
             * SQvqn0CUZgMu+rvWhC1su6FAOI438vS6itGovwZLV/rlqsrbWmsdD3wuj9LGADLX+
             * EP2GFvuWiuLzYzfZ1CppakW1e</ds:X509Certificate> </ds:X509Data>
             * </ds:KeyInfo>
             * <KeyUsage>http://www.w3.org/2002/03/xkms#Signature</KeyUsage>
             * <UseKeyWith Application = "urn:ietf:rfc:2487" Identifier =
             * "xkmstestuser-995-2.test.com"></UseKeyWith> <ValidityInterval
             * NotBefore = "2009-02-09T14:49:19.000+09:00" NotOnOrAfter =
             * "2011-02-09T14:49:19.000+09:00"></ValidityInterval>
             * </UnverifiedKeyBinding> </LocateResult> </S:Body> </S:Envelope>
             */
            // modified by dai 20090209
            // return xml is above, so I think keyInfoType.getContent().size()
            // should be 1 if the xml is correct.
            // assertTrue(keyInfoType.getContent().size() > 1 );
            assertTrue(keyInfoType.getContent().size() > 0);
            JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyInfoType.getContent().get(0);
            assertTrue(jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().size() == 2);
            Iterator iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();
            while (iter2.hasNext()) {
                JAXBElement next = (JAXBElement) iter2.next();
                assertTrue(next.getName().getLocalPart().equals("X509Certificate"));
                byte[] encoded = (byte[]) next.getValue();
                Certificate nextCert = CertTools.getCertfromByteArray(encoded);
                assertTrue(CertTools.stringToBCDNString(CertTools.getSubjectDN(nextCert)).equals(CertTools.stringToBCDNString(dn2))
                        || CertTools.stringToBCDNString(CertTools.getSubjectDN(nextCert)).equals(CertTools.stringToBCDNString(issuerdn)));
            }

        }

        // Test with returnwith values, require both cert and chain in answer
        // check that just chain is returned
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("133");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
        numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        iter = numberOfUnverifiedKeyBindings.iterator();
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            // modified by dai 20090209 same as above
            // assertTrue(keyInfoType.getContent().size() > 1 );
            assertTrue(keyInfoType.getContent().size() > 0);
            JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyInfoType.getContent().get(0);
            assertTrue(jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().size() == 2);
            Iterator iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();
            while (iter2.hasNext()) {
                JAXBElement next = (JAXBElement) iter2.next();
                // log.debug("next.getName().getLocalPart(): "+next.getName().getLocalPart());
                assertTrue(next.getName().getLocalPart().equals("X509Certificate"));
                byte[] encoded = (byte[]) next.getValue();
                Certificate nextCert = CertTools.getCertfromByteArray(encoded);
                assertTrue(CertTools.stringToBCDNString(CertTools.getSubjectDN(nextCert)).equals(CertTools.stringToBCDNString(dn2))
                        || CertTools.stringToBCDNString(CertTools.getSubjectDN(nextCert)).equals(CertTools.stringToBCDNString(issuerdn)));
            }

        }

        // Test with returnwith values, require crl in answer
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("134");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CRL);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
        numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        iter = numberOfUnverifiedKeyBindings.iterator();
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            // modified by dai 20090209 same as above
            // assertTrue(keyInfoType.getContent().size() > 1 );
            assertTrue(keyInfoType.getContent().size() > 0);
            JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyInfoType.getContent().get(0);
            assertTrue(jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().size() == 1);
            Iterator iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();
            while (iter2.hasNext()) {
                JAXBElement next = (JAXBElement) iter2.next();
                assertTrue(next.getName().getLocalPart().equals("X509CRL"));
                byte[] encoded = (byte[]) next.getValue();
                X509CRL nextCRL = CertTools.getCRLfromByteArray(encoded);
                assertTrue(CertTools.stringToBCDNString(nextCRL.getIssuerDN().toString()).equals(CertTools.stringToBCDNString(issuerdn)));
            }
        }

        // Test with returnwith values, require certchain and crl in answer
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("135");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CRL);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
        numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        iter = numberOfUnverifiedKeyBindings.iterator();
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            // modified by dai 20090209 same as above
            // assertTrue(keyInfoType.getContent().size() > 1 );
            assertTrue(keyInfoType.getContent().size() > 0);
            JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyInfoType.getContent().get(0);
            assertTrue(jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().size() == 3);
            Iterator iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();
            while (iter2.hasNext()) {
                JAXBElement next = (JAXBElement) iter2.next();
                if (next.getName().getLocalPart().equals("X509CRL")) {
                    byte[] encoded = (byte[]) next.getValue();
                    X509CRL nextCRL = CertTools.getCRLfromByteArray(encoded);
                    assertTrue(CertTools.stringToBCDNString(nextCRL.getIssuerDN().toString()).equals(CertTools.stringToBCDNString(issuerdn)));
                }
                if (next.getName().getLocalPart().equals("X509Certificate")) {
                    byte[] encoded = (byte[]) next.getValue();
                    Certificate nextCert = CertTools.getCertfromByteArray(encoded);
                    assertTrue(CertTools.stringToBCDNString(CertTools.getSubjectDN(nextCert)).equals(CertTools.stringToBCDNString(dn2))
                            || CertTools.stringToBCDNString(CertTools.getSubjectDN(nextCert)).equals(CertTools.stringToBCDNString(issuerdn)));
                }
            }
        }

        // Test with returnwith values, require keyname in answer
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("135");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_KEYNAME);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
        numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        iter = numberOfUnverifiedKeyBindings.iterator();
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            // modified by dai 20090209 same as above
            // assertTrue(keyInfoType.getContent().size() > 1 );
            assertTrue(keyInfoType.getContent().size() > 0);
            JAXBElement<String> jAXBString = (JAXBElement<String>) keyInfoType.getContent().get(0);
            assertTrue(jAXBString.getName().getLocalPart().equals("KeyName"));
            assertTrue(CertTools.stringToBCDNString(jAXBString.getValue()) + " = " + CertTools.stringToBCDNString(dn2), CertTools.stringToBCDNString(
                    jAXBString.getValue()).equals(CertTools.stringToBCDNString(dn2)));
        }

        // Test with returnwith values, require public key in answer
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("135");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_KEYVALUE);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
        numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        iter = numberOfUnverifiedKeyBindings.iterator();
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            assertTrue("" + keyInfoType.getContent().size(), keyInfoType.getContent().size() > 0);
            JAXBElement<KeyValueType> jAXBKeyValue = (JAXBElement<KeyValueType>) keyInfoType.getContent().get(0);
            assertTrue(jAXBKeyValue.getName().getLocalPart(), jAXBKeyValue.getName().getLocalPart().equals("KeyValue"));
            // modified by dai 20090209 same as above
            // assertTrue(""+jAXBKeyValue.getValue().getContent().size(),jAXBKeyValue.getValue().getContent().size()
            // > 1);
            assertTrue("" + jAXBKeyValue.getValue().getContent().size(), jAXBKeyValue.getValue().getContent().size() > 0);
            JAXBElement<RSAKeyValueType> rSAKeyValueType = (JAXBElement<RSAKeyValueType>) jAXBKeyValue.getValue().getContent().get(0);
            assertTrue(rSAKeyValueType.getName().getLocalPart(), rSAKeyValueType.getName().getLocalPart().equals("RSAKeyValue"));
            BigInteger exp = new BigInteger(rSAKeyValueType.getValue().getExponent());
            BigInteger modulus = new BigInteger(rSAKeyValueType.getValue().getModulus());
            assertTrue(((RSAPublicKey) cert2.getPublicKey()).getModulus().equals(modulus));
            assertTrue(((RSAPublicKey) cert2.getPublicKey()).getPublicExponent().equals(exp));
        }

        // Test with returnwith one invalid values
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("136");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_RETRIEVALMETHOD);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SENDER));
        assertTrue(locateResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED));

        // Test with returnwith many invalid values
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("137");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_RETRIEVALMETHOD);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PGP);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PGPWEB);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_SPKI);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PRIVATEKEY);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SENDER));
        assertTrue(locateResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED));

        // Test with many invalid values and one certificate
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("138");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_RETRIEVALMETHOD);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PGP);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PGPWEB);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_SPKI);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PRIVATEKEY);

        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
        numberOfUnverifiedKeyBindings = locateResultType.getUnverifiedKeyBinding();
        iter = numberOfUnverifiedKeyBindings.iterator();

        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            keyInfoType = nextKeyBinding.getKeyInfo();
            assertTrue(keyInfoType.getContent().size() > 0);
            JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyInfoType.getContent().get(0);
            Iterator iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();
            while (iter2.hasNext()) {
                JAXBElement next = (JAXBElement) iter2.next();
                assertTrue(next.getName().getLocalPart().equals("X509Certificate"));
                byte[] encoded = (byte[]) next.getValue();
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        validateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);

        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        X509DataType x509DataType = sigFactory.createX509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(cert1.getEncoded()));
        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
        queryKeyBindingType.setKeyInfo(keyInfoType);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        validateRequestType.setQueryKeyBinding(queryKeyBindingType);

        validateResultType = xKMSInvoker.validate(validateRequestType, null, null);

        assertTrue(validateResultType.getKeyBinding().size() > 0);
        assertTrue(validateResultType.getKeyBinding().get(0).getStatus().getValidReason().contains(XKMSConstants.STATUSREASON_VALIDITYINTERVAL));
        assertTrue(validateResultType.getKeyBinding().get(0).getStatus().getValidReason().contains(XKMSConstants.STATUSREASON_ISSUERTRUST));
        assertTrue(validateResultType.getKeyBinding().get(0).getStatus().getValidReason().contains(XKMSConstants.STATUSREASON_SIGNATURE));
        assertTrue(validateResultType.getKeyBinding().get(0).getStatus().getValidReason().contains(XKMSConstants.STATUSREASON_REVOCATIONSTATUS));

        // Test with unknown certificate.
        validateRequestType = xKMSObjectFactory.createValidateRequestType();
        validateRequestType.setId("202");

        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier(username1);

        validateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);

        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        x509DataType = sigFactory.createX509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(certbytes));
        keyInfoType = sigFactory.createKeyInfoType();
        keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
        queryKeyBindingType.setKeyInfo(keyInfoType);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        validateRequestType.setQueryKeyBinding(queryKeyBindingType);

        validateResultType = xKMSInvoker.validate(validateRequestType, null, null);

        assertTrue(validateResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS));
        assertTrue(validateResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_NOMATCH));

        // Revoke certificate
        Admin administrator = new Admin(Admin.TYPE_RA_USER);
        certificateStoreSession.revokeCertificate(administrator, cert1, new ArrayList(), RevokedCertInfo.REVOCATION_REASON_UNSPECIFIED, null);
        // Validate with revoked certificate
        validateRequestType = xKMSObjectFactory.createValidateRequestType();
        validateRequestType.setId("203");

        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier(username1);

        validateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);

        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        x509DataType = sigFactory.createX509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(cert1.getEncoded()));
        keyInfoType = sigFactory.createKeyInfoType();
        keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
        queryKeyBindingType.setKeyInfo(keyInfoType);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        validateRequestType.setQueryKeyBinding(queryKeyBindingType);

        validateResultType = xKMSInvoker.validate(validateRequestType, null, null);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn);

        registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
        rsaKeyValueType.setExponent(((RSAPublicKey) keys1.getPublic()).getPublicExponent().toByteArray());
        rsaKeyValueType.setModulus(((RSAPublicKey) keys1.getPublic()).getModulus().toByteArray());
        JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
        keyInfoType.getContent().add(rsaKeyValue);
        PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
        prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
        prototypeKeyBindingType.setKeyInfo(keyInfoType);
        prototypeKeyBindingType.setId("100231");
        registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier("CN=wrong");

        registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
        rsaKeyValueType.setExponent(((RSAPublicKey) keys3.getPublic()).getPublicExponent().toByteArray());
        rsaKeyValueType.setModulus(((RSAPublicKey) keys3.getPublic()).getModulus().toByteArray());
        JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
        keyInfoType.getContent().add(rsaKeyValue);
        PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
        prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
        prototypeKeyBindingType.setKeyInfo(keyInfoType);
        prototypeKeyBindingType.setId("100231");
        registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn1);

        registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
        rsaKeyValueType.setExponent(((RSAPublicKey) keys.getPublic()).getPublicExponent().toByteArray());
        rsaKeyValueType.setModulus(((RSAPublicKey) keys.getPublic()).getModulus().toByteArray());
        JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
        keyInfoType.getContent().add(rsaKeyValue);
        PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
        prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
        prototypeKeyBindingType.setKeyInfo(keyInfoType);
        prototypeKeyBindingType.setId("100231");
        registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn3);

        registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
        rsaKeyValueType.setExponent(((RSAPublicKey) keys.getPublic()).getPublicExponent().toByteArray());
        rsaKeyValueType.setModulus(((RSAPublicKey) keys.getPublic()).getModulus().toByteArray());
        JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
        keyInfoType.getContent().add(rsaKeyValue);
        PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
        prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
        prototypeKeyBindingType.setKeyInfo(keyInfoType);
        prototypeKeyBindingType.setId("100231");
        registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
View Full Code Here

Examples of org.w3._2000._09.xmldsig_.KeyInfoType

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn3);

        registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);

        KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
        RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
        rsaKeyValueType.setExponent(((RSAPublicKey) keys.getPublic()).getPublicExponent().toByteArray());
        rsaKeyValueType.setModulus(((RSAPublicKey) keys.getPublic()).getModulus().toByteArray());
        JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
        keyInfoType.getContent().add(rsaKeyValue);
        PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
        prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
        prototypeKeyBindingType.setKeyInfo(keyInfoType);
        prototypeKeyBindingType.setId("100231");
        registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.