com.ibm.as400.access
Class AS400

java.lang.Object
  |
  +--com.ibm.as400.access.AS400
Direct Known Subclasses:
SecureAS400

public class AS400
extends java.lang.Object
implements java.io.Serializable

The AS400 class represents an AS/400 sign-on.

If running from an AS/400 to another AS/400 or to itself, the system name, user ID, and password do not need to be supplied. These values default to the local system. For the system name, the keyword localhost can be used to specify the local AS/400. For the user ID and password, *CURRENT can be used.

If running from a non-AS/400 to an AS/400, the system name, user ID, and password need to be supplied. If not supplied, the first open request associated with an AS400 object will prompt the workstation user. Subsequent opens associated with the same AS400 object will not prompt the workstation user. Keywords localhost and *CURRENT will not work when running from a non-AS/400 system.

For example:

AS400 as400 = new AS400();
as400.connectService(AS400.DATAQUEUE);   // This causes a password prompt.
...
as400.connectService(AS400.FILE);        // This does not cause a prompt.

See Also:
Serialized Form

Field Summary
static int CENTRAL
          Constant indicating the Central AS/400 service.
static int COMMAND
          Constant indicating the Command AS/400 service.
static int DATABASE
          Constant indicating the Database AS/400 service.
static int DATAQUEUE
          Constant indicating the Dataqueue AS/400 service.
static int FILE
          Constant indicating the File AS/400 service.
static int PRINT
          Constant indicating the Print AS/400 service.
static int RECORDACCESS
          Constant indicating the Record Access AS/400 service.
static int SIGNON
          Constant indicating the Sign-on AS/400 service.
static int USE_PORT_MAPPER
          Special value indicating the service port should be retrieved from the port mapper server.
 
Constructor Summary
AS400()
          Constructs an AS400 object.
AS400(AS400 system)
          Constructs an AS400 object.
AS400(java.lang.String systemName)
          Constructs an AS400 object.
AS400(java.lang.String systemName, java.lang.String userId)
          Constructs an AS400 object.
AS400(java.lang.String systemName, java.lang.String userId, java.lang.String password)
          Constructs an AS400 object.
AS400(java.lang.String systemName, java.lang.String userId, java.lang.String password, java.lang.String proxyServer)
          Constructs an AS400 object.
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
          Adds a listener to the event list.
static void addPasswordCacheEntry(java.lang.String systemName, java.lang.String userId, java.lang.String password)
          Validates the user ID and password against the system, and if successful, adds the information to the password cache.
static void addPasswordCacheEntry(java.lang.String systemName, java.lang.String userId, java.lang.String password, java.lang.String proxyServer)
          Validates the user ID and password against the system, and if successful, adds the information to the password cache.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a property changed listener to the list.
 void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Adds a listener to be notified when the value of any constrained property is changed.
 boolean authenticate(java.lang.String userId, java.lang.String password)
          Authenticates the user profile and password for this system.
 void changePassword(java.lang.String oldPassword, java.lang.String newPassword)
          Changes the password on the AS/400.
static void clearPasswordCache()
          Clears the password cache for all systems within this Java virtual machine.
static void clearPasswordCache(java.lang.String systemName)
          Clears all the passwords that are cached for the given AS/400 within this Java virtual machine.
 void connectService(int service)
          Connects to an AS/400 service on this AS/400.
 void disconnectAllServices()
          Disconnects from the AS/400.
 void disconnectService(int service)
          Disconnects the service from the AS/400.
static int generateVRM(int version, int release, int modification)
          Generates a VRM from a version, release, and modification.
 int getCcsid()
          Returns the CCSID for this AS/400.
static java.lang.String getDefaultUser(java.lang.String systemName)
          Returns the default user ID for this AS/400.
 java.lang.String getJobCCSIDEncoding()
          Returns the encoding that corresponds to the Job CCSID of this AS/400.
 int getModification()
          Returns the modification level of the AS/400.
 java.util.GregorianCalendar getPasswordExpirationDate()
          Returns the password expiration date for the signed on user.
