Search in sources :

Example 1 with EncryptionToken

use of org.apache.wss4j.policy.model.EncryptionToken in project cxf by apache.

the class AbstractBindingPolicyValidator method checkDerivedKeys.

/**
 * Check the derived key requirement.
 */
protected boolean checkDerivedKeys(AbstractTokenWrapper tokenWrapper, boolean hasDerivedKeys, List<WSSecurityEngineResult> signedResults, List<WSSecurityEngineResult> encryptedResults) {
    AbstractToken token = tokenWrapper.getToken();
    boolean isDerivedKeys = token.getDerivedKeys() == DerivedKeys.RequireDerivedKeys;
    // If derived keys are not required then just return
    if (!(token instanceof X509Token && isDerivedKeys)) {
        return true;
    }
    if (tokenWrapper instanceof EncryptionToken && !hasDerivedKeys && !encryptedResults.isEmpty()) {
        return false;
    } else if (tokenWrapper instanceof SignatureToken && !hasDerivedKeys && !signedResults.isEmpty()) {
        return false;
    } else if (tokenWrapper instanceof ProtectionToken && !hasDerivedKeys && !(signedResults.isEmpty() || encryptedResults.isEmpty())) {
        return false;
    }
    return true;
}
Also used : AbstractToken(org.apache.wss4j.policy.model.AbstractToken) X509Token(org.apache.wss4j.policy.model.X509Token) SignatureToken(org.apache.wss4j.policy.model.SignatureToken) EncryptionToken(org.apache.wss4j.policy.model.EncryptionToken) ProtectionToken(org.apache.wss4j.policy.model.ProtectionToken)

Aggregations

AbstractToken (org.apache.wss4j.policy.model.AbstractToken)1 EncryptionToken (org.apache.wss4j.policy.model.EncryptionToken)1 ProtectionToken (org.apache.wss4j.policy.model.ProtectionToken)1 SignatureToken (org.apache.wss4j.policy.model.SignatureToken)1 X509Token (org.apache.wss4j.policy.model.X509Token)1