use of org.apache.wss4j.policy.model.X509Token.TokenType in project cxf by apache.
the class AbstractBindingBuilder method checkForX509PkiPath.
private void checkForX509PkiPath(WSSecSignature sig, AbstractToken token) {
if (token instanceof X509Token) {
X509Token x509Token = (X509Token) token;
TokenType tokenType = x509Token.getTokenType();
if (tokenType == TokenType.WssX509PkiPathV1Token10 || tokenType == TokenType.WssX509PkiPathV1Token11) {
sig.setUseSingleCertificate(false);
}
}
}
use of org.apache.wss4j.policy.model.X509Token.TokenType in project cxf by apache.
the class AbstractStaxBindingHandler method configureSignature.
protected void configureSignature(AbstractToken token, boolean attached) throws WSSecurityException {
if (token instanceof X509Token) {
X509Token x509Token = (X509Token) token;
TokenType tokenType = x509Token.getTokenType();
if (tokenType == TokenType.WssX509PkiPathV1Token10 || tokenType == TokenType.WssX509PkiPathV1Token11) {
properties.setUseSingleCert(false);
}
}
properties.setSignatureKeyIdentifier(getKeyIdentifierType(token));
// Find out do we also need to include the token as per the Inclusion requirement
WSSecurityTokenConstants.KeyIdentifier keyIdentifier = properties.getSignatureKeyIdentifier();
if (token instanceof X509Token && isTokenRequired(token.getIncludeTokenType()) && (WSSecurityTokenConstants.KeyIdentifier_IssuerSerial.equals(keyIdentifier) || WSSecurityTokenConstants.KEYIDENTIFIER_THUMBPRINT_IDENTIFIER.equals(keyIdentifier) || WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE.equals(keyIdentifier))) {
properties.setIncludeSignatureToken(true);
} else {
properties.setIncludeSignatureToken(false);
}
String userNameKey = SecurityConstants.SIGNATURE_USERNAME;
if (binding instanceof SymmetricBinding) {
userNameKey = SecurityConstants.ENCRYPT_USERNAME;
properties.setSignatureAlgorithm(binding.getAlgorithmSuite().getSymmetricSignature());
} else {
properties.setSignatureAlgorithm(binding.getAlgorithmSuite().getAsymmetricSignature());
}
properties.setSignatureCanonicalizationAlgorithm(binding.getAlgorithmSuite().getC14n().getValue());
String sigUser = (String) SecurityUtils.getSecurityPropertyValue(userNameKey, message);
if (sigUser == null) {
sigUser = (String) SecurityUtils.getSecurityPropertyValue(SecurityConstants.USERNAME, message);
}
if (sigUser != null && properties.getSignatureUser() == null) {
properties.setSignatureUser(sigUser);
}
AlgorithmSuiteType algType = binding.getAlgorithmSuite().getAlgorithmSuiteType();
properties.setSignatureDigestAlgorithm(algType.getDigest());
// sig.setSigCanonicalization(binding.getAlgorithmSuite().getC14n().getValue());
boolean includePrefixes = MessageUtils.getContextualBoolean(message, SecurityConstants.ADD_INCLUSIVE_PREFIXES, true);
properties.setAddExcC14NInclusivePrefixes(includePrefixes);
}
use of org.apache.wss4j.policy.model.X509Token.TokenType in project cxf by apache.
the class X509TokenPolicyValidator method assertToken.
private void assertToken(X509Token token, AssertionInfoMap aim) {
String namespace = token.getName().getNamespaceURI();
// Assert references
if (token.isRequireIssuerSerialReference()) {
PolicyUtils.assertPolicy(aim, new QName(namespace, SPConstants.REQUIRE_ISSUER_SERIAL_REFERENCE));
}
if (token.isRequireThumbprintReference()) {
PolicyUtils.assertPolicy(aim, new QName(namespace, SPConstants.REQUIRE_THUMBPRINT_REFERENCE));
}
if (token.isRequireEmbeddedTokenReference()) {
PolicyUtils.assertPolicy(aim, new QName(namespace, SPConstants.REQUIRE_EMBEDDED_TOKEN_REFERENCE));
}
if (token.isRequireKeyIdentifierReference()) {
PolicyUtils.assertPolicy(aim, new QName(namespace, SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE));
}
// Assert TokenType
TokenType tokenType = token.getTokenType();
if (tokenType != null) {
PolicyUtils.assertPolicy(aim, new QName(namespace, tokenType.name()));
}
}
Aggregations