static int getPasswordExpirationWarningDays()
          Returns the number of days before password expiration to start warning the user.
 java.util.GregorianCalendar getPreviousSignonDate()
          Returns the date of the last successful sign-on.
 ProfileTokenCredential getProfileToken()
          Deprecated. Use getProfileToken(int, int) instead.
 ProfileTokenCredential getProfileToken(int tokenType, int timeoutInterval)
          Authenticates the assigned user profile and password and returns a corresponding ProfileTokenCredential if successful.
 ProfileTokenCredential getProfileToken(java.lang.String userId, java.lang.String password)
          Authenticates the given user profile and password and returns a corresponding ProfileTokenCredential if successful.
 ProfileTokenCredential getProfileToken(java.lang.String userId, java.lang.String password, int tokenType, int timeoutInterval)
          Authenticates the given user profile and password and returns a corresponding ProfileTokenCredential if successful.
 java.lang.String getProxyServer()
          Returns the name of the middle-tier machine where the proxy server is running.
 int getRelease()
          Returns the release of the AS/400.
 int getServicePort(int service)
          Returns the service port stored in the service port table for the specified service.
 java.util.GregorianCalendar getSignonDate()
          Returns the date for the current sign-on.
 java.lang.String getSystemName()
          Returns the name of the system.
 java.lang.String getUserId()
          Returns the user ID.
 int getVersion()
          Returns the version of the AS/400.
 int getVRM()
          Returns the version, release, and modification level for the AS/400.
 void initializeConverter(int ccsid)
          Initialize conversion table for the given CCSID.
 boolean isConnected()
          Indicates if any service is currently connected through this AS400 object.
 boolean isConnected(int service)
          Indicates if a service is currently connected through this AS400 object.
 boolean isGuiAvailable()
          Returns the sign-on prompting mode for this AS400 object.
 boolean isLocal()
          Indicates if this AS400 object is representing the system you are currently running on.
 boolean isMustUseSockets()
          When your Java program runs on a V4R3 or later AS/400, the Toolbox record-level database access, data queues, and user space classes access data via a call to an AS/400 API instead of making a socket call to a server.
 boolean isShowCheckboxes()
          Indicates if checkboxes should be shown on the signon dialog.
 boolean isThreadUsed()
          Indicates whether threads are used in communication with the host servers.
 boolean isUseDefaultUser()
          Indicates if the default user should be used by this AS400 object.
 boolean isUsePasswordCache()
          Indicates if password cache is being used by this AS400 object.
 void removeConnectionListener(ConnectionListener listener)
          Removes a listener from the connection event list.
static void removeDefaultUser(java.lang.String systemName)
          Removes the default user for the given AS/400.
static void removePasswordCacheEntry(java.lang.String systemName, java.lang.String userId)
          Removes the password entry associated with this user and AS/400.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a property changed listener from the listener list.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Removes a listener from the veto list.
 void resetAllServices()
          Disconnect all services and clear signon information.
 void setCcsid(int ccsid)
          Sets the CCSID to be used for this AS/400.
static boolean setDefaultUser(java.lang.String systemName, java.lang.String userId)
          Sets the default user for a given AS/400.
 void setGuiAvailable(boolean guiAvailable)
          Sets the environment you are running in.
 void setMustUseSockets(boolean mustUseSockets)
          When your Java program runs on a V4R3 or later AS/400, the Toolbox record-level database access, data queues, and user space classes access data via a call to an AS/400 API instead of making a socket call to a server.
 void setPassword(java.lang.String password)
          Sets the password for this AS400 object.
static void setPasswordExpirationWarningDays(int days)
          Sets the number of days before password expiration to warn the user.
 void setProxyServer(java.lang.String proxyServer)
          Sets the name and port of the middle-tier machine where the proxy server is running.
 void setServicePort(int service, int port)
          Sets the service port in the service port table for the specified service for this system.
 void setServicePortsToDefault()
          Sets the ports in the service port table for all the services for this system to their default values.
 void setShowCheckboxes(boolean showCheckboxes)
          Indicates if checkboxes should be shown on the signon dialog.
 void setSystemName(java.lang.String systemName)
          Sets the system name for this AS400 object.
 void setThreadUsed(boolean useThreads)
          Sets whether the AS/400 Toolbox for Java uses threads in communication with the host servers.
 void setUseDefaultUser(boolean useDefaultUser)
          Sets the indicator for whether the default user is used.
 void setUsePasswordCache(boolean usePasswordCache)
          Sets the indicator for whether the password cache is used.
 void setUserId(java.lang.String userId)
          Sets the user ID for this AS400 object.
 java.lang.String toString()
          Returns the text representation of this AS400 object.
 boolean validateSignon()
          Validates the user ID and password for this AS/400 but does not add to the signed-on list.
 boolean validateSignon(java.lang.String password)
          Validates the user ID and password for this AS/400 but does not add to the signed-on list.
 boolean validateSignon(java.lang.String userId, java.lang.String password)
          Validates the user ID and password for this AS/400 but does not add to the signed-on list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILE

