|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ws.security.message.token.UsernameToken
public class UsernameToken
UsernameToken according to WS Security specifications, UsernameToken profile. Enhanced to support digest password type for username token signature Enhanced to support passwordless usernametokens as allowed by spec.
Field Summary | |
---|---|
static java.lang.String |
BASE64_ENCODING
|
static int |
DEFAULT_ITERATION
|
protected org.w3c.dom.Element |
element
|
protected org.w3c.dom.Element |
elementCreated
|
protected org.w3c.dom.Element |
elementIteration
|
protected org.w3c.dom.Element |
elementNonce
|
protected org.w3c.dom.Element |
elementPassword
|
protected org.w3c.dom.Element |
elementSalt
|
protected org.w3c.dom.Element |
elementUsername
|
protected boolean |
hashed
|
static java.lang.String |
PASSWORD_TYPE
|
protected java.lang.String |
passwordType
|
static javax.xml.namespace.QName |
TOKEN
|
Constructor Summary | |
---|---|
UsernameToken(boolean milliseconds,
org.w3c.dom.Document doc)
Constructs a UsernameToken object according to the defined
parameters. |
|
UsernameToken(boolean milliseconds,
org.w3c.dom.Document doc,
java.lang.String pwType)
Constructs a UsernameToken object according to the defined
parameters. |
|
UsernameToken(org.w3c.dom.Element elem)
Constructs a UsernameToken object and parses the
wsse:UsernameToken element to initialize it. |
|
UsernameToken(org.w3c.dom.Element elem,
boolean allowNamespaceQualifiedPasswordTypes,
boolean bspCompliant)
Constructs a UsernameToken object and parses the
wsse:UsernameToken element to initialize it. |
Method Summary | |
---|---|
void |
addCreated(boolean milliseconds,
org.w3c.dom.Document doc)
Creates and adds a Created element to this UsernameToken |
void |
addIteration(org.w3c.dom.Document doc,
int iteration)
Creates and adds a Iteration element to this UsernameToken |
void |
addNonce(org.w3c.dom.Document doc)
Creates and adds a Nonce element to this UsernameToken |
byte[] |
addSalt(org.w3c.dom.Document doc,
byte[] saltValue,
boolean mac)
Adds and optionally creates a Salt element to this UsernameToken. |
void |
addWSSENamespace()
Add the WSSE Namespace to this UT. |
void |
addWSUNamespace()
Add the WSU Namespace to this UT. |
java.security.Principal |
createPrincipal()
Create a WSUsernameTokenPrincipal from this UsernameToken object |
static java.lang.String |
doPasswordDigest(java.lang.String nonce,
java.lang.String created,
byte[] password)
|
static java.lang.String |
doPasswordDigest(java.lang.String nonce,
java.lang.String created,
java.lang.String password)
|
boolean |
equals(java.lang.Object object)
|
static byte[] |
generateDerivedKey(byte[] password,
byte[] salt,
int iteration)
This static method generates a derived key as defined in WSS Username Token Profile. |
static byte[] |
generateDerivedKey(java.lang.String password,
byte[] salt,
int iteration)
This static method generates a derived key as defined in WSS Username Token Profile. |
static byte[] |
generateSalt(boolean useForMac)
This static method generates a 128 bit salt value as defined in WSS Username Token Profile. |
java.lang.String |
getCreated()
Get the created timestamp. |
byte[] |
getDerivedKey()
This method gets a derived key as defined in WSS Username Token Profile. |
org.w3c.dom.Element |
getElement()
Returns the dom element of this UsernameToken object. |
java.lang.String |
getID()
Gets the id. |
int |
getIteration()
Get the Iteration value of this UsernameToken. |
java.lang.String |
getName()
Get the user name. |
java.lang.String |
getNonce()
Get the nonce. |
java.lang.String |
getPassword()
Gets the password string. |
boolean |
getPasswordsAreEncoded()
|
java.lang.String |
getPasswordType()
|
byte[] |
getSalt()
Get the Salt value of this UsernameToken. |
byte[] |
getSecretKey()
Gets the secret key as per WS-Trust spec. |
byte[] |
getSecretKey(int keylen)
Gets the secret key as per WS-Trust spec. |
byte[] |
getSecretKey(int keylen,
java.lang.String labelString)
Gets the secret key as per WS-Trust spec. |
int |
hashCode()
|
boolean |
isDerivedKey()
Return whether the UsernameToken represented by this class is to be used for key derivation as per the UsernameToken Profile 1.1. |
boolean |
isHashed()
Get the hashed indicator. |
void |
setID(java.lang.String id)
Set the id of this username token. |
void |
setName(java.lang.String name)
Set the user name. |
void |
setPassword(java.lang.String pwd)
Sets the password string. |
void |
setPasswordsAreEncoded(boolean passwordsAreEncoded)
|
void |
setRawPassword(RequestData data)
Set the raw (plain text) password used to compute secret key. |
java.lang.String |
toString()
Returns the string representation of the token. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String BASE64_ENCODING
public static final java.lang.String PASSWORD_TYPE
public static final int DEFAULT_ITERATION
public static final javax.xml.namespace.QName TOKEN
protected org.w3c.dom.Element element
protected org.w3c.dom.Element elementUsername
protected org.w3c.dom.Element elementPassword
protected org.w3c.dom.Element elementNonce
protected org.w3c.dom.Element elementCreated
protected org.w3c.dom.Element elementSalt
protected org.w3c.dom.Element elementIteration
protected java.lang.String passwordType
protected boolean hashed
Constructor Detail |
---|
public UsernameToken(org.w3c.dom.Element elem) throws WSSecurityException
UsernameToken
object and parses the
wsse:UsernameToken
element to initialize it.
elem
- the wsse:UsernameToken
element that contains
the UsernameToken data
WSSecurityException
public UsernameToken(org.w3c.dom.Element elem, boolean allowNamespaceQualifiedPasswordTypes, boolean bspCompliant) throws WSSecurityException
UsernameToken
object and parses the
wsse:UsernameToken
element to initialize it.
elem
- the wsse:UsernameToken
element that contains
the UsernameToken dataallowNamespaceQualifiedPasswordTypes
- whether to allow (wsse)
namespace qualified password types or not (for interop with WCF)bspCompliant
- whether the UsernameToken processing complies with the BSP spec
WSSecurityException
public UsernameToken(boolean milliseconds, org.w3c.dom.Document doc)
UsernameToken
object according to the defined
parameters. This constructs set the password encoding to
WSConstants.PASSWORD_DIGEST
doc
- the SOAP envelope as Document
public UsernameToken(boolean milliseconds, org.w3c.dom.Document doc, java.lang.String pwType)
UsernameToken
object according to the defined
parameters.
doc
- the SOAP envelope as Document
pwType
- the required password encoding, either
WSConstants.PASSWORD_DIGEST
or
WSConstants.PASSWORD_TEXT
or
WSConstants.PW_NONE
null
if no
password requiredMethod Detail |
---|
public void addWSSENamespace()
public void addWSUNamespace()
public void addNonce(org.w3c.dom.Document doc)
public void addCreated(boolean milliseconds, org.w3c.dom.Document doc)
public byte[] addSalt(org.w3c.dom.Document doc, byte[] saltValue, boolean mac)
saltValue
is null
the the method
generates a new salt. Otherwise it uses the the given value.
doc
- The Document for the UsernameTokensaltValue
- The salt to add, if null generate a new salt valuemac
- If true
then an optionally generated value is
usable for a MAC
public void addIteration(org.w3c.dom.Document doc, int iteration)
public java.lang.String getName()
public void setName(java.lang.String name)
name
- sets a text node containing the use name into the user name
element.public java.lang.String getNonce()
public java.lang.String getCreated()
public java.lang.String getPassword()
null
if no such node exists.public byte[] getSalt() throws WSSecurityException
null
if no Salt
value is available in the username token.
WSSecurityException
public int getIteration()
public boolean isHashed()
true> the password of the
UsernameToken
was encoded using WSConstants.PASSWORD_DIGEST
- Returns:
- the hashed indicator.
public java.lang.String getPasswordType()
public void setPassword(java.lang.String pwd)
UsernameToken
either as plain text or encodes the password
according to the WS Security specifications, UsernameToken profile, into
a password digest.
pwd
- the password to usepublic void setRawPassword(RequestData data) throws WSSecurityException
WSSecurityException
public void setPasswordsAreEncoded(boolean passwordsAreEncoded)
passwordsAreEncoded
- whether passwords are encodedpublic boolean getPasswordsAreEncoded()
public static java.lang.String doPasswordDigest(java.lang.String nonce, java.lang.String created, byte[] password)
public static java.lang.String doPasswordDigest(java.lang.String nonce, java.lang.String created, java.lang.String password)
public org.w3c.dom.Element getElement()
UsernameToken
object.
wsse:UsernameToken
elementpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getID()
wsu:Id
attribute of this username
tokenpublic void setID(java.lang.String id)
id
- the value for the wsu:Id
attribute of this
username tokenpublic byte[] getSecretKey()
public byte[] getSecretKey(int keylen)
public byte[] getSecretKey(int keylen, java.lang.String labelString)
keylen
- How many bytes to generate for the keylabelString
- the label used to generate the seed
public static byte[] generateDerivedKey(byte[] password, byte[] salt, int iteration) throws WSSecurityException
password
- The password to include in the key generationsalt
- The Salt valueiteration
- The Iteration value. If zero (0) is given the method uses the
default value
WSSecurityException
public static byte[] generateDerivedKey(java.lang.String password, byte[] salt, int iteration) throws WSSecurityException
password
- The password to include in the key generationsalt
- The Salt valueiteration
- The Iteration value. If zero (0) is given the method uses the
default value
WSSecurityException
public byte[] getDerivedKey() throws WSSecurityException
WSSecurityException
public boolean isDerivedKey() throws WSSecurityException
WSSecurityException
public java.security.Principal createPrincipal()
public static byte[] generateSalt(boolean useForMac)
useForMac
- If true
define the Salt for use in a MAC
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |