public class UsernameToken extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BASE64_ENCODING |
static int |
DEFAULT_ITERATION |
static String |
PASSWORD_TYPE |
static QName |
TOKEN |
Constructor and Description |
---|
UsernameToken(boolean milliseconds,
Document doc)
Constructs a
UsernameToken object according to the defined
parameters. |
UsernameToken(boolean milliseconds,
Document doc,
String pwType)
Constructs a
UsernameToken object according to the defined
parameters. |
UsernameToken(boolean milliseconds,
Document doc,
WSTimeSource timeSource,
String pwType) |
UsernameToken(Element elem,
boolean allowNamespaceQualifiedPasswordTypes,
BSPEnforcer bspEnforcer)
Constructs a
UsernameToken object and parses the
wsse:UsernameToken element to initialize it. |
Modifier and Type | Method and Description |
---|---|
void |
addCreated(boolean milliseconds,
Document doc)
Creates and adds a Created element to this UsernameToken
|
void |
addCreated(boolean milliseconds,
WSTimeSource timeSource,
Document doc)
Creates and adds a Created element to this UsernameToken
|
void |
addIteration(Document doc,
int iteration)
Creates and adds a Iteration element to this UsernameToken
|
void |
addNonce(Document doc)
Creates and adds a Nonce element to this UsernameToken
|
byte[] |
addSalt(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.
|
boolean |
containsPasswordElement()
Return true if this UsernameToken contains a Password element
|
Principal |
createPrincipal()
Create a WSUsernameTokenPrincipal from this UsernameToken object
|
static String |
doPasswordDigest(String nonce,
String created,
byte[] password) |
static String |
doPasswordDigest(String nonce,
String created,
String password) |
boolean |
equals(Object object) |
String |
getCreated()
Get the created timestamp.
|
Date |
getCreatedDate()
Return the Created Element as a Date object
|
byte[] |
getDerivedKey(BSPEnforcer bspEnforcer)
This method gets a derived key as defined in WSS Username Token Profile.
|
Element |
getElement()
Returns the dom element of this
UsernameToken object. |
String |
getID()
Gets the id.
|
int |
getIteration()
Get the Iteration value of this UsernameToken.
|
String |
getName()
Get the user name.
|
String |
getNonce()
Get the nonce.
|
String |
getPassword()
Gets the password string.
|
boolean |
getPasswordsAreEncoded() |
String |
getPasswordType() |
byte[] |
getSalt()
Get the Salt value of this UsernameToken.
|
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(String id)
Set the id of this username token.
|
void |
setName(String name)
Set the user name.
|
void |
setPassword(String pwd)
Sets the password string.
|
void |
setPasswordsAreEncoded(boolean passwordsAreEncoded) |
void |
setRawPassword(CallbackHandler callbackHandler)
Set the raw (plain text) password used to compute secret key.
|
String |
toString()
Returns the string representation of the token.
|
boolean |
verifyCreated(int timeToLive,
int futureTimeToLive)
Return true if the "Created" value is before the current time minus the timeToLive
argument, and if the Created value is not "in the future".
|
public static final String BASE64_ENCODING
public static final String PASSWORD_TYPE
public static final int DEFAULT_ITERATION
public static final QName TOKEN
public UsernameToken(Element elem, boolean allowNamespaceQualifiedPasswordTypes, BSPEnforcer bspEnforcer) 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)bspEnforcer
- a BSPEnforcer instance to enforce BSP rulesWSSecurityException
public UsernameToken(boolean milliseconds, Document doc)
UsernameToken
object according to the defined
parameters. This constructs set the password encoding to
WSS4JConstants.PASSWORD_DIGEST
doc
- the SOAP envelope as Document
public UsernameToken(boolean milliseconds, Document doc, String pwType)
UsernameToken
object according to the defined
parameters.doc
- the SOAP envelope as Document
pwType
- the required password encoding, either
WSS4JConstants.PASSWORD_DIGEST
or
WSS4JConstants.PASSWORD_TEXT
or
WSS4JConstants.PW_NONE
null
if no
password requiredpublic UsernameToken(boolean milliseconds, Document doc, WSTimeSource timeSource, String pwType)
public void addWSSENamespace()
public void addWSUNamespace()
public void addNonce(Document doc)
public void addCreated(boolean milliseconds, Document doc)
public void addCreated(boolean milliseconds, WSTimeSource timeSource, Document doc)
public byte[] addSalt(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 MACpublic void addIteration(Document doc, int iteration)
public String getName()
public void setName(String name)
name
- sets a text node containing the use name into the user name
element.public String getNonce()
public String getCreated()
public Date getCreatedDate()
public String getPassword()
null
if no such node exists.public boolean containsPasswordElement()
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 WSS4JConstants.PASSWORD_DIGEST
public String getPasswordType()
public void setPassword(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(CallbackHandler callbackHandler) throws WSSecurityException
WSSecurityException
public void setPasswordsAreEncoded(boolean passwordsAreEncoded)
passwordsAreEncoded
- whether passwords are encodedpublic boolean getPasswordsAreEncoded()
public static String doPasswordDigest(String nonce, String created, byte[] password)
public static String doPasswordDigest(String nonce, String created, String password)
public Element getElement()
UsernameToken
object.wsse:UsernameToken
elementpublic String toString()
public String getID()
wsu:Id
attribute of this username
tokenpublic void setID(String id)
id
- the value for the wsu:Id
attribute of this
username tokenpublic byte[] getDerivedKey(BSPEnforcer bspEnforcer) throws WSSecurityException
WSSecurityException
public boolean isDerivedKey() throws WSSecurityException
WSSecurityException
public Principal createPrincipal() throws WSSecurityException
WSSecurityException
public boolean verifyCreated(int timeToLive, int futureTimeToLive)
timeToLive
- the value in seconds for the validity of the Created timefutureTimeToLive
- the value in seconds for the future validity of the Created timeCopyright © 2017 JBoss by Red Hat. All rights reserved.