public static final int FILE
Constant indicating the File AS/400 service.

PRINT

public static final int PRINT
Constant indicating the Print AS/400 service.

COMMAND

public static final int COMMAND
Constant indicating the Command AS/400 service.

DATAQUEUE

public static final int DATAQUEUE
Constant indicating the Dataqueue AS/400 service.

DATABASE

public static final int DATABASE
Constant indicating the Database AS/400 service.

RECORDACCESS

public static final int RECORDACCESS
Constant indicating the Record Access AS/400 service.

CENTRAL

public static final int CENTRAL
Constant indicating the Central AS/400 service.

SIGNON

public static final int SIGNON
Constant indicating the Sign-on AS/400 service.

USE_PORT_MAPPER

public static final int USE_PORT_MAPPER
Special value indicating the service port should be retrieved from the port mapper server.
Constructor Detail

AS400

public AS400()
Constructs an AS400 object.

If running on an AS/400, the target is the local system. This has the same effect as using localhost for the system name, *CURRENT for the user ID, and *CURRENT for the password.

If running from a non-AS/400 to an AS/400, a sign-on prompt is displayed. The user is then able to specify the system name, user ID, and password.


AS400

public AS400(java.lang.String systemName)
Constructs an AS400 object. It uses the specified system name.

If running from an AS/400 to another AS/400 or to itself, the user ID and password of the current job are used.

If running from a non-AS/400 to an AS/400, the user is prompted for the user ID and password if a default user has not been established for this AS/400.

Parameters:
systemName - The name of the AS/400. Use localhost to access data locally on the AS/400.

AS400

public AS400(java.lang.String systemName,
             java.lang.String userId)
Constructs an AS400 object. It uses the specified system name and user ID. When the sign-on prompt is displayed, the user is able to specify the password. Note that the user ID may be overridden.
Parameters:
systemName - The name of the AS/400. Use localhost to access data locally on the AS/400.
userId - The user ID to use to connect to the system. If running from an AS/400, *CURRENT may be used to specify the current user ID.

AS400

public AS400(java.lang.String systemName,
             java.lang.String userId,
             java.lang.String password)
Constructs an AS400 object. It uses the specified system name, user ID, and password. No sign-on prompt is displayed unless the sign-on fails.
Parameters:
systemName - The name of the AS/400. Use localhost to access data locally on the AS/400.
userId - The user ID to use to connect to the system. If running from an AS/400, *CURRENT may be used to specify the current user ID.
password - The password to use to connect to the system. If running from an AS/400, *CURRENT may be used to specify the current user ID.

AS400

public AS400(java.lang.String systemName,
             java.lang.String userId,
             java.lang.String password,
             java.lang.String proxyServer)
Constructs an AS400 object. It uses the specified system name, user ID, and password. No sign-on prompt is displayed unless the sign-on fails.
Parameters:
systemName - The name of the AS/400. Use localhost to access data locally on the AS/400.
userId - The user ID to use to connect to the system. If running from an AS/400, *CURRENT may be used to specify the current user ID.
password - The password to use to connect to the system. If running from an AS/400, *CURRENT may be used to specify the current user ID.
proxyServer - The name and port in the format serverName[:port]. If no port is specified, a default will be used.

AS400

public AS400(AS400 system)
Constructs an AS400 object. It uses the same system name and user ID. This does not create a clone. The new AS400 object has the same behavior, but results in a new set of socket connections.
Parameters:
system - A previously instantiated AS400 object.
Method Detail

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Adds a listener to the event list.
Parameters:
listener - The listener object.

addPasswordCacheEntry

public static void addPasswordCacheEntry(java.lang.String systemName,
                                         java.lang.String userId,
                                         java.lang.String password)
                                  throws AS400SecurityException,
                                         java.io.IOException
Validates the user ID and password against the system, and if successful, adds the information to the password cache.
Parameters:
systemName - The system name for the AS/400.
userId - The user ID.
password - The password.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

addPasswordCacheEntry

public static void addPasswordCacheEntry(java.lang.String systemName,
                                         java.lang.String userId,
                                         java.lang.String password,
                                         java.lang.String proxyServer)
                                  throws AS400SecurityException,
                                         java.io.IOException
