Examples of BinarySecurityTokenType


Examples of com.sun.xml.ws.security.secext10.BinarySecurityTokenType

    /**
     * Create a BinarySecurity Token Header element.
     *
     */
    public BinarySecurityToken createBinarySecurityToken(String id,String valueType,String encodingType,byte[] token){
        BinarySecurityTokenType bst = new BinarySecurityTokenType();
        bst.setValueType(valueType);
        bst.setId(id);
        bst.setEncodingType(encodingType);
        //bst.setValue(Base64.encode(cert));
        bst.setValue(token);
        return new BinarySecurityToken(bst,soapVersion);
    }
View Full Code Here

Examples of com.sun.xml.ws.security.secext10.BinarySecurityTokenType

            // Create Identity element with a BinarySecurityTOken for
            // the server certificate

            // Create BinarySecurityToken
            String id = UUID.randomUUID().toString();
            BinarySecurityTokenType bst = new BinarySecurityTokenType();
            bst.setValueType(MessageConstants.X509v3_NS);
            bst.setId(id);
            bst.setEncodingType(MessageConstants.BASE64_ENCODING_NS);
            try {
                bst.setValue(((X509Certificate)identity).getEncoded());
            }catch (CertificateEncodingException ex){
                throw new WSTrustException(ex.getMessage());
            }
            JAXBElement<BinarySecurityTokenType> bstElem = new com.sun.xml.ws.security.secext10.ObjectFactory().createBinarySecurityToken(bst);
           
View Full Code Here

