protected void decodeSignatureParameter(RequestData reqData)
throws WSSecurityException {
Object mc = reqData.getMsgContext();
String signatureUser = getString(WSHandlerConstants.SIGNATURE_USER, mc);
SignatureActionToken actionToken = reqData.getSignatureToken();
if (actionToken == null) {
actionToken = new SignatureActionToken();
reqData.setSignatureToken(actionToken);
}
if (signatureUser != null) {
actionToken.setUser(signatureUser);
} else {
actionToken.setUser(reqData.getUsername());
}
String keyId = getString(WSHandlerConstants.SIG_KEY_ID, mc);
if (keyId != null) {
Integer id = WSHandlerConstants.getKeyIdentifier(keyId);
if (id == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"empty",
"WSHandler: Signature: unknown key identification"
);
}
int tmp = id;
if (!(tmp == WSConstants.ISSUER_SERIAL
|| tmp == WSConstants.BST_DIRECT_REFERENCE
|| tmp == WSConstants.X509_KEY_IDENTIFIER
|| tmp == WSConstants.SKI_KEY_IDENTIFIER
|| tmp == WSConstants.THUMBPRINT_IDENTIFIER
|| tmp == WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER
|| tmp == WSConstants.KEY_VALUE)) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"empty",
"WSHandler: Signature: illegal key identification"
);
}
actionToken.setKeyIdentifierId(tmp);
}
String algo = getString(WSHandlerConstants.SIG_ALGO, mc);
actionToken.setSignatureAlgorithm(algo);
String derivedKeyReference = getString(WSHandlerConstants.DERIVED_TOKEN_REFERENCE, mc);
actionToken.setDerivedKeyTokenReference(derivedKeyReference);
String derivedKeyIdentifier = getString(WSHandlerConstants.DERIVED_TOKEN_KEY_ID, mc);
if (derivedKeyIdentifier != null) {
Integer id = WSHandlerConstants.getKeyIdentifier(derivedKeyIdentifier);
actionToken.setDerivedKeyIdentifier(id);
}
String derivedKeyLength = getString(WSHandlerConstants.DERIVED_SIGNATURE_KEY_LENGTH, mc);
if (derivedKeyLength != null) {
try {
int dKL = Integer.parseInt(derivedKeyLength);
if (dKL > 0) {
actionToken.setDerivedKeyLength(dKL);
}
} catch (NumberFormatException e) {
LOG.warn("Error in configuring a derived key length: " + e.getMessage());
}
}
String digestAlgo = getString(WSHandlerConstants.SIG_DIGEST_ALGO, mc);
actionToken.setDigestAlgorithm(digestAlgo);
String c14nAlgo = getString(WSHandlerConstants.SIG_C14N_ALGO, mc);
actionToken.setC14nAlgorithm(c14nAlgo);
boolean use200512Namespace = decodeUse200512Namespace(reqData);
reqData.setUse200512Namespace(use200512Namespace);
String parts = getString(WSHandlerConstants.SIGNATURE_PARTS, mc);
if (parts != null) {
splitEncParts(true, parts, actionToken.getParts(), reqData);
}
parts = getString(WSHandlerConstants.OPTIONAL_SIGNATURE_PARTS, mc);
if (parts != null) {
splitEncParts(false, parts, actionToken.getParts(), reqData);
}
boolean useSingleCert = decodeUseSingleCertificate(reqData);
actionToken.setUseSingleCert(useSingleCert);
boolean includeToken = decodeIncludeSignatureToken(reqData);
actionToken.setIncludeToken(includeToken);
}