Package org.apache.ws.security.message.token

Examples of org.apache.ws.security.message.token.SecurityContextToken


            if (keySize < 128 || keySize > 512) {
                keySize = 256;
            }
           
            writer.writeStartElement(prefix, "RequestedSecurityToken", namespace);
            SecurityContextToken sct =
                new SecurityContextToken(NegotiationUtils.getWSCVersion(tokenType), writer.getDocument());
           
            Date created = new Date();
            Date expires = new Date();
            expires.setTime(created.getTime() + ttl);
           
            SecurityToken token = new SecurityToken(sct.getIdentifier(), created, expires);
            token.setToken(sct.getElement());
            token.setTokenType(sct.getTokenType());
           
            writer.getCurrentNode().appendChild(sct.getElement());
            writer.writeEndElement();       
           
            writer.writeStartElement(prefix, "RequestedAttachedReference", namespace);
            token.setAttachedReference(
                writeSecurityTokenReference(writer, "#" + sct.getID(), tokenType)
            );
            writer.writeEndElement();
           
            writer.writeStartElement(prefix, "RequestedUnattachedReference", namespace);
            token.setUnattachedReference(
                writeSecurityTokenReference(writer, sct.getIdentifier(), tokenType)
            );
            writer.writeEndElement();
           
            writeLifetime(writer, created, expires, prefix, namespace);
View Full Code Here


               
                el = DOMUtils.getNextElement(el);
            }
           
            writer.writeStartElement(prefix, "RequestedSecurityToken", namespace);
            SecurityContextToken sct =
                new SecurityContextToken(SecureConversationTokenInterceptorProvider
                                              .getWSCVersion(tokenType), writer.getDocument());
           
            Calendar created = Calendar.getInstance();
            Calendar expires = Calendar.getInstance();
            expires.setTimeInMillis(System.currentTimeMillis() + ttl);

            SecurityToken token = new SecurityToken(sct.getIdentifier(), created, expires);
            token.setToken(sct.getElement());
            token.setTokenType(WSConstants.WSC_SCT);
           
            writer.getCurrentNode().appendChild(sct.getElement());
            writer.writeEndElement();       
           
            writer.writeStartElement(prefix, "RequestedAttachedReference", namespace);
            token.setAttachedReference(SecureConversationTokenInterceptorProvider
                                           .writeSecurityTokenReference(writer,
                                                                   "#" + sct.getID(),
                                                                   tokenType));
            writer.writeEndElement();
           
            writer.writeStartElement(prefix, "RequestedUnattachedReference", namespace);
            token.setUnattachedReference(SecureConversationTokenInterceptorProvider
                                             .writeSecurityTokenReference(writer,
                                                                     sct.getIdentifier(),
                                                                     tokenType));
            writer.writeEndElement();
           
            XmlSchemaDateFormat fmt = new XmlSchemaDateFormat();
            writer.writeStartElement(prefix, "Lifetime", namespace);
View Full Code Here

                for (int j = 0; j < wsSecEngineResults.size(); j++) {
                    WSSecurityEngineResult wser =
                            (WSSecurityEngineResult) wsSecEngineResults.get(j);
                    Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
                    if (actInt.intValue() == WSConstants.SCT) {
                        SecurityContextToken tok
                            = (SecurityContextToken)wser
                                .get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN);
                        message.getExchange().put(SecurityConstants.TOKEN_ID, tok.getIdentifier());
                        found = true;
                    }
                }
            }
            AssertionInfoMap aim = message.get(AssertionInfoMap.class);
View Full Code Here

        response.setValid(false);
       
        if (validateTarget != null && validateTarget.isDOMElement()) {
            try {
                Element validateTargetElement = (Element)validateTarget.getToken();
                SecurityContextToken sct = new SecurityContextToken(validateTargetElement);
                String identifier = sct.getIdentifier();
                SecurityToken token = tokenParameters.getTokenStore().getToken(identifier);
                if (token == null) {
                    LOG.fine("Identifier: " + identifier + " is not found in the cache");
                    return response;
                }
View Full Code Here

               
                el = DOMUtils.getNextElement(el);
            }
           
            writer.writeStartElement(prefix, "RequestedSecurityToken", namespace);
            SecurityContextToken sct =
                new SecurityContextToken(SecureConversationTokenInterceptorProvider
                                              .getWSCVersion(tokenType), writer.getDocument());
           
            Calendar created = Calendar.getInstance();
            Calendar expires = Calendar.getInstance();
            expires.setTimeInMillis(System.currentTimeMillis() + ttl);

            SecurityToken token = new SecurityToken(sct.getIdentifier(), created, expires);
            token.setToken(sct.getElement());
            token.setTokenType(WSConstants.WSC_SCT);
           
            writer.getCurrentNode().appendChild(sct.getElement());
            writer.writeEndElement();       
           
            writer.writeStartElement(prefix, "RequestedAttachedReference", namespace);
            token.setAttachedReference(SecureConversationTokenInterceptorProvider
                                           .writeSecurityTokenReference(writer,
                                                                   "#" + sct.getID(),
                                                                   tokenType));
            writer.writeEndElement();
           
            writer.writeStartElement(prefix, "RequestedUnattachedReference", namespace);
            token.setUnattachedReference(SecureConversationTokenInterceptorProvider
                                             .writeSecurityTokenReference(writer,
                                                                     sct.getIdentifier(),
                                                                     tokenType));
            writer.writeEndElement();
           
            XmlSchemaDateFormat fmt = new XmlSchemaDateFormat();
            writer.writeStartElement(prefix, "Lifetime", namespace);
View Full Code Here

                    for (int j = 0; j < wsSecEngineResults.size(); j++) {
                        WSSecurityEngineResult wser =
                                (WSSecurityEngineResult) wsSecEngineResults.get(j);
                        Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
                        if (actInt.intValue() == WSConstants.SCT) {
                            SecurityContextToken tok
                                = (SecurityContextToken)wser
                                    .get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN);
                            message.getExchange().put(SecurityConstants.TOKEN_ID, tok.getIdentifier());
                            found = true;
                        }
                    }
                }
            }
