|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wss4j.dom.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 String |
BASE64_ENCODING
|
static int |
DEFAULT_ITERATION
|
static String |
PASSWORD_TYPE
|
static QName |
TOKEN
|
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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(RequestData data)
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". |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String BASE64_ENCODING
public static final String PASSWORD_TYPE
public static final int DEFAULT_ITERATION
public static final QName TOKEN
| Constructor Detail |
|---|
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 rules
WSSecurityException
public UsernameToken(boolean milliseconds,
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,
Document doc,
String pwType)
UsernameToken object according to the defined
parameters.
doc - the SOAP envelope as DocumentpwType - the required password encoding, either
WSConstants.PASSWORD_DIGEST or
WSConstants.PASSWORD_TEXT or
WSConstants.PW_NONE null if no
password required
public UsernameToken(boolean milliseconds,
Document doc,
WSTimeSource timeSource,
String pwType)
| Method Detail |
|---|
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 MAC
public 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.
WSSecurityExceptionpublic int getIteration()
public boolean isHashed()
true> the password of the
UsernameToken was encoded using WSConstants.PASSWORD_DIGEST
- Returns:
- the hashed indicator.
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 use
public void setRawPassword(RequestData data)
throws WSSecurityException
WSSecurityExceptionpublic 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()
toString in class Objectpublic String getID()
wsu:Id attribute of this username
tokenpublic void setID(String id)
id - the value for the wsu:Id attribute of this
username token
public 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 time
public int hashCode()
hashCode in class Objectpublic boolean equals(Object object)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||