Package org.w3._2002._03.xkms_

Examples of org.w3._2002._03.xkms_.UnverifiedKeyBindingType


    public void test05LocateAndReturnWith() throws Exception {
        // Test with returnwith values, first check that certificate is
        // returning
        LocateRequestType locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("131");
        QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        UseKeyWithType useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);

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

        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();
View Full Code Here


    public void test06LocateAndKeyUsage() throws Exception {
        // request with Signature and expect signature
        LocateRequestType locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("139");
        QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        UseKeyWithType useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");

        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        queryKeyBindingType.getKeyUsage().add(XKMSConstants.KEYUSAGE_SIGNATURE);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        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();
        while (iter.hasNext()) {
            UnverifiedKeyBindingType nextKeyBinding = iter.next();
            assertTrue(nextKeyBinding.getKeyUsage().size() == 1);
            assertTrue(nextKeyBinding.getKeyUsage().contains(XKMSConstants.KEYUSAGE_SIGNATURE));
        }

        // request with Signature and receive noMatch
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("140");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn1);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        queryKeyBindingType.getKeyUsage().add(XKMSConstants.KEYUSAGE_SIGNATURE);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        /*
         * <?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 = "_1669649196518103469"
         * RequestId = "140" ResultMajor =
         * "http://www.w3.org/2002/03/xkms#Success" Service =
         * "http://localhost:8080/ejbca/xkms/xkms"> <UnverifiedKeyBinding Id =
         * "_77cca72c8e066b19"> <ds:KeyInfo> <ds:X509Data>
         * <ds:X509Certificate>MIIDFzCCAf+
         * gAwIBAgIId8ynLI4GaxkwDQYJKoZIhvcNAQELBQAwNzERMA8GA1UEAwwIQWRtaW5DQTExFTATBgNVBAoMDEVKQkNBIFNhbXBsZTELMAkGA1UEBhMCU0UwHhcNMDkwMjA5MDYyNjMyWhcNMTEwMjA5MDYyNjMyWjA7MRswGQYDVQQDDBJ4a21zdGVzdHVzZXItOTAyLTExDzANBgNVBAoMBkFuYVRvbTELMAkGA1UEBhMCU0UwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJJBZdwEN7RCY
         * +46ZnxzrjXOm+h6k/
         * WF6jbt8O5V7YbVr2wL657ivKWBQr8WEEtOheQ9DFFbXq80Adryf8YSRDz4DL5008Fn/
         * LRC5jqCspT6aEhhvSvcvmBEO8YJhR2YhVUHB84p3RD9RvPPRzDsTLXGWScbbjCu1NzdnXX7AGNTAgMBAAGjgaYwgaMwHQYDVR0OBBYEFPYgaKLUO
         * /X7ZC+6Mn3uFzRmTcVwMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUwaEcbxN+
         * sSfiQreKUuLPjNpzi24wDgYDVR0PAQH/
         * BAQDAgXgMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDBDAkBgNVHREEHTAbgRl4a21zdGVzdHVzZXItOTAyLTFAZm9vLnNlMA0GCSqGSIb3DQEBCwUAA4IBAQAcFUxvDxDcNpkvzp2bdntR9HnaljqlUwPWVQROSr5r0h7iS0
         * /ZJ/
         * kFKLuSdBSoVU1nbuOrtlhNC1zdfE6e86IHbFDK8dk6zJRpYRdsoZcmz9k0F9dX9AmILj9aXS3kiSzyF8L0m02siZZF9dMbpXCgFZCQRGFWLxcNAf6BZTS6c92W7
         * +
         * bPS67vVcGujideTiO8Ud0fU1tyu9BtsqpFItnS9N34sm19MC8pLAzaJjoCNmSXcUl0bswe4d3TkzWKlEjfQeNrRwNP1dI8HJEE7Ddr1j8eE8sW9E
         * /
         * IXQP4QINzF7P6psdtqMlevqx7JFUR6Px73Yn2ASJueScyB9l03Ikj</ds:X509Certificate
         * > </ds:X509Data> </ds:KeyInfo>
         * <KeyUsage>http://www.w3.org/2002/03/xkms#Exchange</KeyUsage>
         * <KeyUsage>http://www.w3.org/2002/03/xkms#Signature</KeyUsage>
         * <UseKeyWith Application = "urn:ietf:rfc:2459" Identifier =
         * "C=SE, O=AnaTom, CN=xkmstestuser-902-1"></UseKeyWith>
         * <ValidityInterval NotBefore = "2009-02-09T15:26:32.000+09:00"
         * NotOnOrAfter = "2011-02-09T15:26:32.000+09:00"></ValidityInterval>
         * </UnverifiedKeyBinding> </LocateResult> </S:Body> </S:Envelope>
         */
        // modified by dai 20090209
        // according to the result xml above, there is no resultminor if the
        // resut is success.
        // so assert for resultminor should not be done if succeed case.
        assertTrue(locateResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS));
        // assertTrue(locateResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_NOMATCH));

        // request Exchange or Signature and receive Signature expect Nomatch
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("141");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");

        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        queryKeyBindingType.getKeyUsage().add(XKMSConstants.KEYUSAGE_SIGNATURE);
        queryKeyBindingType.getKeyUsage().add(XKMSConstants.KEYUSAGE_EXCHANGE);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

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

        // request Exchange and that response can be used for both exchange and
        // encryption.
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("142");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn3);

        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        queryKeyBindingType.getKeyUsage().add(XKMSConstants.KEYUSAGE_ENCRYPTION);
        queryKeyBindingType.getKeyUsage().add(XKMSConstants.KEYUSAGE_EXCHANGE);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS));
        assertEquals("locateResultType.getUnverifiedKeyBinding: ", 1, locateResultType.getUnverifiedKeyBinding().size());
