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

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


       
        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
   

        IssuedToken issuedToken = new IssuedToken(consts);
        issuedToken.setOptional(PolicyConstants.isOptional(element));
        issuedToken.setIgnorable(PolicyConstants.isIgnorable(element));

        String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken());
        if (includeAttr != null) {
            issuedToken.setInclusion(consts.getInclusionFromAttributeValue(includeAttr));
        }
       
        Element child = DOMUtils.getFirstElement(element);
        while (child != null) {
            String ln = child.getLocalName();
            if (SP11Constants.ISSUER.getLocalPart().equals(ln)) {
                Element issuerEpr = DOMUtils
                    .getFirstChildWithName(child,
                                       new QName(WSA_NAMESPACE, "Address"));

                // try the other addressing namespace
                if (issuerEpr == null) {
                    issuerEpr = DOMUtils
                        .getFirstChildWithName(child,
                                           new QName(WSA_NAMESPACE_SUB,
                                                     "Address"));
                }
                issuedToken.setIssuerEpr(issuerEpr);

                Element issuerMex = DOMUtils
                    .getFirstChildWithName(child,
                                       new QName(WSA_NAMESPACE, "Metadata"));

                // try the other addressing namespace
                if (issuerMex == null) {
                    issuerMex = DOMUtils
                        .getFirstChildWithName(child,
                                               new QName(WSA_NAMESPACE_SUB,
                                                         "Metadata"));
                }
   
                issuedToken.setIssuerMex(issuerMex);
            } else if (SPConstants.REQUEST_SECURITY_TOKEN_TEMPLATE.equals(ln)) {
                issuedToken.setRstTemplate(child);
            } else if (org.apache.neethi.Constants.ELEM_POLICY.equals(ln)) {
                Policy policy = builder.getPolicy(child);
                policy = (Policy)policy.normalize(builder.getPolicyRegistry(), false);

                for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
                    processAlternative((List)iterator.next(), issuedToken);
                    break; // since there should be only one alternative ..
                }               
            } else if (SPConstants.ISSUER_NAME.equals(ln)) {
                String issuerName = child.getNodeValue();
                issuedToken.setIssuerName(issuerName);
            }
           
            child = DOMUtils.getNextElement(child);
        }
        return issuedToken;
View Full Code Here


       
        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
   

        IssuedToken issuedToken = new IssuedToken(consts);

        String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken());
        if (includeAttr != null) {
            issuedToken.setInclusion(consts.getInclusionFromAttributeValue(includeAttr));
        }
        // Extract Issuer
        Element issuerElem = DOMUtils.getFirstChildWithName(element, SP11Constants.ISSUER);
        if (issuerElem != null) {
            Element issuerEpr = DOMUtils
                .getFirstChildWithName(issuerElem,
                                       new QName(WSA_NAMESPACE, "Address"));

            // try the other addressing namespace
            if (issuerEpr == null) {
                issuerEpr = DOMUtils
                    .getFirstChildWithName(issuerElem,
                                           new QName(WSA_NAMESPACE_SUB,
                                                     "Address"));
            }

            issuedToken.setIssuerEpr(issuerEpr);
        }

        // TODO check why this returns an Address element
        // iter = issuerElem.getChildrenWithLocalName("Metadata");

        if (issuerElem != null) {
            Element issuerMex = DOMUtils
                .getFirstChildWithName(issuerElem,
                                       new QName(WSA_NAMESPACE, "Metadata"));

            // try the other addressing namespace
            if (issuerMex == null) {
                issuerMex = DOMUtils
                    .getFirstChildWithName(issuerElem,
                                           new QName(WSA_NAMESPACE_SUB,
                                                     "Metadata"));
            }

            issuedToken.setIssuerMex(issuerMex);
        }

        // Extract RSTTemplate
        Element rstTmplElem = DOMUtils.getFirstChildWithName(element,
                                                             SP11Constants.REQUEST_SECURITY_TOKEN_TEMPLATE);
        if (rstTmplElem != null) {
            issuedToken.setRstTemplate(rstTmplElem);
        }

        Element policyElement = DOMUtils.getFirstChildWithName(element,
                                                               org.apache.neethi.Constants.Q_ELEM_POLICY);
View Full Code Here

       
        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
   

        IssuedToken issuedToken = new IssuedToken(consts);
        issuedToken.setOptional(PolicyConstants.isOptional(element));
        issuedToken.setIgnorable(PolicyConstants.isIgnorable(element));

        String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken());
        if (includeAttr != null) {
            issuedToken.setInclusion(consts.getInclusionFromAttributeValue(includeAttr));
        }
       
        Element child = DOMUtils.getFirstElement(element);
        boolean foundPolicy = false;
        boolean foundRST = false;
        while (child != null) {
            String ln = child.getLocalName();
            if (SPConstants.ISSUER.equals(ln)) {
                try {
                    EndpointReferenceType epr = VersionTransformer.parseEndpointReference(child);
                    issuedToken.setIssuerEpr(epr);
                } catch (JAXBException e) {
                    throw new IllegalArgumentException(e);
                }
            } else if (SPConstants.REQUEST_SECURITY_TOKEN_TEMPLATE.equals(ln)) {
                foundRST = true;
                issuedToken.setRstTemplate(child);
            } else if (org.apache.neethi.Constants.ELEM_POLICY.equals(ln)) {
                foundPolicy = true;
                Policy policy = builder.getPolicy(child);
                policy = policy.normalize(builder.getPolicyRegistry(), false);

                for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) {
                    processAlternative(iterator.next(), issuedToken);
                    break; // since there should be only one alternative ..
                }               
            } else if (SPConstants.ISSUER_NAME.equals(ln)) {
                String issuerName = child.getNodeValue();
                issuedToken.setIssuerName(issuerName);
            }
           
            child = DOMUtils.getNextElement(child);
        }
       
