TokenProvider samlTokenProvider = new SAMLTokenProvider();
TokenProviderParameters providerParameters =
createProviderParameters(WSConstants.WSS_SAML2_TOKEN_TYPE, STSConstants.SYMMETRIC_KEY_KEYTYPE);
assertTrue(samlTokenProvider.canHandleToken(WSConstants.WSS_SAML2_TOKEN_TYPE));
Entropy entropy = new Entropy();
entropy.setBinarySecretValue(WSSecurityUtil.generateNonce(256 / 8));
providerParameters.getKeyRequirements().setEntropy(entropy);
try {
samlTokenProvider.createToken(providerParameters);
fail("Failure expected on no type");
} catch (STSException ex) {
// expected as no type is provided
}
entropy.setBinarySecretType("bad-type");
try {
samlTokenProvider.createToken(providerParameters);
fail("Failure expected on a bad type");
} catch (STSException ex) {
// expected as no type is provided
}
entropy.setBinarySecretType(STSConstants.NONCE_TYPE);
try {
samlTokenProvider.createToken(providerParameters);
fail("Failure expected on no computed key algorithm");
} catch (STSException ex) {
// expected as no computed key algorithm is provided