// Test Entropy
clientEntropy = keyRequirements.getEntropy();
if (clientEntropy == null) {
LOG.log(Level.WARNING, "A SymmetricKey KeyType is requested, but no client entropy is provided");
} else if (clientEntropy.getBinarySecret() != null) {
BinarySecret binarySecret = clientEntropy.getBinarySecret();
if (STSConstants.NONCE_TYPE.equals(binarySecret.getBinarySecretType())) {
byte[] nonce = binarySecret.getBinarySecretValue();
if (nonce == null || (nonce.length < (keySize / 8))) {
LOG.log(Level.WARNING, "User Entropy rejected");
clientEntropy = null;
}
String computedKeyAlgorithm = keyRequirements.getComputedKeyAlgorithm();
if (!STSConstants.COMPUTED_KEY_PSHA1.equals(computedKeyAlgorithm)) {
LOG.log(
Level.WARNING,
"The computed key algorithm of " + computedKeyAlgorithm + " is not supported"
);
throw new STSException(
"Computed Key Algorithm not supported", STSException.INVALID_REQUEST
);
}
} else if (STSConstants.SYMMETRIC_KEY_TYPE.equals(binarySecret.getBinarySecretType())
|| binarySecret.getBinarySecretType() == null) {
byte[] secretValue = binarySecret.getBinarySecretValue();
if (((long)secretValue.length * 8L) < signatureProperties.getMinimumKeySize()
|| ((long)secretValue.length * 8L) > signatureProperties.getMaximumKeySize()) {
LOG.log(
Level.WARNING, "Received secret of length " + secretValue.length
+ " bits is not accepted"
);
LOG.log(Level.WARNING, "User Entropy rejected");
clientEntropy = null;
}
} else {
LOG.log(
Level.WARNING, "The type " + binarySecret.getBinarySecretType() + " is not supported"
);
throw new STSException(
"No user supplied entropy for SymmetricKey case", STSException.INVALID_REQUEST
);
}