InfoCenter Home >
5: Securing applications -- special topics >
5.2: Introduction to custom registries >
5.2.2: Implementing the CustomRegistry interface >
5.2.2.2: Writing the sample application >
5.2.2.2.1: Structure of the implementation class

5.2.2.2.1: Structure of the implementation class

The class implementing the CustomRegistry interface is called FileRegistrySample. It primarily contains implementations of the methods in the CustomRegistry interface, but it also contains private variables representing the user- and group-information files making up the registry, private file-manipulation methods for accessing the registry files, and an empty constructor. Figure 5 shows the structure and content of the class, excluding the methods in the CustomRegistry interface, which are described separately.

Figure 5. Code example: The structure of the FileRegistrySample class

import java.util.*;
import java.io.*;
import java.security.cert.X509Certificate;
import com.ibm.websphere.security.*;

public class FileRegistrySample implements CustomRegistry
{
private static String USERFILENAME = null;
private static String GROUPFILENAME = null;

private BufferedReader fileOpen(String fileName)
throws FileNotFoundException
{
try {
return new BufferedReader(new FileReader(fileName));
}
catch(FileNotFoundException e) {
throw e;
}
}

private void fileClose(BufferedReader in)
{
try {
if (in != null) in.close();
}
catch(Exception e) {
System.out.println("Error closing file" + e);
}
}

private boolean match(String name, String pattern)
{
// RegExpSample is an auxiliary class for regular expressions
RegExpSample regexp = new RegExpSample(pattern);
boolean matches = false;
if(regexp.match(name))
matches = true;
return matches;
}
public FileRegistrySample() {}

// Methods from the CustomRegistry interface
...
}

This sample implementation also includes an auxiliary class, RegExpSample, that implements basic regular-expression handling.

Go to previous article: Implementing the CustomRegistry interface Go to next article: getRealm and initialize methods

 

 
Go to previous article: Implementing the CustomRegistry interface Go to next article: getRealm and initialize methods