Examples of com.sun.xml.ws.security.secext10.BinarySecurityTokenType

            public XMLStreamReader readAsXMLStreamReader() throws XMLStreamException {
                XMLStreamReader reader = null;
                try {

                    String id = PolicyUtil.randomUUID();
                    BinarySecurityTokenType bst = new BinarySecurityTokenType();
                    bst.setValueType(MessageConstants.X509v3_NS);
                    bst.setId(id);
                    bst.setEncodingType(MessageConstants.BASE64_ENCODING_NS);
                    if (cs != null) {
                        bst.setValue(cs.getEncoded());
                    }
                    JAXBElement<BinarySecurityTokenType> bstElem = new com.sun.xml.ws.security.secext10.ObjectFactory().createBinarySecurityToken(bst);
                    IdentityType identityElement = new IdentityType();
                    identityElement.getDnsOrSpnOrUpn().add(bstElem);
View Full Code Here

Examples of com.sun.xml.ws.security.secext10.BinarySecurityTokenType

    /**
     * Create a BinarySecurity Token Header element.
     *
     */
    public BinarySecurityToken createBinarySecurityToken(String id,String valueType,String encodingType,byte[] token){
        BinarySecurityTokenType bst = new BinarySecurityTokenType();
        bst.setValueType(valueType);
        bst.setId(id);
        bst.setEncodingType(encodingType);
        //bst.setValue(Base64.encode(cert));
        bst.setValue(token);
        return new BinarySecurityToken(bst,soapVersion);
    }
View Full Code Here

Examples of org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType

       
        if (!validateTarget.isBinarySecurityToken()) {
            return response;
        }

        BinarySecurityTokenType binarySecurityType = (BinarySecurityTokenType)validateTarget.getToken();

        // Test the encoding type
        String encodingType = binarySecurityType.getEncodingType();
        if (!BASE64_ENCODING.equals(encodingType)) {
            LOG.fine("Bad encoding type attribute specified: " + encodingType);
            return response;
        }

        //
        // Turn the received JAXB object into a DOM element
        //
        Document doc = DOMUtils.createDocument();
        BinarySecurity binarySecurity = new X509Security(doc);
        binarySecurity.setEncodingType(encodingType);
        binarySecurity.setValueType(binarySecurityType.getValueType());
        String data = binarySecurityType.getValue();
        ((Text)binarySecurity.getElement().getFirstChild()).setData(data);

        //
        // Validate the token
        //
View Full Code Here

Examples of org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType

       
        if (!validateTarget.isBinarySecurityToken()) {
            return response;
        }

        BinarySecurityTokenType binarySecurityType = (BinarySecurityTokenType)validateTarget.getToken();

        // Test the encoding type
        String encodingType = binarySecurityType.getEncodingType();
        if (!BASE64_ENCODING.equals(encodingType)) {
            LOG.fine("Bad encoding type attribute specified: " + encodingType);
            return response;
        }

        //
        // Turn the received JAXB object into a DOM element
        //
        Document doc = DOMUtils.createDocument();
        BinarySecurity binarySecurity = new X509Security(doc);
        binarySecurity.setEncodingType(encodingType);
        binarySecurity.setValueType(binarySecurityType.getValueType());
        String data = binarySecurityType.getValue();
        ((Text)binarySecurity.getElement().getFirstChild()).setData(data);

        //
        // Validate the token
        //
View Full Code Here

Examples of org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType

       
        if (!validateTarget.isBinarySecurityToken()) {
            return response;
        }

        BinarySecurityTokenType binarySecurityType = (BinarySecurityTokenType)validateTarget.getToken();

        // Test the encoding type
        String encodingType = binarySecurityType.getEncodingType();
        if (!BASE64_ENCODING.equals(encodingType)) {
            LOG.fine("Bad encoding type attribute specified: " + encodingType);
            return response;
        }

        //
        // Turn the received JAXB object into a DOM element
        //
        Document doc = DOMUtils.createDocument();
        BinarySecurity binarySecurity = new X509Security(doc);
        binarySecurity.setEncodingType(encodingType);
        binarySecurity.setValueType(binarySecurityType.getValueType());
        String data = binarySecurityType.getValue();
        ((Text)binarySecurity.getElement().getFirstChild()).setData(data);

        //
        // Validate the token
        //
View Full Code Here

Examples of org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType

        if (validateTarget == null || !validateTarget.isBinarySecurityToken()) {
            TokenValidatorResponse response = new TokenValidatorResponse();
            response.setValid(false);
            return response;
        }
        BinarySecurityTokenType binarySecurityToken = (BinarySecurityTokenType)validateTarget.getToken();
       
        TokenValidatorResponse response = new TokenValidatorResponse();
        //
        // Do some validation of the token here
        //
        if (Base64.encode("12345678".getBytes()).equals(binarySecurityToken.getValue())) {
            response.setValid(true);
        }
        response.setPrincipal(new CustomTokenPrincipal("alice"));
       
        return response;
View Full Code Here

Examples of org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType

       
        if (validateTarget == null || !validateTarget.isBinarySecurityToken()) {
            return response;
        }

        BinarySecurityTokenType binarySecurityType = (BinarySecurityTokenType)validateTarget.getToken();

        // Test the encoding type
        String encodingType = binarySecurityType.getEncodingType();
        if (!BASE64_ENCODING.equals(encodingType)) {
            LOG.fine("Bad encoding type attribute specified: " + encodingType);
            return response;
        }

        //
        // Turn the received JAXB object into a DOM element
        //
        Document doc = DOMUtils.createDocument();
        BinarySecurity binarySecurity = new X509Security(doc);
        binarySecurity.setEncodingType(encodingType);
        binarySecurity.setValueType(binarySecurityType.getValueType());
        String data = binarySecurityType.getValue();
        ((Text)binarySecurity.getElement().getFirstChild()).setData(data);

        //
        // Validate the token
        //
View Full Code Here

Examples of org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType

        TokenValidator x509TokenValidator = new X509TokenValidator();
        TokenValidatorParameters validatorParameters = createValidatorParameters();
        TokenRequirements tokenRequirements = validatorParameters.getTokenRequirements();
       
        // Create a ValidateTarget consisting of an X509Certificate
        BinarySecurityTokenType binarySecurityToken = new BinarySecurityTokenType();
        JAXBElement<BinarySecurityTokenType> tokenType =
            new JAXBElement<BinarySecurityTokenType>(
                QNameConstants.BINARY_SECURITY_TOKEN, BinarySecurityTokenType.class, binarySecurityToken
            );
        CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
        cryptoType.setAlias("myclientkey");
        Crypto crypto = validatorParameters.getStsProperties().getSignatureCrypto();
        X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
        assertTrue(certs != null && certs.length > 0);
        binarySecurityToken.setValue(Base64.encode(certs[0].getEncoded()));
       
        ReceivedToken validateTarget = new ReceivedToken(tokenType);
        tokenRequirements.setValidateTarget(validateTarget);
       
        // It can't handle the token as the value type is not set
        assertFalse(x509TokenValidator.canHandleToken(validateTarget));
       
        binarySecurityToken.setValueType(X509TokenValidator.X509_V3_TYPE);
        assertTrue(x509TokenValidator.canHandleToken(validateTarget));
       
        // This will fail as the encoding type is not set
        TokenValidatorResponse validatorResponse = null;
        validatorResponse = x509TokenValidator.validateToken(validatorParameters);
        assertTrue(validatorResponse != null);
        assertFalse(validatorResponse.isValid());
       
        binarySecurityToken.setEncodingType(WSConstants.SOAPMESSAGE_NS + "#Base64Binary");
       
        validatorResponse = x509TokenValidator.validateToken(validatorParameters);
        assertTrue(validatorResponse != null);
        assertTrue(validatorResponse.isValid());
       
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.