Package org.apache.wss4j.dom.processor

Examples of org.apache.wss4j.dom.processor.UsernameTokenProcessor


        boolean bspCompliant = isWsiBSPCompliant(message);
        boolean utWithCallbacks =
            MessageUtils.getContextualBoolean(message, SecurityConstants.VALIDATE_TOKEN, true);
        boolean allowNoPassword = isAllowNoPassword(message.get(AssertionInfoMap.class));
        if (utWithCallbacks) {
            UsernameTokenProcessor p = new UsernameTokenProcessor();
            WSDocInfo wsDocInfo = new WSDocInfo(tokenElement.getOwnerDocument());
            RequestData data = new RequestData() {
                public CallbackHandler getCallbackHandler() {
                    return getCallback(message);
                }
                public Validator getValidator(QName qName) throws WSSecurityException {
                    Object validator =
                        message.getContextualProperty(SecurityConstants.USERNAME_TOKEN_VALIDATOR);
                    if (validator == null) {
                        return super.getValidator(qName);
                    }
                    return (Validator)validator;
                }
            };
           
            // Configure replay caching
            ReplayCache nonceCache =
                WSS4JUtils.getReplayCache(
                    message, SecurityConstants.ENABLE_NONCE_CACHE, SecurityConstants.NONCE_CACHE_INSTANCE
                );
            data.setNonceReplayCache(nonceCache);
           
            WSSConfig config = WSSConfig.getNewInstance();
            config.setAllowUsernameTokenNoPassword(allowNoPassword);
            data.setWssConfig(config);
            if (!bspCompliant) {
                data.setDisableBSPEnforcement(true);
            }
            List<WSSecurityEngineResult> results =
                p.handleToken(tokenElement, data, wsDocInfo);
            return (UsernameTokenPrincipal)results.get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
        } else {
            UsernameTokenPrincipal principal = parseTokenAndCreatePrincipal(tokenElement, bspCompliant);
            WSS4JTokenConverter.convertToken(message, principal);
            return principal;
View Full Code Here


    protected WSSecurityEngineResult validateToken(Element tokenElement, final SoapMessage message)
        throws WSSecurityException, Base64DecodingException {
       
        boolean bspCompliant = isWsiBSPCompliant(message);
        boolean allowNoPassword = isAllowNoPassword(message.get(AssertionInfoMap.class));
        UsernameTokenProcessor p = new UsernameTokenProcessor();
        WSDocInfo wsDocInfo = new WSDocInfo(tokenElement.getOwnerDocument());
        RequestData data = new RequestData() {
            public CallbackHandler getCallbackHandler() {
                return getCallback(message);
            }
            public Validator getValidator(QName qName) throws WSSecurityException {
                Object validator =
                        message.getContextualProperty(SecurityConstants.USERNAME_TOKEN_VALIDATOR);
                if (validator == null) {
                    return super.getValidator(qName);
                }
                return (Validator)validator;
            }
        };

        // Configure replay caching
        ReplayCache nonceCache =
            WSS4JUtils.getReplayCache(
                message, SecurityConstants.ENABLE_NONCE_CACHE, SecurityConstants.NONCE_CACHE_INSTANCE
            );
        data.setNonceReplayCache(nonceCache);

        WSSConfig config = WSSConfig.getNewInstance();
        config.setAllowUsernameTokenNoPassword(allowNoPassword);
        data.setWssConfig(config);
        if (!bspCompliant) {
            data.setDisableBSPEnforcement(true);
        }
        List<WSSecurityEngineResult> results = p.handleToken(tokenElement, data, wsDocInfo);
        return results.get(0);
    }
View Full Code Here

        boolean bspCompliant = isWsiBSPCompliant(message);
        boolean utWithCallbacks =
            MessageUtils.getContextualBoolean(message, SecurityConstants.VALIDATE_TOKEN, true);
        boolean allowNoPassword = isAllowNoPassword(message.get(AssertionInfoMap.class));
        if (utWithCallbacks) {
            UsernameTokenProcessor p = new UsernameTokenProcessor();
            WSDocInfo wsDocInfo = new WSDocInfo(tokenElement.getOwnerDocument());
            RequestData data = new RequestData() {
                public CallbackHandler getCallbackHandler() {
                    return getCallback(message);
                }
                public Validator getValidator(QName qName) throws WSSecurityException {
                    Object validator =
                        message.getContextualProperty(SecurityConstants.USERNAME_TOKEN_VALIDATOR);
                    if (validator == null) {
                        return super.getValidator(qName);
                    }
                    return (Validator)validator;
                }
            };
           
            // Configure replay caching
            ReplayCache nonceCache =
                WSS4JUtils.getReplayCache(
                    message, SecurityConstants.ENABLE_NONCE_CACHE, SecurityConstants.NONCE_CACHE_INSTANCE
                );
            data.setNonceReplayCache(nonceCache);
           
            WSSConfig config = WSSConfig.getNewInstance();
            config.setAllowUsernameTokenNoPassword(allowNoPassword);
            data.setWssConfig(config);
            if (!bspCompliant) {
                data.setDisableBSPEnforcement(true);
            }
            List<WSSecurityEngineResult> results =
                p.handleToken(tokenElement, data, wsDocInfo);
            return (UsernameTokenPrincipal)results.get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
        } else {
            UsernameTokenPrincipal principal = parseTokenAndCreatePrincipal(tokenElement, bspCompliant);
            WSS4JTokenConverter.convertToken(message, principal);
            return principal;
View Full Code Here

TOP

Related Classes of org.apache.wss4j.dom.processor.UsernameTokenProcessor

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.