i-Planet Administration Guide

Examples

There are two examples of .properties and Java code files.

Sample .properties File 1

Missing Cross Reference Target is a sample .properties file.


SCREEN

TEXT This is a sample login page

TOKEN First Name

TOKEN Last Name
TOKEN Favorite Car

PASSWORD Favorite Car's password



SCREEN
TIMEOUT 200

TEXT   The all password page

PASSWORD password 1

PASSWORD password 2

PASSWORD password 3

PASSWORD password 4



SCREEN

TEXT 3rd page

TOKEN Enter anything

TOKEN This will be your userID

Sample Java Module 1

Missing Cross Reference Target is the sample code for MySampleLogin.java.


package com.sun.login.sample;

import java.util.*;
import com.sun.authd.*;

public class MySampleLogin extends Login {

    private String userTokenId;

    public MySampleLogin() throws LoginException{
        System.out.println("MySampleLogin()");
    }

    public void init() throws LoginException {
        System.out.println("MySampleLogin initialization");
    }

    public void validate() throws LoginException {
        System.out.println("SampleLoginModule validate()");
			// get the current login page

			int login_page = getCurrentState();

			// print out all the tokens and passwords the user entered

			String[]tokens = getAllTokens();
			for (int i = 0; i < tokens.length; i++) {
            System.out.println(i + "->" + " " + tokens[i]);
			}

			if (login_page == 2) {
	   			 userTokenId = new String(getToken(1));
			}
            
	}
	public String getUserTokenId() {
        return new String(userTokenId);
	}
	public String getDescription() {
			return "My Sample Login Module";
	}
}

Sample .properties File 2

You can also find the following sample file SampleLoginModule.properties in /opt/SUNWstnr/sample/auth/com/sun/login/sample, where /opt is the directory in which it is installed by default. Missing Cross Reference Target shows a sample .properties file.


SCREEN

TEXT This is a sample login page

TOKEN First Name

TOKEN Last Name
SCREEN

TIMEOUT 30



TEXT   You made it to page 2

PASSWORD Enter any password
SCREEN



TIMEOUT 60

TEXT You made it past the first page

TOKEN Enter <REPLACE>'s favorite car

PASSWORD Enter <REPLACE>'s favorite color



SCREEN

TEXT 4th page

PASSWORD who cares

TOKEN anything here

Sample Java Module 2

You can also find the following sample in a file named SampleLoginModule.java in /opt/SUNWstnr/sample/auth/com/sun/login/sample, where /opt is the directory in which it is installed by default.Missing Cross Reference Target shows a sample Java module


package com.sun.login.sample;

import java.util.*;
import com.sun.authd.*;

public class SampleLoginModule extends Login {

	private String userTokenId;
	private String firstName;
	private String lastName;

	public SampleLoginModule() throws LoginException{
			System.out.println("SampleLoginModule()");
	}

	public void init() throws LoginException {
			System.out.println("SampleLoginModule initialization");
	} 

	public void validate() throws LoginException {

			int currentState = getCurrentState();
			if (currentState == 1) {
				firstName = getToken(1);
				lastName = getToken(2);
				if (firstName.equals("") || lastName.equals("")) {
						throw new LoginException("Sample failed names must not be\

empty");
			}
			return;
	}
	else if (currentState == 2) {
			String pass = getToken(1);
			System.out.println("Replace Text first: " + firstName + " last: "\

+ lastName);
			setReplaceText(1, firstName);
			setReplaceText(2, lastName);
			return;
			}
.


	else if (currentState == 3) {
			String[] tokens = getAllTokens();
			for (int i=0; i<getNumberOfTokens(); i++) {
				System.out.println("Token-> " + tokens[i]);	    }
			return;
	}
	else if (currentState == 4) {
			String[] tokens = getAllTokensForState(1);
			for (int i=0; i<getNumberOfTokensForState(1); i++) {
				System.out.println("Token-> " + tokens[i]);
			}
	}

			userTokenId = firstName;
	 }

	public String getUserTokenId() {
			return userTokenId;
    }

}