Java Code Examples for org.apache.ws.security.message.WSSecUsernameToken#getUsernameTokenElement()

The following examples show how to use org.apache.ws.security.message.WSSecUsernameToken#getUsernameTokenElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SymmetricBindingHandler.java    From steady with Apache License 2.0 6 votes vote down vote up
private String setupUTDerivedKey(UsernameToken sigToken) throws WSSecurityException {
    boolean useMac = hasSignedPartsOrElements();
    WSSecUsernameToken usernameToken = addDKUsernameToken(sigToken, useMac);
    String id = usernameToken.getId();
    byte[] secret = usernameToken.getDerivedKey();

    Date created = new Date();
    Date expires = new Date();
    expires.setTime(created.getTime() + 300000);
    SecurityToken tempTok = 
        new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
    tempTok.setSecret(secret);
    
    tokenStore.add(tempTok);
    
    return id;
}
 
Example 2
Source File: SymmetricBindingHandler.java    From steady with Apache License 2.0 6 votes vote down vote up
private String setupUTDerivedKey(UsernameToken sigToken) throws WSSecurityException {
    boolean useMac = hasSignedPartsOrElements();
    WSSecUsernameToken usernameToken = addDKUsernameToken(sigToken, useMac);
    String id = usernameToken.getId();
    byte[] secret = usernameToken.getDerivedKey();

    Date created = new Date();
    Date expires = new Date();
    expires.setTime(created.getTime() + 300000);
    SecurityToken tempTok = 
        new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
    tempTok.setSecret(secret);
    
    tokenStore.add(tempTok);
    
    return id;
}
 
Example 3
Source File: SymmetricBindingHandler.java    From steady with Apache License 2.0 6 votes vote down vote up
private String setupUTDerivedKey(UsernameToken sigToken) throws WSSecurityException {
    boolean useMac = hasSignedPartsOrElements();
    WSSecUsernameToken usernameToken = addDKUsernameToken(sigToken, useMac);
    String id = usernameToken.getId();
    byte[] secret = usernameToken.getDerivedKey();

    Date created = new Date();
    Date expires = new Date();
    expires.setTime(created.getTime() + 300000);
    SecurityToken tempTok = 
        new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
    tempTok.setSecret(secret);
    
    tokenStore.add(tempTok);
    
    return id;
}
 
Example 4
Source File: SymmetricBindingHandler.java    From steady with Apache License 2.0 6 votes vote down vote up
private String setupUTDerivedKey(UsernameToken sigToken) throws WSSecurityException {
    boolean useMac = hasSignedPartsOrElements();
    WSSecUsernameToken usernameToken = addDKUsernameToken(sigToken, useMac);
    String id = usernameToken.getId();
    byte[] secret = usernameToken.getDerivedKey();

    Date created = new Date();
    Date expires = new Date();
    expires.setTime(created.getTime() + 300000);
    SecurityToken tempTok = 
        new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
    tempTok.setSecret(secret);
    
    tokenStore.add(tempTok);
    
    return id;
}
 
Example 5
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 5 votes vote down vote up
private void handleEndorsingToken(
    Token token, SupportingToken wrapper
) throws Exception {
    if (token instanceof IssuedToken
        || token instanceof SecureConversationToken
        || token instanceof SecurityContextToken
        || token instanceof KerberosToken
        || token instanceof SpnegoContextToken) {
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof X509Token
        || token instanceof KeyValueToken) {
        addSig(doX509TokenSignature(token, wrapper));
    } else if (token instanceof SamlToken) {
        AssertionWrapper assertionWrapper = addSamlToken((SamlToken)token);
        assertionWrapper.toDOM(saaj.getSOAPPart());
        storeAssertionAsSecurityToken(assertionWrapper);
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof UsernameToken) {
        // Create a UsernameToken object for derived keys and store the security token
        WSSecUsernameToken usernameToken = addDKUsernameToken((UsernameToken)token, true);
        String id = usernameToken.getId();
        byte[] secret = usernameToken.getDerivedKey();

        Date created = new Date();
        Date expires = new Date();
        expires.setTime(created.getTime() + 300000);
        SecurityToken tempTok = 
            new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
        tempTok.setSecret(secret);
        getTokenStore().add(tempTok);
        message.setContextualProperty(SecurityConstants.TOKEN_ID, tempTok.getId());
        
        addSig(doIssuedTokenSignature(token, wrapper));
    }
}
 