View Full Code Here

    public void test07LocateAndResponseLimit() throws Exception {
        // request with 3 and expect 3
        LocateRequestType locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("300");
        QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        UseKeyWithType useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier(baseUsername);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        locateRequestType.setResponseLimit(new BigInteger("3"));

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

        LocateResultType locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertEquals("Wrong number of UnverifiedKeyBinding.", 3, locateResultType.getUnverifiedKeyBinding().size());

        // request with 2 and expect 2
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("301");
        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier(baseUsername);
        locateRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);
        locateRequestType.setResponseLimit(new BigInteger("2"));

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

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS));
        assertTrue(locateResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_TOOMANYRESPONSES));
View Full Code Here

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier(username1);

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

        QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        validateRequestType.setQueryKeyBinding(queryKeyBindingType);

        ValidateResultType 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 known certificate.
        validateRequestType = xKMSObjectFactory.createValidateRequestType();
        validateRequestType.setId("201");

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

        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);

        assertTrue(validateResultType.getKeyBinding().size() > 0);
View Full Code Here

        DocumentBuilder db = dbf.newDocumentBuilder();
        Document rSAKeyPairDoc = db.newDocument();

        SecretKey sk = getSecretKeyFromPassphrase(sharedSecret,true, 24, KEY_PRIVATEKEYDATA);
       
        RSAKeyPairType rSAKeyPairType = xKMSObjectFactory.createRSAKeyPairType();
      
        rSAKeyPairType.setModulus(rSAPrivateKey.getModulus().toByteArray());
        rSAKeyPairType.setExponent(rSAPrivateKey.getPublicExponent().toByteArray());
        rSAKeyPairType.setP(rSAPrivateKey.getPrimeP().toByteArray());
        rSAKeyPairType.setQ(rSAPrivateKey.getPrimeQ().toByteArray());
        rSAKeyPairType.setDP(rSAPrivateKey.getPrimeExponentP().toByteArray());
        rSAKeyPairType.setDQ(rSAPrivateKey.getPrimeExponentQ().toByteArray());
        rSAKeyPairType.setInverseQ(rSAPrivateKey.getCrtCoefficient().toByteArray());
        rSAKeyPairType.setD(rSAPrivateKey.getPrivateExponent().toByteArray());

        JAXBElement<RSAKeyPairType> rSAKeyPair = xKMSObjectFactory.createRSAKeyPair(rSAKeyPairType);

    marshaller.marshal( rSAKeyPair, rSAKeyPairDoc );
View Full Code Here

      
        xmlDecipher.doFinal(privateKeyDoc, encryptedDataElement);
       
        JAXBElement<RSAKeyPairType> rSAKeyPair = (JAXBElement<RSAKeyPairType>) unmarshaller.unmarshal(privateKeyDoc.getDocumentElement().getFirstChild());
       
        RSAKeyPairType rSAKeyPairType = rSAKeyPair.getValue();
       
               
        RSAPrivateCrtKeySpec rSAPrivateKeySpec = new RSAPrivateCrtKeySpec(new BigInteger(rSAKeyPairType.getModulus()), new BigInteger(rSAKeyPairType.getExponent()),
                         new BigInteger(rSAKeyPairType.getD()), new BigInteger(rSAKeyPairType.getP()),
                         new BigInteger(rSAKeyPairType.getQ()), new BigInteger(rSAKeyPairType.getDP()),
                         new BigInteger(rSAKeyPairType.getDQ()), new BigInteger(rSAKeyPairType.getInverseQ()));
       
        privkey2 = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(rSAPrivateKeySpec);
       
    } catch (InvalidKeySpecException e) {
      log.error("Error decrypting private key", e);
View Full Code Here

                outputPath = args[ARG_OUTPUTPATH] + "/";                           
              }
            }

            String reqId = genId();
            RecoverRequestType recoverRequestType = xKMSObjectFactory.createRecoverRequestType();
            recoverRequestType.setId(reqId);
            recoverRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);           
            recoverRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PRIVATEKEY);
           
            X509DataType x509DataType = sigFactory.createX509DataType();
            x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(orgCert.getEncoded()));
            KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
            keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
           
            String keyBindingId = "_" + CertTools.getSerialNumber(orgCert).toString();
            KeyBindingType keyBindingType = xKMSObjectFactory.createKeyBindingType();               
            keyBindingType.setKeyInfo(keyInfoType);
            keyBindingType.setId(keyBindingId);
            recoverRequestType.setRecoverKeyBinding(keyBindingType)
           
          
           
            RecoverResultType recoverResultType = getXKMSInvoker().recover(recoverRequestType, clientCert, privateKey, password,  keyBindingId);