View Full Code Here

        if (ais == null || ais.isEmpty()) {
            return true;
        }
       
        for (AssertionInfo ai : ais) {
            IssuedToken issuedToken = (IssuedToken)ai.getAssertion();
            ai.setAsserted(true);

            if (!isTokenRequired(issuedToken, message)) {
                continue;
            }
           
            if (assertionWrapper == null) {
                ai.setNotAsserted(
                    "The received token does not match the token inclusion requirement"
                );
                return false;
            }

            Element template = issuedToken.getRstTemplate();
            if (template != null && !checkIssuedTokenTemplate(template, assertionWrapper)) {
                ai.setNotAsserted("Error in validating the IssuedToken policy");
                return false;
            }
View Full Code Here

        if (ais == null || ais.isEmpty()) {
            return true;
        }
       
        for (AssertionInfo ai : ais) {
            IssuedToken issuedToken = (IssuedToken)ai.getAssertion();
            ai.setAsserted(true);

            if (!isTokenRequired(issuedToken, message)) {
                continue;
            }
            if (binarySecurityToken == null) {
                ai.setNotAsserted(
                    "The received token does not match the token inclusion requirement"
                );
                return false;
            }

            Element template = issuedToken.getRstTemplate();
            if (template != null && !checkIssuedTokenTemplate(template, binarySecurityToken)) {
                ai.setNotAsserted("Error in validating the IssuedToken policy");
                return false;
            }
        }
View Full Code Here

                Collection<AssertionInfo> ais = aim.get(SP12Constants.ISSUED_TOKEN);
                if (ais == null || ais.isEmpty()) {
                    return;
                }
                if (isRequestor(message)) {
                    IssuedToken itok = (IssuedToken)ais.iterator().next().getAssertion();
                   
                    SecurityToken tok = retrieveCachedToken(message);
                    if (tok == null) {
                        STSClient client = STSUtils.getClient(message, "sts");
                        AddressingProperties maps =
View Full Code Here

        Collection<AssertionInfo> issuedAis,
        AssertionWrapper assertionWrapper
    ) {
        if (issuedAis != null) {
            for (AssertionInfo ai : issuedAis) {
                IssuedToken issuedToken = (IssuedToken)ai.getAssertion();
                ai.setAsserted(true);
               
                boolean tokenRequired = isTokenRequired(issuedToken, message);
                if (tokenRequired && assertionWrapper == null) {
                    ai.setNotAsserted(
                        "The received token does not match the token inclusion requirement"
                    );
                    return false;
                }
                if (!tokenRequired) {
                    continue;
                }
               
                Element template = issuedToken.getRstTemplate();
                if (template != null && !checkIssuedTokenTemplate(template, assertionWrapper)) {
                    ai.setNotAsserted("Error in validating the IssuedToken policy");
                    return false;
                }
               
View Full Code Here

        Collection<AssertionInfo> issuedAis,
        BinarySecurity binarySecurityToken
    ) {
        if (issuedAis != null) {
            for (AssertionInfo ai : issuedAis) {
                IssuedToken issuedToken = (IssuedToken)ai.getAssertion();
                ai.setAsserted(true);

                boolean tokenRequired = isTokenRequired(issuedToken, message);
                if (tokenRequired && binarySecurityToken == null) {
                    ai.setNotAsserted(
                        "The received token does not match the token inclusion requirement"
                    );
                    return false;
                }
                if (!tokenRequired) {
                    continue;
                }

                Element template = issuedToken.getRstTemplate();
                if (template != null && !checkIssuedTokenTemplate(template, binarySecurityToken)) {
                    ai.setNotAsserted("Error in validating the IssuedToken policy");
                    return false;
                }
            }
View Full Code Here

                Collection<AssertionInfo> ais = aim.get(SP12Constants.ISSUED_TOKEN);
                if (ais == null || ais.isEmpty()) {
                    return;
                }
                if (isRequestor(message)) {
                    IssuedToken itok = (IssuedToken)ais.iterator().next().getAssertion();
                   
                    SecurityToken tok = retrieveCachedToken(message);
                    if (tok == null) {
                        tok = issueToken(message, aim, itok);
                    } else {
View Full Code Here

                Collection<AssertionInfo> ais = aim.get(SP12Constants.ISSUED_TOKEN);
                if (ais == null || ais.isEmpty()) {
                    return;
                }
                if (isRequestor(message)) {
                    IssuedToken itok = (IssuedToken)ais.iterator().next().getAssertion();
                   
                    SecurityToken tok = retrieveCachedToken(message);
                    if (tok == null) {
                        tok = issueToken(message, aim, itok);
                    } else {
View Full Code Here

TOP

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

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.