Package org.w3._2002._03.xkms_

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


        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);
        JAXBElement<RegisterRequestType> registerRequest = xKMSObjectFactory.createRegisterRequest(registerRequestType);

        Document registerRequestDoc = dbf.newDocumentBuilder().newDocument();
        marshaller.marshal(registerRequest, registerRequestDoc);

        String authenticationData = "024837";

        SecretKey sk = XKMSUtil.getSecretKeyFromPassphrase(authenticationData, true, 20, XKMSUtil.KEY_AUTHENTICATION);

        org.apache.xml.security.signature.XMLSignature authXMLSig = new org.apache.xml.security.signature.XMLSignature(registerRequestDoc, "",
                org.apache.xml.security.signature.XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
                org.apache.xml.security.c14n.Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
        org.apache.xml.security.transforms.Transforms transforms = new org.apache.xml.security.transforms.Transforms(registerRequestDoc);
        transforms.addTransform(org.apache.xml.security.transforms.Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
        authXMLSig.addDocument("#" + prototypeKeyBindingType.getId(), transforms, org.apache.xml.security.utils.Constants.ALGO_ID_DIGEST_SHA1);

        authXMLSig.sign(sk);

        Element authenticationElement = registerRequestDoc.createElementNS("http://www.w3.org/2002/03/xkms#", "Authentication");
        Element keyBindingAuthenticationElement = registerRequestDoc.createElementNS("http://www.w3.org/2002/03/xkms#", "KeyBindingAuthentication");
        keyBindingAuthenticationElement.appendChild(authXMLSig.getElement().cloneNode(true));
        authenticationElement.appendChild(keyBindingAuthenticationElement);
        registerRequestDoc.getDocumentElement().appendChild(authenticationElement);

        org.apache.xml.security.signature.XMLSignature xmlSig = new org.apache.xml.security.signature.XMLSignature(registerRequestDoc, "",
                org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1,
                org.apache.xml.security.c14n.Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
        transforms = new org.apache.xml.security.transforms.Transforms(registerRequestDoc);
        transforms.addTransform(org.apache.xml.security.transforms.Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);

        xmlSig.addDocument("#" + prototypeKeyBindingType.getId(), transforms, org.apache.xml.security.utils.Constants.ALGO_ID_DIGEST_SHA1);

        xmlSig.sign(keyPair.getPrivate());

        Element pOPElement = registerRequestDoc.createElementNS("http://www.w3.org/2002/03/xkms#", "ProofOfPossession");
        pOPElement.appendChild(xmlSig.getElement().cloneNode(true));
View Full Code Here


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

           
            QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
            if(isCertQuery){
              X509DataType x509DataType = sigFactory.createX509DataType();
                x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(queryCert));
                KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
                keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
                queryKeyBindingType.setKeyInfo(keyInfoType);
            }else{
              UseKeyWithType useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
              useKeyWithType.setApplication(queryType);
              useKeyWithType.setIdentifier(queryVal);
              queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
            }
            if(keyUsage != null){
              queryKeyBindingType.getKeyUsage().add(keyUsage);
            }
           
            String reqId = genId();
           
            List keyBindings = new ArrayList();
View Full Code Here

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier("Test");

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

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

        JAXBElement<ValidateRequestType> validateRequest = xKMSObjectFactory.createValidateRequest(validateRequestType);

        String alias = "TEST";
View Full Code Here

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier("Test");

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

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

        JAXBElement<ValidateRequestType> validateRequest = xKMSObjectFactory.createValidateRequest(validateRequestType);

        Document doc = dbf.newDocumentBuilder().newDocument();
View Full Code Here

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier("Test");

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

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

        JAXBElement<ValidateRequestType> validateRequest = xKMSObjectFactory.createValidateRequest(validateRequestType);

        Document doc = dbf.newDocumentBuilder().newDocument();
View Full Code Here

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSHTTP);
        useKeyWithType.setIdentifier("Test");

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

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

        JAXBElement<ValidateRequestType> validateRequest = xKMSObjectFactory.createValidateRequest(validateRequestType);

        Document doc = dbf.newDocumentBuilder().newDocument();
View Full Code Here

        LocateRequestType abstractRequestType = xKMSObjectFactory.createLocateRequestType();
        abstractRequestType.setId("123");
        OpaqueClientDataType opaqueClientDataType = new OpaqueClientDataType();
        opaqueClientDataType.getOpaqueData().add("TEST".getBytes());
        opaqueClientDataType.getOpaqueData().add("TEST2".getBytes());
        QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        abstractRequestType.setQueryKeyBinding(queryKeyBindingType);

        abstractRequestType.setOpaqueClientData(opaqueClientDataType);
        LocateResultType abstractResultType = xKMSInvoker.locate(abstractRequestType, null, null);
        assertTrue(abstractResultType.getRequestId().equals("123"));
View Full Code Here

    public void test02TimeInstantNotSupported() throws Exception {
        LocateRequestType localteRequestType = xKMSObjectFactory.createLocateRequestType();
        localteRequestType.setId("124");

        QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        TimeInstantType timeInstantType = xKMSObjectFactory.createTimeInstantType();
        GregorianCalendar caledar = new GregorianCalendar();
        XMLGregorianCalendar xMLGregorianCalendar = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(caledar);
        xMLGregorianCalendar.normalize();
        timeInstantType.setTime(xMLGregorianCalendar);
        queryKeyBindingType.setTimeInstant(timeInstantType);
        localteRequestType.setQueryKeyBinding(queryKeyBindingType);

        LocateResultType abstractResultType = xKMSInvoker.locate(localteRequestType, null, null);
        abstractResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_RECIEVER);
        abstractResultType.getResultMajor().equals(XKMSConstants.RESULTMINOR_TIMEINSTANTNOTSUPPORTED);
View Full Code Here

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

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

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

        LocateResultType locateResultType = xKMSInvoker.locate(locateRequestType, null, null);

        assertTrue(locateResultType.getUnverifiedKeyBinding().size() > 0);
View Full Code Here

        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLS);
        useKeyWithType.setIdentifier("http://www.test.com/" + username2);

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

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

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

        // Locate by DNS Name
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("127");
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType.setIdentifier(username2 + ".test.com");

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

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

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

        // Locate by IP Name
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("128");
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_IPSEC);
        useKeyWithType.setIdentifier("10.0.0.1");

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

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

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() > 0);

        // Locate by Subject DN
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("129");
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn1);

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

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

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        assertEquals("locateResultType.getUnverifiedKeyBinding: ", 1, locateResultType.getUnverifiedKeyBinding().size());

        // Locate by With a more complicated query
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("129");
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn1);

        UseKeyWithType useKeyWithType2 = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType2.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType2.setIdentifier(username2 + ".test.com");

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

        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType2);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

        locateResultType = xKMSInvoker.locate(locateRequestType, null, null);
        // Should return the cert of username1 and username2
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 2);

        // Locate by With a more complicated query but results in only one cert
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("129");
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier(dn2);

        useKeyWithType2 = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType2.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType2.setIdentifier(username2 + ".test.com");

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

        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType2);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

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

        // Locate by With a more complicated query with one subquery doesn't
        // match
        locateRequestType = xKMSObjectFactory.createLocateRequestType();
        locateRequestType.setId("129");
        useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
        useKeyWithType.setIdentifier("CN=nomatch");

        useKeyWithType2 = xKMSObjectFactory.createUseKeyWithType();
        useKeyWithType2.setApplication(XKMSConstants.USEKEYWITH_TLSSMTP);
        useKeyWithType2.setIdentifier(username2 + ".test.com");

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

        queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
        queryKeyBindingType.getUseKeyWith().add(useKeyWithType2);
        locateRequestType.setQueryKeyBinding(queryKeyBindingType);

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

        // Test with certificate
        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);
        assertTrue(locateResultType.getUnverifiedKeyBinding().size() == 1);
View Full Code Here

TOP

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

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.