Validates the user ID and password against the system, and if successful, adds the information to the password cache.
Parameters:
systemName - The system name for the AS/400.
userId - The user ID.
password - The password.
proxyServer - The name and port in the format serverName[:port]. If no port is specified, a default will be used.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property changed listener to the list.
Parameters:
listener - The listener to add.

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed. The vetoableChange method will be called.
Parameters:
listener - The VetoableChangeListener.

changePassword

public void changePassword(java.lang.String oldPassword,
                           java.lang.String newPassword)
                    throws AS400SecurityException,
                           java.io.IOException
Changes the password on the AS/400.
Parameters:
oldpassword - The old password.
newpassword - The new password.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

clearPasswordCache

public static void clearPasswordCache()
Clears the password cache for all systems within this Java virtual machine.

clearPasswordCache

public static void clearPasswordCache(java.lang.String systemName)
Clears all the passwords that are cached for the given AS/400 within this Java virtual machine.
Parameters:
systemName - The system name for the AS/400.

connectService

public void connectService(int service)
                    throws AS400SecurityException,
                           java.io.IOException
Connects to an AS/400 service on this AS/400. Security is validated and a connection is established to the AS/400.

Services typically connect implicitly; therefore, this method does not have to be called to use an AS/400 service. This method can be used to control when the connection is established.
Valid services are:
FILE - IFS file classes
PRINT - print classes
COMMAND - command and program call classes
DATAQUEUE - data queue classes
RECORDACCESS - record level access classes

Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.

disconnectAllServices

public void disconnectAllServices()
Disconnects from the AS/400. All socket connections associated with this AS400 object will be closed.

disconnectService

public void disconnectService(int service)
Disconnects the service from the AS/400. All socket connections associated with this service and this AS400 object will be closed.
Parameters:
service - The name of the service.
Valid services are:
FILE - IFS file classes
PRINT - print classes
COMMAND - command and program call classes
DATAQUEUE - data queue classes
RECORDACCESS - record level access classes

generateVRM

public static int generateVRM(int version,
                              int release,
                              int modification)
Generates a VRM from a version, release, and modification. This can then be used to compare against the VRM returned by getVRM().
Parameters:
version - The version.
release - The release.
modification - The modification level.
Returns:
The generated VRM.

getCcsid

public int getCcsid()
Returns the CCSID for this AS/400. The CCSID returned either is the one retrieved from the AS/400 based on the user profile or is set by the setCcsid() method.
Returns:
The CCSID to use for this AS/400.

getDefaultUser

public static java.lang.String getDefaultUser(java.lang.String systemName)
Returns the default user ID for this AS/400. The default user ID is the last user ID that is currently connected to this AS/400. This user ID is used to connect to the AS/400 if a user ID was not used to construct this AS400 object.
Parameters:
systemName - The name of the AS/400.
Returns:
The default user ID for this AS/400. A null is returned if there is not a default user.

getJobCCSIDEncoding

public java.lang.String getJobCCSIDEncoding()
                                     throws AS400SecurityException,
                                            java.io.IOException,
                                            java.lang.InterruptedException
Returns the encoding that corresponds to the Job CCSID of this AS/400.
Returns:
The encoding.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.lang.InterruptedException - If this thread is interrupted.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getModification

public int getModification()
                    throws AS400SecurityException,
                           java.io.IOException
Returns the modification level of the AS/400. The modification level returned is the modification level of the sign-on server and may not match the OS/400 program.

A connection is required to the AS/400 to retrieve this information. If a connection has not been established, one is created to retrieve the system information.

Returns:
The modification level of the AS/400. For example, version 4, release 1, modification level 2 returns 2.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getPasswordExpirationDate

public java.util.GregorianCalendar getPasswordExpirationDate()
                                                      throws AS400SecurityException,
                                                             java.io.IOException
Returns the password expiration date for the signed on user.

A connection is required to the AS/400 to retrieve this information. If a connection has not been established, one is created to retrieve the system information.

Returns:
The password expiration date.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getPasswordExpirationWarningDays

public static int getPasswordExpirationWarningDays()
Returns the number of days before password expiration to start warning the user.
Returns:
The number of days before expiration to warn the user.

getPreviousSignonDate

public java.util.GregorianCalendar getPreviousSignonDate()
                                                  throws AS400SecurityException,
                                                         java.io.IOException
Returns the date of the last successful sign-on.

A connection is required to the AS/400 to retrieve this information. If a connection has not been established, one is created to retrieve the system information.

Returns:
The date of the last successful sign-on.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getProxyServer

public java.lang.String getProxyServer()
Returns the name of the middle-tier machine where the proxy server is running.
Returns:
The name of the middle-tier machine where the proxy server is running, or an empty string ("") if not set.

