Example Plug-In: SamplePlugin.java

This example shows how to use a plug-in to retrieve data from a file, from an LDAP source, and from the user. This data can then be stored in the GC applet.

The sampleplugin defines three parameters, which are described in the following procedure and Example: Using a Plug-In for Retrieving Data:

  • SampleConfigFile

  • employee_name

  • employee_mail

The SampleConfigFile parameter type is String. It is not visible to, nor is it modifiable by, the ActivID CMS operator. This parameter type specifies the name of the file that the plug-in opens and from which reads data.

The employee_name parameter is initialized with the CN LDAP attribute of the user by the ActivID CMS Portal. This parameter is visible to the user, but is not modifiable by the user of the ActivID CMS Portal.

The employee_mail parameter is both visible to and modifiable by the user of the ActivID CMS Portal. This parameter is mandatory; the user must enter a value before issuance can be completed.

Example: Using a Plug-In for Retrieving Data

Copy
package com.activcard.aims.plugin.staticdata;
 
 
import java.util.*;
import java.io.*;
 
 
public class SamplePlugin implements StaticDataCollectionPlugIn {
private String m_confFile = null;
private String[] values = null;
 
 
void CreateBSITags( ByteArrayOutputStream tagStream, ByteArrayOutputStream valStream,
byte tag,byte[] val) throws Exception {
tagStream.write(tag); tagStream.write(val.length); valStream.write(val, 0, val.length);
}
 
 
public void init(Map aParametersMap) throws Exception { Object[] paramValues = null;
paramValues = (Object[])aParametersMap.get("sampleConfigFile");
m_confFile = (String)paramValues[0];
values = new String[2];
paramValues = (Object[])aParametersMap.get("employee_name");
values[0] = (String) paramValues[0];
paramValues = (Object[])aParametersMap.get("employee_mail");
values[1] = (String) paramValues[0];
}
 
public void setParameters(Map aParametersMap) throws Exception {}
 
public Map computeCredentialParameters(String aUserDN, String aDeviceType, String aDeviceCUID) throws Exception {
Properties properties = new Properties();
try {
FileInputStream stream = new FileInputStream(m_confFile);
try {
properties.load(stream);
}
finally {
stream.close();
}
}
catch(FileNotFoundException e) {
throw new Exception("Properties file not found : "+    m_confFile);
}
catch (IOException x) {
throw new Exception( "Error loading properties file : " + m_confFile);
}
String someData = properties.getProperty("somedata"); Map theCredentialParams = new HashMap();
 
ByteArrayOutputStream tagStream = new ByteArrayOutputStream(); ByteArrayOutputStream valStream = new ByteArrayOutputStream();
 
CreateBSITags(tagStream, valStream,(byte)1,values[0].getBytes("UTF-8")); CreateBSITags(tagStream, valStream,(byte)2,values[1].getBytes("UTF-8")); CreateBSITags(tagStream, valStream,(byte)3,someData.getBytes("UTF-8"));
 
 
theCredentialParams.put("persoGC/BufferValue/BufferT", tagStream.toByteArray());
theCredentialParams.put("persoGC/BufferValue/BufferV", valStream.toByteArray());
tagStream.close();
valStream.close();
 
return theCredentialParams;
}
 
public String getPluginVersion() {
return "1.0";
}
public String getPluginProvider() {
return "HIDGlobal";
}
public void setStatus(String status) throws Exception {}