}
// AppliesTo
//final AppliesTo scopes = ((RequestSecurityToken)request).getAppliesTo();
final RequestedProofToken proofToken = wsscEleFac.createRequestedProofToken();
// Get client entropy
byte[] clientEntr = null;
final Entropy clientEntropy = ((RequestSecurityToken)request).getEntropy();
if (clientEntropy != null){
final BinarySecret clientBS = clientEntropy.getBinarySecret();
if (clientBS == null){
//ToDo
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE,
LogStringsMessages.WSSC_0009_CLIENT_ENTROPY_VALUE("null"));
}
}else {
clientEntr = clientBS.getRawValue();
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE,
LogStringsMessages.WSSC_0009_CLIENT_ENTROPY_VALUE(clientEntropy.toString()));
}
}
}
parseAssertion(scToken, clientEntropy);
int keySize = (int)((RequestSecurityToken)request).getKeySize();
if (keySize < 1 && symBinding!=null ){
final AlgorithmSuite algoSuite = symBinding.getAlgorithmSuite();
keySize = algoSuite.getMinSKLAlgorithm();
}
if (keySize < 1){
keySize = DEFAULT_KEY_SIZE;
}
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE,
LogStringsMessages.WSSC_0011_KEY_SIZE_VALUE(keySize, WSSCContract.DEFAULT_KEY_SIZE));
}
byte[] secret = WSTrustUtil.generateRandomSecret(keySize/8);
final String proofTokenType = (clientEntr == null ||clientEntr.length ==0)
? wsTrustVer.getSymmetricKeyTypeURI() :wsTrustVer.getNonceBinarySecretTypeURI();
Entropy serverEntropy = null;
if(reqServerEntr){
final BinarySecret serverBS = wsscEleFac.createBinarySecret(secret, proofTokenType);
if (proofTokenType.equals(wsTrustVer.getNonceBinarySecretTypeURI())){
serverEntropy = wsscEleFac.createEntropy(serverBS);
proofToken.setProofTokenType(RequestedProofToken.COMPUTED_KEY_TYPE);
proofToken.setComputedKey(computeKeyAlgo);
// compute the secret key
try {
secret = SecurityUtil.P_SHA1(clientEntr, secret, keySize/8);
} catch (Exception ex){
log.log(Level.SEVERE,
LogStringsMessages.WSSC_0012_COMPUTE_SECKEY(), ex);
throw new WSSecureConversationException(LogStringsMessages.WSSC_0012_COMPUTE_SECKEY(), ex);
}
} else {
proofToken.setProofTokenType(RequestedProofToken.BINARY_SECRET_TYPE);
proofToken.setBinarySecret(serverBS);
}
}else if (clientEntropy != null){
secret = clientEntr;
proofToken.setProofTokenType(RequestedProofToken.BINARY_SECRET_TYPE);
proofToken.setBinarySecret(clientEntropy.getBinarySecret());
}
Lifetime lifetime = (Lifetime)((RequestSecurityToken)request).getLifetime();
if(lifetime != null){