getRelease

public int getRelease()
               throws AS400SecurityException,
                      java.io.IOException
Returns the release of the AS/400. The release returned is the release of the sign-on server and may not match the release of the OS/400 program.

A connection is required to the AS/400 in order to retrieve this information. If a connection has not been established, one is created to retrieve the system information.

Returns:
The release of the AS/400. For example, version 4, release 1, modification level 0, returns 1.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getServicePort

public int getServicePort(int service)
Returns the service port stored in the service port table for the specified service.
Parameters:
service - The name of the service.
Returns:
The port specified in the service port table. The value USE_PORT_MAPPER will be returned if the service has not been set, and the service has not been connected.

getSignonDate

public java.util.GregorianCalendar getSignonDate()
                                          throws AS400SecurityException,
                                                 java.io.IOException
Returns the date for the current sign-on.

A connection is required to the AS/400 to retrieve this information. If a connection has not been established, one is created to retrieve the system information.

Returns:
The date for the current sign-on.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getSystemName

public java.lang.String getSystemName()
Returns the name of the system. The system name is provided on the constructor or may have been provided by the user at the sign-on prompt.
Returns:
The name of the AS/400, or an empty string ("") if not set.

getUserId

public java.lang.String getUserId()
Returns the user ID. The user ID returned may be set as a result of the constructor, or it may be what the user typed in at the sign-on prompt.
Returns:
The user ID, or an empty string ("") if not set.

getVersion

public int getVersion()
               throws AS400SecurityException,
                      java.io.IOException
Returns the version of the AS/400.

A connection is required to the AS/400 to retrieve this information. If a connection has not been established, one is created to retrieve the system information.

Returns:
The version of the AS/400. For example, version 4, release 1, modification level 0, returns 4.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getVRM

public int getVRM()
           throws AS400SecurityException,
                  java.io.IOException
Returns the version, release, and modification level for the AS/400.

A connection is required to the AS/400 to retrieve this information. If a connection has not been established, one is created to retrieve the system information.

Returns:
The high 16-bit is the version, the next 8 bits is the release, and the low 8 bits is the modification level. Thus version 4, release 1, modification level 0, returns 0x00040100.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

initializeConverter

public void initializeConverter(int ccsid)
                         throws java.io.UnsupportedEncodingException
Initialize conversion table for the given CCSID. The default EBCDIC to unicode converters are not shipped with some browsers. This method can be used to check and download converters if they are not available locally.
Parameters:
ccsid - the CCSID for the conversion table to initialize.

isConnected

public boolean isConnected()
Indicates if any service is currently connected through this AS400 object.
Returns:
true if any service is connected; false otherwise.

isConnected

public boolean isConnected(int service)
Indicates if a service is currently connected through this AS400 object.

A service is connected if connectService() has been called, or an implicit connect has been done by the service, and disconnectService() or disconnectAllServices() has not been called.
Valid services are:
FILE - IFS file classes
PRINT - print classes
COMMAND - command and program call classes
DATAQUEUE - data queue classes
RECORDACCESS - record-level access

Returns:
true if service is connected; false otherwise.

isGuiAvailable

public boolean isGuiAvailable()
Returns the sign-on prompting mode for this AS400 object. If true, then messages are displayed. If warnings or errors are displayed, then sign-on and change password dialogs are displayed if needed. If false, warnings and errors result in exceptions, and password dialogs are not displayed. The caller has to provide the user ID and password.
Returns:
true if using GUI; false otherwise.

isLocal

public boolean isLocal()
Indicates if this AS400 object is representing the system you are currently running on.
Returns:
true if you are running on this AS/400; false otherwise.

isMustUseSockets

public boolean isMustUseSockets()
When your Java program runs on a V4R3 or later AS/400, the Toolbox record-level database access, data queues, and user space classes access data via a call to an AS/400 API instead of making a socket call to a server. There are minor differences in the behavior of the classes when they use API calls instead of socket calls. If your program is affected by these differences you can check whether the Toolbox classes will use socket calls instead of API calls by using this method.
Returns:
true if you have indicated that the services must use sockets; false otherwise.

isShowCheckboxes

public boolean isShowCheckboxes()
Indicates if checkboxes should be shown on the signon dialog.
Returns:
true if checkboxes should be shown; false otherwise.

isThreadUsed

public boolean isThreadUsed()
Indicates whether threads are used in communication with the host servers.
Returns:
true if threads are used; false otherwise.

