public interface SignonHandler
setSignonHandler()
.
The AS400 class invokes the SignonHandler at runtime, if additional information (such as userID or password) must be obtained while attempting to connect to the system.
By default, the Toolbox uses an internal AWT-based implementation of SignonHandler.
For all methods that return a boolean, a returned value of true indicates that the sign-on should proceed; false indicates that the sign-on should not proceed, in which case the system object will throw an AS400SecurityException
with an error code indicating what information is missing or incorrect. In the case of connectionInitiated()
and passwordAboutToExpire()
, the return code will be SIGNON_CANCELED
.
Suggestions for implementers:
Extend SignonHandlerAdapter
rather than implementing this interface directly. That will insulate your implementation from future additions to the interface.
In order to avoid hang conditions, the SignonHandler should not attempt to display a GUI if isGuiAvailable()
indicates false.
In order to avoid infinite loops, a SignonHandler must not call the following AS400 methods:
Here is a minimal implementation that just prints a message when connectionInitiated() is called.:
import com.ibm.as400.access.SignonHandlerAdapter; import com.ibm.as400.access.SignonEvent; public class SimpleSignonHandler extends SignonHandlerAdapter { public boolean connectionInitiated(SignonEvent event) throws SignonHandlerException { System.out.println("SimpleSignonHandler.connectionInitiated()"); return true; // indicate that the sign-on should proceed } }
Here is a somewhat more realistic sample implementation:
import com.ibm.as400.access.*; import java.io.File; public class MySignonHandler extends SignonHandlerAdapter { public boolean connectionInitiated(SignonEvent event) { AS400 system = (AS400)event.getSource(); if (system.isGuiAvailable()) { // Display an interactive dialog to prompt user for userid and password. ... system.setUserId(userId); system.setPassword(password); } else // no GUI available { File myPasswordFile = new File(...); // file containing sign-on information if (myPasswordFile.exists()) { // Read systemName, userId, and password from file, and update the system object. ... system.setUserId(userId); system.setPassword(password); } else { // Just return 'true'. Let the system object proceed with the connection. // If anything necessary is missing, the Toolbox will call handleEvent(). } } return true; // indicate that the sign-on should proceed } }
Modifier and Type | Method and Description |
---|---|
boolean |
connectionInitiated(SignonEvent event,
boolean forceUpdate)
Informs the SignonHandler that a connection operation has been initiated.
|
void |
exceptionOccurred(SignonEvent event)
Handles an exception that was thrown during a sign-on attempt.
|
boolean |
passwordAboutToExpire(SignonEvent event,
int daysUntilExpiration)
Handles the situation where the password is within a few days of expiring.
|
boolean |
passwordExpired(SignonEvent event)
Handles the situation where the password has expired.
|
boolean |
passwordIncorrect(SignonEvent event)
Handles the situation where an incorrect password has been specified.
|
boolean |
passwordLengthIncorrect(SignonEvent event)
Handles the situation where a specified password is either too long or too short.
|
boolean |
passwordMissing(SignonEvent event)
Handles the situation where a password has not been specified.
|
boolean |
systemNameMissing(SignonEvent event)
Handles the situation where the system name has not been specified.
|
boolean |
systemNameUnknown(SignonEvent event,
java.net.UnknownHostException exc)
Handles the situation where the specified system name is unknown to the network.
|
boolean |
userIdAboutToBeDisabled(SignonEvent event)
Handles the situation where the specified user profile will be disabled after next incorrect sign-on attempt.
|
boolean |
userIdDefaultAlreadyAssigned(SignonEvent event,
java.lang.String defaultUser)
Handles the situation where a default userID has already been assigned for the system object.
|
boolean |
userIdDisabled(SignonEvent event)
Handles the situation where the specified user profile has been disabled.
|
boolean |
userIdLengthIncorrect(SignonEvent event)
Handles the situation where a specified userID is either too long or too short.
|
boolean |
userIdMissing(SignonEvent event)
Handles the situation where a userID has not been specified.
|
boolean |
userIdUnknown(SignonEvent event)
Handles the situation where a specified userID is unknown to the system.
|
boolean connectionInitiated(SignonEvent event, boolean forceUpdate)
In order to avoid infinite loops, a SignonHandler must not call the following AS400 methods:
event
- The sign-on event.forceUpdate
- true indicates that the sign-on information is known to be incomplete or incorrect. false indicates that the information may be correct.EventObject.getSource()
void exceptionOccurred(SignonEvent event) throws AS400SecurityException
event
- The sign-on event. getException()
is guaranteed to return non-null.AS400SecurityException
- If the handler cannot handle the exception.AS400SecurityException.getReturnCode()
boolean passwordAboutToExpire(SignonEvent event, int daysUntilExpiration)
changePassword
.
Another reasonable implementation is to just return true, indicating
that the password is not to be changed at this time, and the sign-on should proceed.event
- The sign-on event.daysUntilExpiration
- The number of days until the password expires.AS400.changePassword(java.lang.String, java.lang.String)
boolean passwordExpired(SignonEvent event)
changePassword
.event
- The sign-on event.AS400.changePassword(java.lang.String, java.lang.String)
boolean passwordIncorrect(SignonEvent event)
event
- The sign-on event.AS400.setPassword(java.lang.String)
boolean passwordLengthIncorrect(SignonEvent event)
event
- The sign-on event.AS400.setPassword(java.lang.String)
boolean passwordMissing(SignonEvent event)
event
- The sign-on event.AS400.setPassword(java.lang.String)
boolean systemNameMissing(SignonEvent event)
event
- The sign-on event.AS400.setSystemName(java.lang.String)
boolean systemNameUnknown(SignonEvent event, java.net.UnknownHostException exc)
event
- The sign-on event.exc
- The exception.AS400.setSystemName(java.lang.String)
boolean userIdDefaultAlreadyAssigned(SignonEvent event, java.lang.String defaultUser)
event
- The sign-on event.defaultUser
- The current default user.AS400.isUseDefaultUser()
,
AS400.setUseDefaultUser(boolean)
,
AS400.setDefaultUser(java.lang.String, java.lang.String)
,
AS400.removeDefaultUser(java.lang.String)
boolean userIdAboutToBeDisabled(SignonEvent event)
event
- The sign-on event.AS400.setUserId(java.lang.String)
,
AS400.setPassword(java.lang.String)
boolean userIdDisabled(SignonEvent event)
event
- The sign-on event.AS400.setUserId(java.lang.String)
boolean userIdLengthIncorrect(SignonEvent event)
event
- The sign-on event.AS400.setUserId(java.lang.String)
boolean userIdMissing(SignonEvent event)
event
- The sign-on event.AS400.setUserId(java.lang.String)
boolean userIdUnknown(SignonEvent event)
event
- The sign-on event.AS400.setUserId(java.lang.String)