View Full Code Here

   * Returns a register response
   */
  public RecoverResultType getResponse(boolean requestVerifies){
    RecoverResultType result = xkmsFactory.createRecoverResultType();   
    super.populateResponse(result, requestVerifies);   
    RecoverRequestType req = (RecoverRequestType) this.req;
   

    if(resultMajor == null){    
      if(!checkValidRespondWithRequest(req.getRespondWith(),false)){
        resultMajor = XKMSConstants.RESULTMAJOR_SENDER;
        resultMinor = XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED;
      }

      if(resultMajor == null){        
        if(resultMajor == null){
          X509Certificate cert = (X509Certificate) getPublicKeyInfo(req, false);         
         
          UserDataVO userData = findUserData(cert);
          if(userData != null){
            String password = ""
            boolean encryptedPassword = isPasswordEncrypted(req);
            if(encryptedPassword){
              password = getEncryptedPassword(requestDoc, userData.getPassword());
            }else{
              password = getClearPassword(req, userData.getPassword());
            }

            if(password != null ){
              X509Certificate newCert = registerReissueOrRecover(true,false, result, userData,password,  cert.getPublicKey(), null);
              if(newCert != null){
                KeyBindingAbstractType keyBinding = getResponseValues(req.getRecoverKeyBinding(), newCert, false, true);
                result.getKeyBinding().add((KeyBindingType) keyBinding);
              }
            }
          }

View Full Code Here

            keyBindingType.setId(keyBindingId);
            recoverRequestType.setRecoverKeyBinding(keyBindingType)
           
          
           
            RecoverResultType recoverResultType = getXKMSInvoker().recover(recoverRequestType, clientCert, privateKey, password,  keyBindingId);

           
            if(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS) &&
               recoverResultType.getResultMinor() == null){
           
                if(recoverResultType.getKeyBinding().size() >0){
                  KeyBindingType keyBinding = recoverResultType.getKeyBinding().get(0);                 
                  List certs = getCertsFromKeyBinding(keyBinding);
                   
                  X509Certificate userCert = getUserCert(certs);                 
                  certs.remove(userCert);
                 
                  if(recoverResultType.getPrivateKey() != null){
                    PrivateKey serverKey = XKMSUtil.getPrivateKeyFromEncryptedXML(recoverResultType.getPrivateKey(), password);
                    createKeyStore(userCert, certs, serverKey,password,encoding,outputPath);
                  }else{
                  getPrintStream().println("Error: Response didn't contain any private key");                     
                    System.exit(-1); // NOPMD, this is not a JEE app
                  }
View Full Code Here

 
  /**
   * Returns a register response
   */
  public RecoverResultType getResponse(boolean requestVerifies){
    RecoverResultType result = xkmsFactory.createRecoverResultType();   
    super.populateResponse(result, requestVerifies);   
    RecoverRequestType req = (RecoverRequestType) this.req;
   

    if(resultMajor == null){    
      if(!checkValidRespondWithRequest(req.getRespondWith(),false)){
        resultMajor = XKMSConstants.RESULTMAJOR_SENDER;
        resultMinor = XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED;
      }

      if(resultMajor == null){        
        if(resultMajor == null){
          X509Certificate cert = (X509Certificate) getPublicKeyInfo(req, false);         
         
          UserDataVO userData = findUserData(cert);
          if(userData != null){
            String password = ""
            boolean encryptedPassword = isPasswordEncrypted(req);
            if(encryptedPassword){
              password = getEncryptedPassword(requestDoc, userData.getPassword());
            }else{
              password = getClearPassword(req, userData.getPassword());
            }

            if(password != null ){
              X509Certificate newCert = registerReissueOrRecover(true,false, result, userData,password,  cert.getPublicKey(), null);
              if(newCert != null){
                KeyBindingAbstractType keyBinding = getResponseValues(req.getRecoverKeyBinding(), newCert, false, true);
                result.getKeyBinding().add((KeyBindingType) keyBinding);
              }
            }
          }

        }
View Full Code Here

TOP

Related Classes of org.w3._2002._03.xkms_.UnverifiedKeyBindingType

Copyright © 2018 www.massapicom. 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.