InfoCenter Home >
5: Securing applications -- special topics >
5.4: Overview: Using programmatic and custom logins >
5.4.1: Client-side login >
5.4.1.1: The TestClient program

5.4.1.1: The TestClient program

The TestClient program illustrates the use of the LoginHelper class, a utility class provided to help simplify programming client-side login. The excerpt below shows the performLogin method.

TestClient class

public class TestClient
{
...
private void performLogin()
{
// Get the user's ID and password.
String userid = customGetUserid();
String password = customGetPassword();
// Create a new security context to hold
// authentication data.
LoginHelper loginHelper = new LoginHelper();
try {
// Provide the user's ID and password for authentication.
org.omg.SecurityLevel2.Credentials credentials =
loginHelper.login(userid, password);
// Use the new credentials for all future invocations.
loginHelper.setInvocationCredentials(credentials);
// Retrieve the user's name from the credentials
// so we can tell the user that login succeeded.
String username = loginHelper.getUserName(credentials);
System.out.println("Security context set for user: "+username);
}
catch (org.omg.SecurityLevel2.LoginFailed e)
{
// Handle the LoginFailed exception.
}
}
...
}
Go to previous article: Client-side login Go to next article: LoginHelper

 

 
Go to previous article: Client-side login Go to next article: LoginHelper