UserNameToken.java revision 4a2f0f0be43dfd4c1b490cbf3cc48b6ba6084b1c
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: UserNameToken.java,v 1.8 2009/01/24 01:31:25 mallas Exp $
*
*/
/**
* This class <code>UserNameToken</code> represents an Username
* token that can be inserted into web services security header
* for message level security.
*
* <p>This class implements <code>SecurityToken</code> and can be
* created through security token factory.
*/
public class UserNameToken implements SecurityToken {
private boolean setNonce = false;
private boolean setTimeStamp = false;
/**
* Constructs a user name token with the user name token specification.
*
* @param tokenSpec the user name token specification.
* @exception SecurityException if there is a failure.
*/
throw new SecurityException(
}
}
}
if(setNonce) {
createNonce();
}
if(setTimeStamp) {
}
}
/**
* Constructor to create a username token using username token xml element.
* @param element username token xml element.
* @exception SecurityException if the element parsing fails.
*/
throw new IllegalArgumentException(
}
throw new SecurityException(
}
throw new SecurityException(
}
continue;
}
} else {
}
} else {
if(debug.messageEnabled()) {
child.getLocalName());
}
}
}
throw new SecurityException(
}
}
/**
* Returns the username in the username token.
*
* @return the user name
*/
public String getUserName() {
return username;
}
/**
* Sets the user name in the username token.
* @param username the user name.
*/
}
/**
* Returns the password in the username token.
* @return the password in the username token.
*/
public String getPassword() {
return password;
}
/**
* Returns the password type.
* @return the password type.
*/
public String getPasswordType() {
return passwordType;
}
/**
* Sets the password to the username token.
* @param passwd the password to the username token.
* @exception SecurityException if the password digest is failed when
* the digest password type is set.
*/
throw new SecurityException(
}
if(passwordType != null &&
} else {
}
}
/**
* Returns the nonce
* @return the nonce
*/
return nonce;
}
/**
* Returns the created.
* @return the created.
*/
public String getCreated() {
return created;
}
/**
* Returns the signing id for username token.
* @return the signing id for the username token.
*/
public String getSigningId() {
return id;
}
/**
* Returns as the string format for this username token
*/
return xmlString;
}
.append("\">\n")
if(passwordType != null) {
.append("\"");
}
}
}
if(debug.messageEnabled()) {
}
return xmlString;
}
/**
* Returns the XML document element for the username security token.
* @return Element the XML Element for the username security token.
* @exception if the XML document conversion is failed.
*/
throw new SecurityException(
}
return document.getDocumentElement();
}
/**
* Returns this security token type.
*
* @return user name security token.
*/
public String getTokenType() {
return SecurityToken.WSS_USERNAME_TOKEN ;
}
/**
* Creates nonce.
*/
private void createNonce() throws SecurityException {
byte[] nonceValue = new byte[18];
try {
throw new SecurityException();
}
}
/**
* Returns the password digest for the given password using nonce
* and created timestamp.
* @param password the password that needs to be digested.
* @param nonce the nonce that is used to digest the password.
* @param created the created that is used to digest the password.
* @exception SecurityException if the password digest is failed.
*/
try {
"created are required");
throw new IllegalArgumentException("nullInputParams");
}
int i = 0;
int offset = 0;
" error.", ex);
throw new SecurityException(
}
}
}