isUseDefaultUser

public boolean isUseDefaultUser()
Indicates if the default user should be used by this AS400 object. If default user is not used and a user ID was not specified on the constructor, then the user will be prompted for a user ID.
Returns:
true if default user should be used; false otherwise.

isUsePasswordCache

public boolean isUsePasswordCache()
Indicates if password cache is being used by this AS400 object. If password cache is not used, the user will always be prompted for password if one was not provided in the constructor.
Returns:
true if password cache is being used; false otherwise.

removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
Removes a listener from the connection event list.
Parameters:
listener - The listener to remove.

removeDefaultUser

public static void removeDefaultUser(java.lang.String systemName)
Removes the default user for the given AS/400.
Parameters:
systemName - The name of the AS/400.

removePasswordCacheEntry

public static void removePasswordCacheEntry(java.lang.String systemName,
                                            java.lang.String userId)
Removes the password entry associated with this user and AS/400. Only applies within this Java virtual machine.
Parameters:
systemName - The system name for the AS/400.
user - The user ID associated with the cache entry.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property changed listener from the listener list.
Parameters:
listener - The listener to remove.

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a listener from the veto list.
Parameters:
listener - The VetoableChangeListener.

resetAllServices

public void resetAllServices()
Disconnect all services and clear signon information.

setCcsid

public void setCcsid(int ccsid)
              throws java.beans.PropertyVetoException
Sets the CCSID to be used for this AS/400. The CCSID property cannot be changed once a connection to the AS/400 has been established.
Parameters:
ccsid - The CCSID to use for this AS/400.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

setDefaultUser

public static boolean setDefaultUser(java.lang.String systemName,
                                     java.lang.String userId)
Sets the default user for a given AS/400. The default user is the user ID that is used to connect if a user ID is not provided for that AS/400. There can be only one default user per AS/400. Once the default user is set, it cannot be overridden. To change the default user, the caller should remove the default user and then set it.
Parameters:
systemName - The name of the AS/400.
userId - The user ID.
Returns:
true if default user has been set; false otherwise.

setGuiAvailable

public void setGuiAvailable(boolean guiAvailable)
                     throws java.beans.PropertyVetoException
Sets the environment you are running in. If guiAvailable is set to true, then prompting may occur during sign-on to display error conditions, to prompt for additional information, or to prompt for change password. If guiAvailable is set to false, then these conditions will result in return codes and exceptions. Applications that are running as server applications or want to control the sign-on user interface may want to run with prompting mode set to false. The AS400 object is constructed with prompting mode set to true by default.
Parameters:
guiAvailable - true to prompt; otherwise false.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

setMustUseSockets

public void setMustUseSockets(boolean mustUseSockets)
When your Java program runs on a V4R3 or later AS/400, the Toolbox record-level database access, data queues, and user space classes access data via a call to an AS/400 API instead of making a socket call to a server. There are minor differences in the behavior of the classes when they use API calls instead of socket calls. If your program is affected by these differences you can force the Toolbox classes to use socket calls instead of API calls by using this method. The default is false. The must use sockets property cannot be changed once a connection to the AS/400 has been established.
Parameters:
mustUseSockets - true to use sockets; otherwise false.

setPassword

public void setPassword(java.lang.String password)
Sets the password for this AS400 object.
Parameters:
password - The password with which to connect to the AS/400.

setPasswordExpirationWarningDays

public static void setPasswordExpirationWarningDays(int days)
Sets the number of days before password expiration to warn the user.
Parameters:
days - The number of days before expiration to start the warning. Set to -1 to turn off warning.

setProxyServer

public void setProxyServer(java.lang.String proxyServer)
                    throws java.beans.PropertyVetoException
Sets the name and port of the middle-tier machine where the proxy server is running. If this is not set, then the name is retrieved from the com.ibm.as400.access.AS400.proxyServer system property. The ProxyServer must be running on the middle-tier machine.

The name of the middle-tier machine is ignored in a two-tier environment. If no middle-tier machine is specified, then it is assumed that no middle-tier will be accessed. The name of the middle-tier machine cannot be changed once a connection to this machine has been established.

Parameters:
proxyServer - The name and port in the format serverName[:port]. If no port is specified, a default will be used.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

setServicePort

public void setServicePort(int service,
                           int port)
Sets the service port in the service port table for the specified service for this system.
Parameters:
service - The name of the service.
port - The port to use for this service. The value USE_PORT_MAPPER can be used to specify that the next connection to this service should ask the port mapper server for the port number.

