Java Code Examples for org.apache.ws.security.WSConstants#SCT

The following examples show how to use org.apache.ws.security.WSConstants#SCT . 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: NegotiationUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Return true on successfully parsing a SecurityContextToken result
 */
static boolean parseSCTResult(SoapMessage message) {
    List<WSHandlerResult> results = 
        CastUtils.cast((List<?>)message.get(WSHandlerConstants.RECV_RESULTS));
    if (results == null) {
        return false;
    }
    
    for (WSHandlerResult rResult : results) {
        List<WSSecurityEngineResult> wsSecEngineResults = rResult.getResults();

        for (WSSecurityEngineResult wser : wsSecEngineResults) {
            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());
                
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                if (secret != null) {
                    SecurityToken token = new SecurityToken(tok.getIdentifier());
                    token.setToken(tok.getElement());
                    token.setSecret(secret);
                    token.setTokenType(tok.getTokenType());
                    getTokenStore(message).add(token);
                }
                return true;
            }
        }
    }
    return false;
}
 
Example 2
Source File: AbstractSupportingTokenPolicyValidator.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Process Security Context Tokens.
 */
protected boolean processSCTokens() {
    List<WSSecurityEngineResult> tokenResults = new ArrayList<WSSecurityEngineResult>();
    List<WSSecurityEngineResult> dktResults = new ArrayList<WSSecurityEngineResult>();
    for (WSSecurityEngineResult wser : results) {
        Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
        if (actInt.intValue() == WSConstants.SCT) {
            if (derived) {
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                WSSecurityEngineResult dktResult = getMatchingDerivedKey(secret);
                if (dktResult != null) {
                    dktResults.add(dktResult);
                }
            }
            tokenResults.add(wser);
        }
    }
    
    if (tokenResults.isEmpty()) {
        return false;
    }
    
    if (signed && !areTokensSigned(tokenResults)) {
        return false;
    }
    if (encrypted && !areTokensEncrypted(tokenResults)) {
        return false;
    }
    tokenResults.addAll(dktResults);
    if (endorsed && !checkEndorsed(tokenResults)) {
        return false;
    }
    
    if (!validateSignedEncryptedPolicies(tokenResults)) {
        return false;
    }
    
    return true;
}
 
Example 3
Source File: NegotiationUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Return true on successfully parsing a SecurityContextToken result
 */
static boolean parseSCTResult(SoapMessage message) {
    List<WSHandlerResult> results = 
        CastUtils.cast((List<?>)message.get(WSHandlerConstants.RECV_RESULTS));
    if (results == null) {
        return false;
    }
    
    for (WSHandlerResult rResult : results) {
        List<WSSecurityEngineResult> wsSecEngineResults = rResult.getResults();

        for (WSSecurityEngineResult wser : wsSecEngineResults) {
            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());
                
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                if (secret != null) {
                    SecurityToken token = new SecurityToken(tok.getIdentifier());
                    token.setToken(tok.getElement());
                    token.setSecret(secret);
                    token.setTokenType(tok.getTokenType());
                    getTokenStore(message).add(token);
                }
                return true;
            }
        }
    }
    return false;
}
 
Example 4
Source File: AbstractSupportingTokenPolicyValidator.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Process Security Context Tokens.
 */
protected boolean processSCTokens() {
    List<WSSecurityEngineResult> tokenResults = new ArrayList<WSSecurityEngineResult>();
    List<WSSecurityEngineResult> dktResults = new ArrayList<WSSecurityEngineResult>();
    for (WSSecurityEngineResult wser : results) {
        Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
        if (actInt.intValue() == WSConstants.SCT) {
            if (derived) {
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                WSSecurityEngineResult dktResult = getMatchingDerivedKey(secret);
                if (dktResult != null) {
                    dktResults.add(dktResult);
                }
            }
            tokenResults.add(wser);
        }
    }
    
    if (tokenResults.isEmpty()) {
        return false;
    }
    
    if (signed && !areTokensSigned(tokenResults)) {
        return false;
    }
    if (encrypted && !areTokensEncrypted(tokenResults)) {
        return false;
    }
    tokenResults.addAll(dktResults);
    if (endorsed && !checkEndorsed(tokenResults)) {
        return false;
    }
    
    if (!validateSignedEncryptedPolicies(tokenResults)) {
        return false;
    }
    
    return true;
}
 