View Full Code Here

                    WSSecurityEngineResult wser = (WSSecurityEngineResult) wsSecEngineResults
                            .get(j);
                    final Integer actInt =
                        (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
                    if(WSConstants.SCT == actInt.intValue()) {
                        final SecurityContextToken sct =
                            ((SecurityContextToken) wser
                                .get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN));
                        id = sct.getID();
                    }

                }
            }
        }
View Full Code Here

                String tokenId = (String)RampartUtil.getContextMap(msgCtx).get(ctxIdKey);
               
                if(tokenId != null && RampartUtil.isTokenValid(rmd, tokenId)) {
                    OMElement bodyElem = msgCtx.getEnvelope().getBody();
                    OMElement child = bodyElem.getFirstElement();
                    SecurityContextToken sct = new SecurityContextToken(
                            (Element) rmd.getTokenStorage().getToken(tokenId)
                                    .getToken());
                    OMElement newChild = TrustUtil.createCancelRequest(sct
                            .getIdentifier(), rmd.getWstVersion());
                    Element newDomChild = XMLUtils.toDOM(newChild);
                    Node importedNode = rmd.getDocument().importNode((Element) newDomChild, true);
                    ((Element) bodyElem).replaceChild(importedNode, (Element) child);
                } else {
View Full Code Here

            int wstVersion = data.getVersion();

            // Get the document
            Document doc = ((Element) env).getOwnerDocument();

            SecurityContextToken sct =
                    new SecurityContextToken(this.getWSCVersion(data.getTokenType()), doc);

            OMElement rstrElem;
            if (wstVersion == RahasConstants.VERSION_05_12) {
                /**
                 * If secure conversation version is http://docs.oasis-open.org/ws-sx/ws-trust/200512
                 * We have to wrap "request security token response" in a "request security token response
                 * collection".
                 * See WS-SecureConversation 1.3 spec's Section 3 - Establishing Security Contexts
                 * for more details.
                 */
                OMElement requestedSecurityTokenResponseCollection = TrustUtil
                        .createRequestSecurityTokenResponseCollectionElement(wstVersion, env.getBody());
                rstrElem =
                        TrustUtil.createRequestSecurityTokenResponseElement(wstVersion,
                                requestedSecurityTokenResponseCollection);
            } else {
                rstrElem =
                        TrustUtil.createRequestSecurityTokenResponseElement(wstVersion,
                                env.getBody());
            }


            OMElement rstElem =
                    TrustUtil.createRequestedSecurityTokenElement(wstVersion, rstrElem);

            rstElem.addChild((OMElement) sct.getElement());

            String tokenType = data.getTokenType();

            OMElement reqAttachedRef = null;
            OMElement reqUnattachedRef = null;
            if (config.addRequestedAttachedRef) {
                reqAttachedRef = TrustUtil.createRequestedAttachedRef(wstVersion,
                                                         rstrElem,
                                                         "#" + sct.getID(),
                                                         tokenType);
            }

            if (config.addRequestedUnattachedRef) {
                reqUnattachedRef = TrustUtil.createRequestedUnattachedRef(wstVersion,
                                                           rstrElem,
                                                           sct.getIdentifier(),
                                                           tokenType);
            }

            //Creation and expiration times
            Date creationTime = new Date();
            Date expirationTime = new Date();

            expirationTime.setTime(creationTime.getTime() + config.ttl);

            // Use GMT time in milliseconds
            DateFormat zulu = new XmlSchemaDateFormat();

            // Add the Lifetime element
            TrustUtil.createLifetimeElement(wstVersion,
                                            rstrElem,
                                            zulu.format(creationTime),
                                            zulu.format(expirationTime));

            // Store the tokens
            Token sctToken = new Token(sct.getIdentifier(),
                                       (OMElement) sct.getElement(),
                                       creationTime,
                                       expirationTime);
           
            if(config.addRequestedAttachedRef) {
                sctToken.setAttachedReference(reqAttachedRef.getFirstElement());
View Full Code Here

        CallbackHandler cb,
        WSDocInfo wsDocInfo,
        Vector returnResults,
        WSSConfig config
    ) throws WSSecurityException {
        SecurityContextToken sct = new SecurityContextToken(elem);
        this.identifier = sct.getIdentifier();
        this.secret = this.getSecret(cb, sct);
        this.sctId = sct.getID();
       
        returnResults.add(
            0,
            new WSSecurityEngineResult(WSConstants.SCT, sct)
        );
View Full Code Here

TOP

Related Classes of org.apache.ws.security.message.token.SecurityContextToken

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.