byte[] seed = new byte[label.length + nonce.length];
System.arraycopy(label, 0, seed, 0, label.length);
System.arraycopy(nonce, 0, seed, label.length, nonce.length);
DerivationAlgorithm derivationAlgorithm;
try {
derivationAlgorithm = AlgoFactory.getInstance(WSSConstants.P_SHA_1);
} catch (ConversationException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
final byte[] derivedKeyBytes;
try {
byte[] secret;
if (WSSecurityTokenConstants.SecurityContextToken.equals(wrappingSecurityToken.getTokenType())) {
WSPasswordCallback passwordCallback = new WSPasswordCallback(wsuIdDKT, WSPasswordCallback.Usage.SECRET_KEY);
WSSUtils.doSecretKeyCallback(((WSSSecurityProperties)securityProperties).getCallbackHandler(), passwordCallback, wsuIdDKT);
if (passwordCallback.getKey() == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noKey", wsuIdDKT);
}
secret = passwordCallback.getKey();
} else {
secret = wrappingSecurityToken.getSecretKey("").getEncoded();
}
derivedKeyBytes = derivationAlgorithm.createKey(secret, seed, offset, length);
} catch (ConversationException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
final GenericOutboundSecurityToken derivedKeySecurityToken =