Example 5
Source File: NegotiationUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Return true on successfully parsing a SecurityContextToken result
 */
static boolean parseSCTResult(SoapMessage message) {
    List<WSHandlerResult> results = 
        CastUtils.cast((List<?>)message.get(WSHandlerConstants.RECV_RESULTS));
    if (results == null) {
        return false;
    }
    
    for (WSHandlerResult rResult : results) {
        List<WSSecurityEngineResult> wsSecEngineResults = rResult.getResults();

        for (WSSecurityEngineResult wser : wsSecEngineResults) {
            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());
                
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                if (secret != null) {
                    SecurityToken token = new SecurityToken(tok.getIdentifier());
                    token.setToken(tok.getElement());
                    token.setSecret(secret);
                    token.setTokenType(tok.getTokenType());
                    getTokenStore(message).add(token);
                }
                return true;
            }
        }
    }
    return false;
}
 
Example 6
Source File: AbstractSupportingTokenPolicyValidator.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Process Security Context Tokens.
 */
protected boolean processSCTokens() {
    List<WSSecurityEngineResult> tokenResults = new ArrayList<WSSecurityEngineResult>();
    List<WSSecurityEngineResult> dktResults = new ArrayList<WSSecurityEngineResult>();
    for (WSSecurityEngineResult wser : results) {
        Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
        if (actInt.intValue() == WSConstants.SCT) {
            if (derived) {
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                WSSecurityEngineResult dktResult = getMatchingDerivedKey(secret);
                if (dktResult != null) {
                    dktResults.add(dktResult);
                }
            }
            tokenResults.add(wser);
        }
    }
    
    if (tokenResults.isEmpty()) {
        return false;
    }
    
    if (signed && !areTokensSigned(tokenResults)) {
        return false;
    }
    if (encrypted && !areTokensEncrypted(tokenResults)) {
        return false;
    }
    tokenResults.addAll(dktResults);
    if (endorsed && !checkEndorsed(tokenResults)) {
        return false;
    }
    
    if (!validateSignedEncryptedPolicies(tokenResults)) {
        return false;
    }
    
    return true;
}
 
Example 7
Source File: NegotiationUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Return true on successfully parsing a SecurityContextToken result
 */
static boolean parseSCTResult(SoapMessage message) {
    List<WSHandlerResult> results = 
        CastUtils.cast((List<?>)message.get(WSHandlerConstants.RECV_RESULTS));
    if (results == null) {
        return false;
    }
    
    for (WSHandlerResult rResult : results) {
        List<WSSecurityEngineResult> wsSecEngineResults = rResult.getResults();

        for (WSSecurityEngineResult wser : wsSecEngineResults) {
            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());
                
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                if (secret != null) {
                    SecurityToken token = new SecurityToken(tok.getIdentifier());
                    token.setToken(tok.getElement());
                    token.setSecret(secret);
                    token.setTokenType(tok.getTokenType());
                    getTokenStore(message).add(token);
                }
                return true;
            }
        }
    }
    return false;
}
 
Example 8
Source File: AbstractSupportingTokenPolicyValidator.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Process Security Context Tokens.
 */
protected boolean processSCTokens() {
    List<WSSecurityEngineResult> tokenResults = new ArrayList<WSSecurityEngineResult>();
    List<WSSecurityEngineResult> dktResults = new ArrayList<WSSecurityEngineResult>();
    for (WSSecurityEngineResult wser : results) {
        Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
        if (actInt.intValue() == WSConstants.SCT) {
            if (derived) {
                byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                WSSecurityEngineResult dktResult = getMatchingDerivedKey(secret);
                if (dktResult != null) {
                    dktResults.add(dktResult);
                }
            }
            tokenResults.add(wser);
        }
    }
    
    if (tokenResults.isEmpty()) {
        return false;
    }
    
    if (signed && !areTokensSigned(tokenResults)) {
        return false;
    }
    if (encrypted && !areTokensEncrypted(tokenResults)) {
        return false;
    }
    tokenResults.addAll(dktResults);
    if (endorsed && !checkEndorsed(tokenResults)) {
        return false;
    }
    
    if (!validateSignedEncryptedPolicies(tokenResults)) {
        return false;
    }
    
    return true;
}