Package org.apache.cxf.ws.security.policy.model

Examples of org.apache.cxf.ws.security.policy.model.UsernameToken


    ) throws WSSecurityException {
        Collection<AssertionInfo> ais = aim.get(SP12Constants.USERNAME_TOKEN);
       
        if (ais != null && !ais.isEmpty()) {
            for (AssertionInfo ai : ais) {
                UsernameToken policy = (UsernameToken)ai.getAssertion();
                if (policy.isNoPassword()) {
                    message.put(WSHandlerConstants.ALLOW_USERNAMETOKEN_NOPASSWORD, "true");
                }
            }
        }
    }
View Full Code Here


    public PolicyAssertion build(Element element) {
       
        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

        UsernameToken usernameToken = new UsernameToken(consts);
        usernameToken.setOptional(PolicyConstants.isOptional(element));

        String attribute = element.getAttributeNS(element.getNamespaceURI(), SPConstants.ATTR_INCLUDE_TOKEN);
        if (attribute != null) {
            usernameToken.setInclusion(consts.getInclusionFromAttributeValue(attribute));
        }

        Element polEl = PolicyConstants.findPolicyElement(element);
        if (polEl != null) {
            Element child = DOMUtils.getFirstElement(polEl);
            if (child != null) {
                QName qname = new QName(child.getNamespaceURI(), child.getLocalName());
                if (SPConstants.USERNAME_TOKEN10.equals(qname.getLocalPart())) {
                    usernameToken.setUseUTProfile10(true);
                } else if (SPConstants.USERNAME_TOKEN11.equals(qname.getLocalPart())) {
                    usernameToken.setUseUTProfile11(true);
                } else if (SP12Constants.NO_PASSWORD.equals(qname)) {
                    usernameToken.setNoPassword(true);
                } else if (SP12Constants.HASH_PASSWORD.equals(qname)) {
                    usernameToken.setHashPassword(true);
                } else if (SP12Constants.REQUIRE_DERIVED_KEYS.equals(qname)) {
                    usernameToken.setDerivedKeys(true);
                } else if (SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS.equals(qname)) {
                    usernameToken.setExplicitDerivedKeys(true);
                } else if (SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS.equals(qname)) {
                    usernameToken.setImpliedDerivedKeys(true);
                }
            }
        }
        return usernameToken;
    }
View Full Code Here

        WSUsernameTokenPrincipal princ,
        boolean signed
    ) {
        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
        Collection<AssertionInfo> ais = aim.getAssertionInfo(SP12Constants.USERNAME_TOKEN);
        UsernameToken tok = null;
        for (AssertionInfo ai : ais) {
            tok = (UsernameToken)ai.getAssertion();
            if (princ != null && tok.isHashPassword() != princ.isPasswordDigest()) {
                ai.setNotAsserted("Password hashing policy not enforced");
            } else if (princ != null && !tok.isNoPassword() && (princ.getPassword() == null)
                && isNonEndorsingSupportingToken(tok)) {
                ai.setNotAsserted("Username Token No Password supplied");
            } else {
                ai.setAsserted(true);        
            }
View Full Code Here

        }
        return false;
    }

    protected void addToken(SoapMessage message) {
        UsernameToken tok = assertTokens(message);

        Header h = findSecurityHeader(message, true);
        WSSecUsernameToken utBuilder =
            addUsernameToken(message, tok);
        if (utBuilder == null) {
View Full Code Here

    ) throws WSSecurityException {
        Collection<AssertionInfo> ais = aim.get(SP12Constants.USERNAME_TOKEN);
       
        if (ais != null && !ais.isEmpty()) {
            for (AssertionInfo ai : ais) {
                UsernameToken policy = (UsernameToken)ai.getAssertion();
                if (policy.isNoPassword()) {
                    message.put(WSHandlerConstants.ALLOW_USERNAMETOKEN_NOPASSWORD, "true");
                }
            }
        }
    }
View Full Code Here

    ) throws WSSecurityException {
        Collection<AssertionInfo> ais = aim.get(SP12Constants.USERNAME_TOKEN);
       
        if (ais != null && !ais.isEmpty()) {
            for (AssertionInfo ai : ais) {
                UsernameToken policy = (UsernameToken)ai.getAssertion();
                if (policy.isNoPassword()) {
                    message.put(WSHandlerConstants.ALLOW_USERNAMETOKEN_NOPASSWORD, "true");
                }
            }
        }
    }
View Full Code Here

    }

    private UsernameToken assertUsernameTokens(SoapMessage message, WSUsernameTokenPrincipal princ) {
        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
        Collection<AssertionInfo> ais = aim.getAssertionInfo(SP12Constants.USERNAME_TOKEN);
        UsernameToken tok = null;
        for (AssertionInfo ai : ais) {
            tok = (UsernameToken)ai.getAssertion();
            if (princ != null && tok.isHashPassword() != princ.isPasswordDigest()) {
                ai.setNotAsserted("Password hashing policy not enforced");
            } else {
                ai.setAsserted(true);               
            }
        }
View Full Code Here

        }
        return tok;
    }

    private void addUsernameToken(SoapMessage message) {
        UsernameToken tok = assertUsernameTokens(message, null);

        Header h = findSecurityHeader(message, true);
        WSSecUsernameToken utBuilder =
            addUsernameToken(message, tok);
        if (utBuilder == null) {
View Full Code Here

    ) throws WSSecurityException {
        Collection<AssertionInfo> ais = aim.get(SP12Constants.USERNAME_TOKEN);
       
        if (ais != null && !ais.isEmpty()) {
            for (AssertionInfo ai : ais) {
                UsernameToken policy = (UsernameToken)ai.getAssertion();
                if (policy.isNoPassword()) {
                    message.put(WSHandlerConstants.ALLOW_USERNAMETOKEN_NOPASSWORD, "true");
                }
            }
        }
    }
View Full Code Here

    public PolicyAssertion build(Element element) {
       
        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

        UsernameToken usernameToken = new UsernameToken(consts);

        String attribute = DOMUtils.getAttribute(element, SP11Constants.INCLUDE_TOKEN);
        if (attribute != null) {
            usernameToken.setInclusion(consts.getInclusionFromAttributeValue(attribute));
        }

        Element policyElement = DOMUtils.getFirstElement(element);

        if (policyElement != null) {
View Full Code Here

TOP

Related Classes of org.apache.cxf.ws.security.policy.model.UsernameToken

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.