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

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


                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 = (SecurityToken)message.getContextualProperty(SecurityConstants.TOKEN);
                    if (tok == null) {
                        String tokId = (String)message.getContextualProperty(SecurityConstants.TOKEN_ID);
                        if (tokId != null) {
                            tok = getTokenStore(message).getToken(tokId);
                        }
                    }
                    if (tok == null) {
                        STSClient client = STSUtils.getClient(message, "sts");
                        AddressingProperties maps =
                            (AddressingProperties)message
                                .get("javax.xml.ws.addressing.context.outbound");
                        if (maps == null) {
                            maps = (AddressingProperties)message
                                .get("javax.xml.ws.addressing.context");
                        }
                        synchronized (client) {
                            try {
                                // Transpose ActAs info from original request to the STS client.
                                client.setActAs(
                                    message.getContextualProperty(SecurityConstants.STS_TOKEN_ACT_AS));

                                client.setTrust(getTrust10(aim));
                                client.setTrust(getTrust13(aim));
                                client.setTemplate(itok.getRstTemplate());
                                if (maps == null) {
                                    tok = client.requestSecurityToken();
                                } else {
                                    Object o = message
                                        .getContextualProperty(SecurityConstants.STS_APPLIES_TO);
View Full Code Here


        Collection<AssertionInfo> issuedAis = aim.get(SP12Constants.ISSUED_TOKEN);
        if (issuedAis != null && !issuedAis.isEmpty()) {
            for (AssertionInfo ai : issuedAis) {
                AssertionWrapper assertionWrapper =
                    (AssertionWrapper)wser.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
                IssuedToken issuedToken = (IssuedToken)ai.getAssertion();
                ai.setAsserted(true);
               
                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> 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", itok);
                        AddressingProperties maps =
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);
        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();) {
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"
                );
                continue;
            }

            Element template = issuedToken.getRstTemplate();
            if (template != null && !checkIssuedTokenTemplate(template, assertionWrapper)) {
                ai.setNotAsserted("Error in validating the IssuedToken policy");
                continue;
            }
           
            Element claims = issuedToken.getClaims();
            if (claims != null) {
                String dialect = claims.getAttributeNS(null, "Dialect");
                if (claimsValidator.getDialect().equals(dialect)
                    && !claimsValidator.validatePolicy(claims, assertionWrapper)) {
                    ai.setNotAsserted("Error in validating the Claims policy");
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

       
        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 (SPConstants.CLAIMS.equals(ln)) {
                issuedToken.setClaims(child);
            } else if (org.apache.neethi.Constants.ELEM_POLICY.equals(ln)) {
                foundPolicy = true;
                Policy policy = builder.getPolicy(child);
                policy = policy.normalize(builder.getPolicyRegistry(), false);
                issuedToken.setPolicy(child);

                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

       
        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

                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

        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"
                );
                continue;
            }

            Element template = issuedToken.getRstTemplate();
            if (template != null && !checkIssuedTokenTemplate(template, assertionWrapper)) {
                ai.setNotAsserted("Error in validating the IssuedToken policy");
                continue;
            }
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.