setServicePortsToDefault

public void setServicePortsToDefault()
Sets the ports in the service port table for all the services for this system to their default values.

setShowCheckboxes

public void setShowCheckboxes(boolean showCheckboxes)
Indicates if checkboxes should be shown on the signon dialog.
Parameters:
showCheckboxes - true to show checkboxes; otherwise false.

setSystemName

public void setSystemName(java.lang.String systemName)
                   throws java.beans.PropertyVetoException
Sets the system name for this AS400 object. The system name cannot be changed once a connection to the AS/400 has been established.
Parameters:
systemName - The system name with which to connect to the AS/400.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

setThreadUsed

public void setThreadUsed(boolean useThreads)
                   throws java.beans.PropertyVetoException
Sets whether the AS/400 Toolbox for Java uses threads in communication with the host servers. The default is true. Letting the AS/400 Toolbox for Java use threads may be beneficial to performance, turning threads off may be necessary if your application needs to be compliant with the Enterprise Java Beans specification. The thread used property cannot be changed once a connection to the AS/400 has been established.
Parameters:
useThreads - true to use threads; false otherwise.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

setUseDefaultUser

public void setUseDefaultUser(boolean useDefaultUser)
                       throws java.beans.PropertyVetoException
Sets the indicator for whether the default user is used. The default user is used if a system name is provided, but a user ID is not. If a default user is set for that system, then the default user is used.
Parameters:
useDefaultUser - The value indicating if the default user should be used. Set to true if default user should be used; false otherwise.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

setUsePasswordCache

public void setUsePasswordCache(boolean usePasswordCache)
                         throws java.beans.PropertyVetoException
Sets the indicator for whether the password cache is used. If password cache is used, then the user would only have to enter password once within a Java virtual machine. The default is to use the cache.
Parameters:
usePasswordCache - The value indicating whether the password cache should be used. Set to true to use the password cache; false otherwise.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

setUserId

public void setUserId(java.lang.String userId)
               throws java.beans.PropertyVetoException
Sets the user ID for this AS400 object. The user ID cannot be changed once a connection to the AS/400 has been established.
Parameters:
user - The user ID with which to connect to the AS/400.
Throws:
java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.

toString

public java.lang.String toString()
Returns the text representation of this AS400 object.
Overrides:
toString in class java.lang.Object
Returns:
The string representing this AS400 object.

validateSignon

public boolean validateSignon()
                       throws AS400SecurityException,
                              java.io.IOException
Validates the user ID and password for this AS/400 but does not add to the signed-on list. The system name, user ID, and password need to be set prior to calling this method.
Returns:
true if successful; false otherwise.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

validateSignon

public boolean validateSignon(java.lang.String password)
                       throws AS400SecurityException,
                              java.io.IOException
Validates the user ID and password for this AS/400 but does not add to the signed-on list.
Parameters:
password - Password to use for sign-on. The user ID and system name need to be set before calling this method.
Returns:
true if successful; false otherwise.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

validateSignon

public boolean validateSignon(java.lang.String userId,
                              java.lang.String password)
                       throws AS400SecurityException,
                              java.io.IOException
Validates the user ID and password for this AS/400 but does not add to the signed-on list. The system name needs to be set prior to calling this method.
Parameters:
userId - The user ID to validate.
password - The password to validate.
Returns:
true if successful; false otherwise.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

authenticate

public boolean authenticate(java.lang.String userId,
                            java.lang.String password)
                     throws AS400SecurityException,
                            java.io.IOException
Authenticates the user profile and password for this system.

This method is functionally equivalent to the validateSignon() method. It does not alter the user profile assigned to the system, impact the status of existing connections, or otherwise impact the user and authorities under which the application is running.

The system name needs to be set prior to calling this method.

Note: Providing an incorrect password increments the number of failed sign-on attempts for the user, and can result in the profile being disabled.

Parameters:
userId - The user profile name.
password - The user profile password.
Returns:
true if successful; false otherwise.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getProfileToken

public ProfileTokenCredential getProfileToken()
                                       throws AS400SecurityException,
                                              java.io.IOException,
                                              java.lang.InterruptedException
Deprecated. Use getProfileToken(int, int) instead.

Returns a profile token representing the signed on user profile.

The returned token will be created single-use with a one hour time to expiration. Subsequent method calls will return the same token, regardless of the token status.

This function is not supported if the assigned password is *CURRENT.