Example 6
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 5 votes vote down vote up
private void handleEndorsingToken(
    Token token, SupportingToken wrapper
) throws Exception {
    if (token instanceof IssuedToken
        || token instanceof SecureConversationToken
        || token instanceof SecurityContextToken
        || token instanceof KerberosToken
        || token instanceof SpnegoContextToken) {
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof X509Token
        || token instanceof KeyValueToken) {
        addSig(doX509TokenSignature(token, wrapper));
    } else if (token instanceof SamlToken) {
        AssertionWrapper assertionWrapper = addSamlToken((SamlToken)token);
        assertionWrapper.toDOM(saaj.getSOAPPart());
        storeAssertionAsSecurityToken(assertionWrapper);
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof UsernameToken) {
        // Create a UsernameToken object for derived keys and store the security token
        WSSecUsernameToken usernameToken = addDKUsernameToken((UsernameToken)token, true);
        String id = usernameToken.getId();
        byte[] secret = usernameToken.getDerivedKey();

        Date created = new Date();
        Date expires = new Date();
        expires.setTime(created.getTime() + 300000);
        SecurityToken tempTok = 
            new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
        tempTok.setSecret(secret);
        getTokenStore().add(tempTok);
        message.setContextualProperty(SecurityConstants.TOKEN_ID, tempTok.getId());
        
        addSig(doIssuedTokenSignature(token, wrapper));
    }
}
 
Example 7
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 5 votes vote down vote up
private void handleEndorsingToken(
    Token token, SupportingToken wrapper
) throws Exception {
    if (token instanceof IssuedToken
        || token instanceof SecureConversationToken
        || token instanceof SecurityContextToken
        || token instanceof KerberosToken
        || token instanceof SpnegoContextToken) {
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof X509Token
        || token instanceof KeyValueToken) {
        addSig(doX509TokenSignature(token, wrapper));
    } else if (token instanceof SamlToken) {
        AssertionWrapper assertionWrapper = addSamlToken((SamlToken)token);
        assertionWrapper.toDOM(saaj.getSOAPPart());
        storeAssertionAsSecurityToken(assertionWrapper);
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof UsernameToken) {
        // Create a UsernameToken object for derived keys and store the security token
        WSSecUsernameToken usernameToken = addDKUsernameToken((UsernameToken)token, true);
        String id = usernameToken.getId();
        byte[] secret = usernameToken.getDerivedKey();

        Date created = new Date();
        Date expires = new Date();
        expires.setTime(created.getTime() + 300000);
        SecurityToken tempTok = 
            new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
        tempTok.setSecret(secret);
        getTokenStore().add(tempTok);
        message.setContextualProperty(SecurityConstants.TOKEN_ID, tempTok.getId());
        
        addSig(doIssuedTokenSignature(token, wrapper));
    }
}
 
Example 8
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 5 votes vote down vote up
private void handleEndorsingToken(
    Token token, SupportingToken wrapper
) throws Exception {
    if (token instanceof IssuedToken
        || token instanceof SecureConversationToken
        || token instanceof SecurityContextToken
        || token instanceof KerberosToken
        || token instanceof SpnegoContextToken) {
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof X509Token
        || token instanceof KeyValueToken) {
        addSig(doX509TokenSignature(token, wrapper));
    } else if (token instanceof SamlToken) {
        AssertionWrapper assertionWrapper = addSamlToken((SamlToken)token);
        assertionWrapper.toDOM(saaj.getSOAPPart());
        storeAssertionAsSecurityToken(assertionWrapper);
        addSig(doIssuedTokenSignature(token, wrapper));
    } else if (token instanceof UsernameToken) {
        // Create a UsernameToken object for derived keys and store the security token
        WSSecUsernameToken usernameToken = addDKUsernameToken((UsernameToken)token, true);
        String id = usernameToken.getId();
        byte[] secret = usernameToken.getDerivedKey();

        Date created = new Date();
        Date expires = new Date();
        expires.setTime(created.getTime() + 300000);
        SecurityToken tempTok = 
            new SecurityToken(id, usernameToken.getUsernameTokenElement(), created, expires);
        tempTok.setSecret(secret);
        getTokenStore().add(tempTok);
        message.setContextualProperty(SecurityConstants.TOKEN_ID, tempTok.getId());
        
        addSig(doIssuedTokenSignature(token, wrapper));
    }
}