Package org.apache.rahas

Examples of org.apache.rahas.TokenStorage


                    SAML2KeyInfo saml2KeyInfo = SAML2Utils.
                            getSAML2KeyInfo(assertion, signatureCrypto, tokenCallbackHandler);

                    //Store the token
                    try {
                        TokenStorage store = rmd.getTokenStorage();
                        if (store.getToken(id) == null) {
                            Token token = new Token(id, (OMElement) SAML2Utils.getElementFromAssertion(assertion), dateOfCreation, dateOfExpiration);
                            token.setSecret(saml2KeyInfo.getSecret());
                            store.add(token);
                        }
                    } catch (Exception e) {
                        throw new RampartException(
                                "errorInAddingTokenIntoStore", e);
                    }

                }
                //if this is a SAML1.1 assertion
                else {
                    final SAMLAssertion assertion =

                            ((SAMLAssertion) wser
                                    .get(WSSecurityEngineResult.TAG_SAML_ASSERTION));
                    String id = assertion.getId();
                    Date created = assertion.getNotBefore();
                    Date expires = assertion.getNotOnOrAfter();
                    SAMLKeyInfo samlKi = SAMLUtil.getSAMLKeyInfo(assertion,
                            signatureCrypto, tokenCallbackHandler);
                    try {
                        TokenStorage store = rmd.getTokenStorage();
                        if (store.getToken(id) == null) {
                            Token token = new Token(id, (OMElement) assertion.toDOM(), created, expires);
                            token.setSecret(samlKi.getSecret());
                            store.add(token);
                        }
                    } catch (Exception e) {
                        throw new RampartException(
                                "errorInAddingTokenIntoStore", e);
                    }
View Full Code Here


        String tokenType =
            TrustUtil.getWSTNamespace(version) + RahasConstants.TOK_TYPE_STATUS;
       
        tokenTypeElem.setText(tokenType);
       
        TokenStorage store = TrustUtil.getTokenStore(configCtx);
       
        Token token = store.getToken(tokenId);
       
        if ( token != null) {           
            OMElement str = token.getUnattachedReference();    
           
            if (str == null) {
View Full Code Here

        TrustUtil.createRequestTypeElement(this.version, rst, requestType);
       
        OMElement tokenTypeElem = TrustUtil.createTokenTypeElement(version, rst);
        tokenTypeElem.setText(tokenType);
       
        TokenStorage store = TrustUtil.getTokenStore(configCtx);
       
        Token token = store.getToken(tokenId);
       
        if ( token != null) {
           
            OMElement str = token.getUnattachedReference();    
           
View Full Code Here

                    SAML2KeyInfo saml2KeyInfo = SAML2Utils.getSAML2KeyInfo(assertion,
                            signatureCrypto, tokenCallbackHandler);

                    // Store the token
                    try {
                        TokenStorage store = rmd.getTokenStorage();
                        if (store.getToken(id) == null) {
                            Token token = new Token(id,
                                    (OMElement) SAML2Utils.getElementFromAssertion(assertion),
                                    dateOfCreation, dateOfExpiration);
                            token.setSecret(saml2KeyInfo.getSecret());
                            store.add(token);
                        }
                    } catch (Exception e) {
                        throw new RampartException("errorInAddingTokenIntoStore", e);
                    }

                }
                // if this is a SAML1.1 assertion
                else {
                    final SAMLAssertion assertion = ((SAMLAssertion) wser
                            .get(WSSecurityEngineResult.TAG_SAML_ASSERTION));

                    // if the subject confirmation method is Bearer, do not try to get the KeyInfo
                    if (RahasConstants.SAML11_SUBJECT_CONFIRMATION_BEARER.equals(TrustUtil
                            .getSAML11SubjectConfirmationMethod(assertion))) {
                        break;
                    }

                    String id = assertion.getId();
                    Date created = assertion.getNotBefore();
                    Date expires = assertion.getNotOnOrAfter();
                    SAMLKeyInfo samlKi = SAMLUtil.getSAMLKeyInfo(assertion, signatureCrypto,
                            tokenCallbackHandler);
                    try {
                        TokenStorage store = rmd.getTokenStorage();
                        if (store.getToken(id) == null) {
                            Token token = new Token(id, (OMElement) assertion.toDOM(), created,
                                    expires);
                            token.setSecret(samlKi.getSecret());
                            store.add(token);
                        }
                    } catch (Exception e) {
                        throw new RampartException("errorInAddingTokenIntoStore", e);
                    }
View Full Code Here

        if(this.tokenStorage != null) {
            return this.tokenStorage;
        }

        TokenStorage storage = (TokenStorage) this.msgContext.getConfigurationContext().getProperty(
                        TokenStorage.TOKEN_STORAGE_KEY);

        if (storage != null) {
            this.tokenStorage = storage;
        } else {
View Full Code Here

        if(this.tokenStorage != null) {
            return this.tokenStorage;
        }

        TokenStorage storage = (TokenStorage) this.msgContext.getProperty(
                        TokenStorage.TOKEN_STORAGE_KEY);

        if (storage != null) {
            this.tokenStorage = storage;
        } else {
View Full Code Here

    public SOAPEnvelope validate(RahasData data) throws TrustException {
  // retrieve the message context
  MessageContext inMsgCtx = data.getInMessageContext();

  // retrieve the list of tokens from the message context
  TokenStorage tkStorage = TrustUtil.getTokenStore(inMsgCtx);

  try {
      // Set the DOM impl to DOOM
      DocumentBuilderFactoryImpl.setDOOMRequired(true);

      // Create envelope
      SOAPEnvelope env = TrustUtil.createSOAPEnvelope(inMsgCtx
        .getEnvelope().getNamespace().getNamespaceURI());

      // Create RSTR element, with respective version
      OMElement rstrElem;
      int wstVersion = data.getVersion();
      if (RahasConstants.VERSION_05_02 == wstVersion) {
    rstrElem = TrustUtil.createRequestSecurityTokenResponseElement(
      wstVersion, env.getBody());
      } else {
    OMElement rstrcElem = TrustUtil
      .createRequestSecurityTokenResponseCollectionElement(
        wstVersion, env.getBody());
    rstrElem = TrustUtil.createRequestSecurityTokenResponseElement(
      wstVersion, rstrcElem);
      }

      // Create TokenType element, set to RSTR/Status
      TrustUtil.createTokenTypeElement(wstVersion, rstrElem).setText(
        TrustUtil.getWSTNamespace(wstVersion)
          + RahasConstants.TOK_TYPE_STATUS);

      // Create Status element
      OMElement statusElement = createMessageElement(wstVersion,
        rstrElem, RahasConstants.LocalNames.STATUS);

      // Obtain the token
      Token tk = tkStorage.getToken(data.getTokenId());

      // create the crypto object
      PublicKey issuerPBKey = getIssuerPublicKey(inMsgCtx);

      boolean valid = isValid(tk, issuerPBKey);
View Full Code Here

        if (config == null) {
            throw new TrustException("configurationIsNull");
        }
       
        // retrieve the list of tokens from the message context
        TokenStorage tkStorage = TrustUtil.getTokenStore(inMsgCtx);
       
        try {
            // Set the DOM impl to DOOM
            DocumentBuilderFactoryImpl.setDOOMRequired(true);

            // Create envelope
            SOAPEnvelope env = TrustUtil.createSOAPEnvelope(inMsgCtx
                    .getEnvelope().getNamespace().getNamespaceURI());

            // Create RSTR element, with respective version
            OMElement rstrElem;
            int wstVersion = data.getVersion();
            if (RahasConstants.VERSION_05_02 == wstVersion) {
                rstrElem = TrustUtil.createRequestSecurityTokenResponseElement(
                        wstVersion, env.getBody());
            } else {
                OMElement rstrcElem = TrustUtil
                        .createRequestSecurityTokenResponseCollectionElement(
                                wstVersion, env.getBody());
                rstrElem = TrustUtil.createRequestSecurityTokenResponseElement(
                        wstVersion, rstrcElem);
            }
           
            Crypto crypto;
            if (config.cryptoElement != null) {
                // crypto props defined as elements
                crypto = CryptoFactory.getInstance(TrustUtil
                        .toProperties(config.cryptoElement), inMsgCtx
                        .getAxisService().getClassLoader());
            } else {
                // crypto props defined in a properties file
                crypto = CryptoFactory.getInstance(config.cryptoPropertiesFile,
                        inMsgCtx.getAxisService().getClassLoader());
            }

            // Create TokenType element
            TrustUtil.createTokenTypeElement(wstVersion, rstrElem).setText(
                    RahasConstants.TOK_TYPE_SAML_10);
           
            // 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));

            // Obtain the token
            Token tk = tkStorage.getToken(data.getTokenId());

            OMElement assertionOMElement = tk.getToken();
            SAMLAssertion samlAssertion = null;

            try {
View Full Code Here

            throw new TrustException("cannotDetermineTokenId");
        }

        // Cancel the token
        MessageContext inMsgCtx = data.getInMessageContext();
        TokenStorage tokenStore = TrustUtil.getTokenStore(inMsgCtx);
        Token token = tokenStore.getToken(tokenId);
        if (token == null) {
            throw new TrustException("tokenNotFound", new String[]{tokenId});
        }
        token.setState(Token.CANCELLED);
        tokenStore.update(token);

        // Create the response SOAP Envelope
        SOAPEnvelope responseEnv =
                TrustUtil.
                        createSOAPEnvelope(inMsgCtx.getEnvelope().getNamespace().getNamespaceURI());
View Full Code Here

        String tokenType =
            TrustUtil.getWSTNamespace(version) + RahasConstants.TOK_TYPE_STATUS;
       
        tokenTypeElem.setText(tokenType);
       
        TokenStorage store = TrustUtil.getTokenStore(configCtx);
       
        Token token = store.getToken(tokenId);
       
        if ( token != null) {           
            OMElement str = token.getUnattachedReference();    
           
            if (str == null) {
View Full Code Here

TOP

Related Classes of org.apache.rahas.TokenStorage

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.