/**
* Create a WSDerivedKeyTokenPrincipal from this DerivedKeyToken object
*/
public Principal createPrincipal() throws WSSecurityException {
WSDerivedKeyTokenPrincipal principal = new WSDerivedKeyTokenPrincipal(getID());
principal.setNonce(getNonce());
principal.setLabel(getLabel());
principal.setLength(getLength());
principal.setOffset(getOffset());
principal.setAlgorithm(getAlgorithm());
String basetokenId = null;
SecurityTokenReference securityTokenReference = getSecurityTokenReference();
if (securityTokenReference.containsReference()) {
basetokenId = securityTokenReference.getReference().getURI();
if (basetokenId.charAt(0) == '#') {
basetokenId = basetokenId.substring(1);
}
} else {
// KeyIdentifier
basetokenId = securityTokenReference.getKeyIdentifierValue();
}
principal.setBasetokenId(basetokenId);
return principal;
}