InfoCenter Home >
5: Securing applications -- special topics >
5.4: Overview: Using programmatic and form logins >
5.4.2: Server-side login >
5.4.2.1: The TestServer program

5.4.2.1: The TestServer program

The TestServer program illustrates the use of the ServerSideAuthenticator class, a utility class provided to help simplify programming server-side login. The excerpt below shows the performLoginAndAuthentication method.

TestServer class

public class TestServer
{
...
private void performLoginAndAuthentication()
{
// Get the user's ID and password.
String userid = customGetUserid();
String password = customGetPassword();
// Ensure immediate authentication.
boolean forceAuthentication = true;
// Create a new security context to hold
// authentication data.
ServerSideAuthenticator serverAuth = new ServerSideAuthenticator();
try
{
// Perform authentication based on supplied data.
org.omg.SecurityLevel2.Credentials credentials =
serverAuth.login(userid, password, forceAuthentication);
// Retrieve the user's name from the credentials
// so we can tell the user that login succeeded.
String username = serverAuth.getUserName(credentials);
System.out.println("Authentication successful for user: "+username);
}
catch (Exception e)
{
// Handle exceptions.
}
}
...
}
Go to previous article: Server-side login Go to next article: ServerSideAuthenticator

 

 
Go to previous article: Server-side login Go to next article: ServerSideAuthenticator