This function is only supported if the AS/400 system is at release V4R5M0 or greater.

Returns:
A com.ibm.as400.security.auth.ProfileTokenCredential representing the currently signed on user.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.lang.InterruptedException - If this thread is interrupted.
See Also:
getProfileToken(int, int)

getProfileToken

public ProfileTokenCredential getProfileToken(int tokenType,
                                              int timeoutInterval)
                                       throws AS400SecurityException,
                                              java.io.IOException,
                                              java.lang.InterruptedException
Authenticates the assigned user profile and password and returns a corresponding ProfileTokenCredential if successful.

This function is not supported if the assigned password is *CURRENT and cannot be used to generate a renewable token. This function is only supported if the AS/400 system is at release V4R5M0 or greater.

Parameters:
tokenType - The type of profile token to create. Possible types are defined as fields on the ProfileTokenCredential class:
  • TYPE_SINGLE_USE
  • TYPE_MULTIPLE_USE_NON_RENEWABLE
timeoutInterval - The number of seconds to expiration when the token is created (1-3600).
Returns:
A com.ibm.as400.security.auth.ProfileTokenCredential representing the signed on user; null if the user identity and password have not been assigned (either programatically or as the result of prompting during the sign-on process).
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.lang.InterruptedException - If this thread is interrupted.

getProfileToken

public ProfileTokenCredential getProfileToken(java.lang.String userId,
                                              java.lang.String password)
                                       throws AS400SecurityException,
                                              java.io.IOException,
                                              java.lang.InterruptedException
Authenticates the given user profile and password and returns a corresponding ProfileTokenCredential if successful.

Invoking this method does not change the user ID and password assigned to the system or otherwise modify the user or authorities under which the application is running.

This method generates a single use token with a timeout of one hour.

This function is only supported if the AS/400 system is at release V4R5M0 or greater.

Note: Providing an incorrect password increments the number of failed sign-on attempts for the user, and can result in the profile being disabled. Refer to documentation on the ProfileTokenCredential class for additional restrictions.

Parameters:
userId - The user profile name.
password - The user profile password. The following special values are allowed:
  • *NOPWD - The password is not verified. This value is not allowed if the name of the currently running profile is specified for the userId parameter. If specified, the user requesting the profile token must have *USE authority to the user profile.
  • *NOPWDCHK - The password is not verified. This value allows a profile token to be generated for a profile that is disabled or has an expired password. If disabled or expired, the user requesting the profile token must have *ALLOBJ and *SECADM special authority.
Returns:
A com.ibm.as400.security.auth.ProfileTokenCredential representing the authenticated profile and password.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.lang.InterruptedException - If this thread is interrupted.
ExtendedIllegalArgumentException - If errors occur during parameter validation.

getProfileToken

public ProfileTokenCredential getProfileToken(java.lang.String userId,
                                              java.lang.String password,
                                              int tokenType,
                                              int timeoutInterval)
                                       throws AS400SecurityException,
                                              java.io.IOException,
                                              java.lang.InterruptedException
Authenticates the given user profile and password and returns a corresponding ProfileTokenCredential if successful.

Invoking this method does not change the user ID and password assigned to the system or otherwise modify the user or authorities under which the application is running.

This function is only supported if the AS/400 system is at release V4R5M0 or greater.

Note: Providing an incorrect password increments the number of failed sign-on attempts for the user, and can result in the profile being disabled. Refer to documentation on the ProfileTokenCredential class for additional restrictions.

Parameters:
userId - The user profile name.
password - The user profile password. The following special values are allowed:
  • *NOPWD - The password is not verified. This value is not allowed if the name of the currently running profile is specified for the userId parameter. If specified, the user requesting the profile token must have *USE authority to the user profile.
  • *NOPWDCHK - The password is not verified. This value allows a profile token to be generated for a profile that is disabled or has an expired password. If disabled or expired, the user requesting the profile token must have *ALLOBJ and *SECADM special authority.
tokenType - The type of profile token to create. Possible types are defined as fields on the ProfileTokenCredential class:
  • TYPE_SINGLE_USE
  • TYPE_MULTIPLE_USE_NON_RENEWABLE
  • TYPE_MULTIPLE_USE_RENEWABLE
timeoutInterval - The number of seconds to expiration when the token is created (1-3600).
Returns:
A com.ibm.as400.security.auth.ProfileTokenCredential representing the authenticated profile and password.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.lang.InterruptedException - If this thread is interrupted.
ExtendedIllegalArgumentException - If errors occur during parameter validation.