summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/certsrv/base
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/certsrv/base')
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ASubsystem.java71
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/AttributeNameHelper.java70
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/BaseResources.java47
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/EBaseException.java150
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/EPropertyNotDefined.java41
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/EPropertyNotFound.java41
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ExtendedPluginInfo.java91
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IArgBlock.java285
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java72
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IAuthInfo.java36
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ICRLPrettyPrint.java50
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ICertPrettyPrint.java40
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IConfigStore.java276
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IConfigStoreEventListener.java50
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IExtPrettyPrint.java44
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IExtendedPluginInfo.java84
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IPluginImpl.java107
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/IPrettyPrintFormat.java72
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java40
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ISourceConfigStore.java82
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ISubsystem.java82
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ISubsystemSource.java40
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/ITimeSource.java43
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/KeyGenInfo.java225
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/MessageFormatter.java155
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java198
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/MetaInfo.java116
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/Nonces.java128
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/PasswordResources.java45
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/Plugin.java65
-rw-r--r--pki/base/common/src/com/netscape/certsrv/base/SessionContext.java163
31 files changed, 3009 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ASubsystem.java b/pki/base/common/src/com/netscape/certsrv/base/ASubsystem.java
new file mode 100644
index 000000000..ea3342308
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ASubsystem.java
@@ -0,0 +1,71 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+/**
+ * This class represents a basic subsystem. Each basic
+ * subsystem is named with an identifier and has a
+ * configuration store.
+ *
+ * @version $Revision$, $Date$
+ */
+public abstract class ASubsystem implements ISubsystem {
+
+ private ISubsystem mParent;
+ private IConfigStore mCfg;
+ private String mId;
+
+ /**
+ * Initializes this subsystem.
+ *
+ * @param parent parent subsystem
+ * @param cfg configuration store
+ */
+ public void init(ISubsystem parent, IConfigStore cfg) {
+ mParent = parent;
+ mCfg = cfg;
+ }
+
+ /**
+ * Retrieves the configuration store.
+ *
+ * @return configuration store
+ */
+ public IConfigStore getConfigStore() {
+ return mCfg;
+ }
+
+ /**
+ * Sets the identifier of this subsystem.
+ *
+ * @param id subsystem identifier
+ */
+ public void setId(String id) {
+ mId = id;
+ }
+
+ /**
+ * Retrieves the subsystem identifier.
+ *
+ * @return subsystem identifier
+ */
+ public String getId() {
+ return mId;
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/AttributeNameHelper.java b/pki/base/common/src/com/netscape/certsrv/base/AttributeNameHelper.java
new file mode 100644
index 000000000..786148a0e
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/AttributeNameHelper.java
@@ -0,0 +1,70 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+/**
+ * AttributeNameHelper. This Helper class used to decompose
+ * dot-separated attribute name into prefix and suffix.
+ *
+ * @version $Revision$, $Date$
+ */
+public class AttributeNameHelper {
+ // Public members
+ private static final char SEPARATOR = '.';
+
+ // Private data members
+ private String prefix = null;
+ private String suffix = null;
+
+ /**
+ * Default constructor for the class. Name is of the form
+ * "proofOfPosession.type".
+ *
+ * @param name the attribute name.
+ */
+ public AttributeNameHelper(String name) {
+ int i = name.indexOf(SEPARATOR);
+
+ if (i == (-1)) {
+ prefix = name;
+ } else {
+ prefix = name.substring(0, i);
+ suffix = name.substring(i + 1);
+ }
+ }
+
+ /**
+ * Return the prefix of the name.
+ *
+ * @return attribute prefix
+ */
+ public String getPrefix() {
+ return (prefix);
+ }
+
+ /**
+ * Return the suffix of the name.
+ *
+ * @return attribute suffix
+ */
+ public String getSuffix() {
+ return (suffix);
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/base/BaseResources.java b/pki/base/common/src/com/netscape/certsrv/base/BaseResources.java
new file mode 100644
index 000000000..f8a69f65d
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/BaseResources.java
@@ -0,0 +1,47 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * A class represents a resource bundle for the entire
+ * system.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ * @see java.util.ListResourceBundle
+ */
+public class BaseResources extends ListResourceBundle {
+
+ /**
+ * Returns the content of this resource.
+ */
+ public Object[][] getContents() {
+ return contents;
+ }
+
+ /*
+ * Constants. The suffix represents the number of
+ * possible parameters.
+ */
+
+ static final Object[][] contents = {};
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/EBaseException.java b/pki/base/common/src/com/netscape/certsrv/base/EBaseException.java
new file mode 100644
index 000000000..50ea8fdc7
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/EBaseException.java
@@ -0,0 +1,150 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import java.lang.reflect.*;
+
+
+/**
+ * An exception with localizable error messages. It is the
+ * base class for all exceptions in certificate server.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ * @see java.text.MessageFormat
+ * @see com.netscape.certsrv.base.BaseResources
+ */
+public class EBaseException extends Exception {
+
+ /**
+ * The resource bundle to use for error messages.
+ * Subclasses can override to use its own resource bundle.
+ */
+ private static final String BASE_RESOURCES = BaseResources.class.getName();
+
+ /**
+ * Parameters to the exception error message.
+ */
+ public Object mParams[] = null;
+
+ /**
+ * Constructs an instance of this exception with the given resource key.
+ * If resource key is not found in the resource bundle, the resource key
+ * specified is used as the error message.
+ * <pre>
+ * new EBaseException(BaseResources.PERMISSION_DENIED);
+ * new EBaseException("An plain error message");
+ * <P>
+ * @param msgFormat The error message resource key.
+ */
+ public EBaseException(String msgFormat) {
+ super(msgFormat);
+ mParams = null;
+ }
+
+ /**
+ * Constructs an instance of this exception with the given resource key
+ * and a parameter as a string.
+ * <PRE>
+ * new EBaseException(BaseResource.NO_CONFIG_FILE, fileName);
+ * </PRE>
+ * <P>
+ * @param msgFormat exception details in message string format
+ * @param param message string parameter
+ */
+ public EBaseException(String msgFormat, String param) {
+ super(msgFormat);
+ mParams = new String[1];
+ mParams[0] = param;
+ }
+
+ /**
+ * Constructs an instance of the exception given the resource key and
+ * a exception parameter.
+ * <PRE>
+ * try {
+ * ...
+ * } catch (IOExeption e) {
+ * throw new EBaseException(BaseResources.INTERNAL_ERROR_1, e);
+ * }
+ * </PRE>
+ * <P>
+ * @param msgFormat The resource key
+ * @param param The parameter as an exception
+ */
+ public EBaseException(String msgFormat, Exception param) {
+ super(msgFormat);
+ mParams = new Exception[1];
+ mParams[0] = param;
+ }
+
+ /**
+ * Constructs an instance of this exception given the resource key and
+ * an array of parameters.
+ * <P>
+ * @param msgFormat The resource key
+ * @param params Array of params
+ */
+ public EBaseException(String msgFormat, Object params[]) {
+ super(msgFormat);
+ mParams = params;
+ }
+
+ /**
+ * Returns the list of parameters.
+ * <P>
+ *
+ * @return List of parameters.
+ */
+ public Object[] getParameters() {
+ return mParams;
+ }
+
+ /**
+ * Returns the exception string in the default locale.
+ * <P>
+ * @return The exception string in the default locale.
+ */
+ public String toString() {
+ return toString(Locale.getDefault());
+ }
+
+ /**
+ * Returns the exception string in the given locale.
+ * <P>
+ * @param locale The locale
+ * @return The exception string in the given locale.
+ */
+ public String toString(Locale locale) {
+ return MessageFormatter.getLocalizedString(locale, getBundleName(),
+ super.getMessage(), mParams);
+ }
+
+ /**
+ * Returns the given resource bundle name.
+ * @return the name of the resource bundle for this class.
+ */
+ protected String getBundleName() {
+ return BASE_RESOURCES;
+ }
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/EPropertyNotDefined.java b/pki/base/common/src/com/netscape/certsrv/base/EPropertyNotDefined.java
new file mode 100644
index 000000000..57385d700
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/EPropertyNotDefined.java
@@ -0,0 +1,41 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+/**
+ * This class represents an exception thrown when a
+ * property is not defined (empty string) the configuration store.
+ * It extends EBaseException and uses the same resource bundle.
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ * @see com.netscape.certsrv.base.EBaseException
+ */
+public class EPropertyNotDefined extends EBaseException {
+
+ /**
+ * Constructs an instance of this exception given the name of the
+ * property that's not found.
+ * <p>
+ * @param errorString Detailed error message.
+ */
+ public EPropertyNotDefined(String errorString) {
+ super(errorString);
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/EPropertyNotFound.java b/pki/base/common/src/com/netscape/certsrv/base/EPropertyNotFound.java
new file mode 100644
index 000000000..a0f4ed93b
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/EPropertyNotFound.java
@@ -0,0 +1,41 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+/**
+ * This class represents an exception thrown when a
+ * property is not found in the configuration store.
+ * It extends EBaseException and uses the same resource bundle.
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ * @see com.netscape.certsrv.base.EBaseException
+ */
+public class EPropertyNotFound extends EBaseException {
+
+ /**
+ * Constructs an instance of this exception given the name of the
+ * property that's not found.
+ * <p>
+ * @param errorString Detailed error message.
+ */
+ public EPropertyNotFound(String errorString) {
+ super(errorString);
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ExtendedPluginInfo.java b/pki/base/common/src/com/netscape/certsrv/base/ExtendedPluginInfo.java
new file mode 100644
index 000000000..b74131a68
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ExtendedPluginInfo.java
@@ -0,0 +1,91 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+import java.lang.*;
+
+
+/**
+ * Plugin which can return extended information to console
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ */
+public class ExtendedPluginInfo implements IExtendedPluginInfo {
+
+ private String _epi[] = null;
+
+ /**
+ * Constructs an extended plugin info object.
+ *
+ * @param epi plugin info list
+ */
+ public ExtendedPluginInfo(String epi[]) {
+ _epi = epi;
+ }
+
+ /**
+ * This method returns an array of strings. Each element of the
+ * array represents a configurable parameter, or some other
+ * meta-info (such as help-token)
+ *
+ * there is an entry indexed on that parameter name
+ * <param-name>;<type_info>[,required];<description>;...
+ *
+ * Where:
+ *
+ * type_info is either 'string', 'number', 'boolean', 'password' or
+ * 'choice(ch1,ch2,ch3,...)'
+ *
+ * If the marker 'required' is included after the type_info,
+ * the parameter will has some visually distinctive marking in
+ * the UI.
+ *
+ * 'description' is a short sentence describing the parameter
+ * 'choice' is rendered as a drop-down list. The first parameter in the
+ * list will be activated by default
+ * 'boolean' is rendered as a checkbox. The resulting parameter will be
+ * either 'true' or 'false'
+ * 'string' allows any characters
+ * 'number' allows only numbers
+ * 'password' is rendered as a password field (the characters are replaced
+ * with *'s when being types. This parameter is not passed through to
+ * the plugin. It is instead inserted directly into the password cache
+ * keyed on the instance name. The value of the parameter
+ * 'bindPWPrompt' (see example below) is set to the key.
+ *
+ * In addition to the configurable parameters, the following magic parameters
+ * may be defined:
+ *
+ * HELP_TOKEN;helptoken - a pointer to the online manual section for this plugin
+ * HELP_TEXT;helptext - a general help string describing the plugin
+ *
+ * For example:
+ * "username;string;The username you wish to login as"
+ * "bindPWPrompt;password;Enter password to bind as above user with"
+ * "algorithm;choice(RSA,DSA);Which algorithm do you want to use"
+ * "enable;boolean;Do you want to run this plugin"
+ * "port;number;Which port number do you want to use"
+ *
+ */
+ public String[] getExtendedPluginInfo(Locale locale) {
+ return _epi;
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IArgBlock.java b/pki/base/common/src/com/netscape/certsrv/base/IArgBlock.java
new file mode 100644
index 000000000..835ad0ed1
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IArgBlock.java
@@ -0,0 +1,285 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+import java.util.*;
+import java.io.*;
+import netscape.security.pkcs.*;
+import java.security.*;
+import java.math.BigInteger;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.base.BaseResources;
+
+
+/**
+ * This interface defines the abstraction for the generic collection
+ * of attributes indexed by string names.
+ * Set of cooperating implementations of this interface may exploit
+ * dot-separated attribute names to provide seamless access to the
+ * attributes of attribute value which also implements AttrSet
+ * interface as if it was direct attribute of the container
+ * E.g., ((AttrSet)container.get("x")).get("y") is equivalent to
+ * container.get("x.y");
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ **/
+public interface IArgBlock extends Serializable {
+
+ /**
+ * Checks if this argument block contains the given key.
+ *
+ * @param n key
+ * @return true if key is present
+ */
+ public boolean isValuePresent(String n);
+ /**
+ * Adds string-based value into this argument block.
+ *
+ * @param n key
+ * @param v value
+ * @return value
+ */
+ public Object addStringValue(String n, String v);
+
+ /**
+ * Retrieves argument value as string.
+ *
+ * @param n key
+ * @return argument value as string
+ * @exception EBaseException failed to retrieve value
+ */
+ public String getValueAsString(String n) throws EBaseException;
+
+ /**
+ * Retrieves argument value as string.
+ *
+ * @param n key
+ * @param def default value to be returned if key is not present
+ * @return argument value as string
+ */
+ public String getValueAsString(String n, String def);
+
+ /**
+ * Retrieves argument value as integer.
+ *
+ * @param n key
+ * @return argument value as int
+ * @exception EBaseException failed to retrieve value
+ */
+ public int getValueAsInt(String n) throws EBaseException;
+
+ /**
+ * Retrieves argument value as integer.
+ *
+ * @param n key
+ * @param def default value to be returned if key is not present
+ * @return argument value as int
+ */
+ public int getValueAsInt(String n, int def);
+
+ /**
+ * Retrieves argument value as big integer.
+ *
+ * @param n key
+ * @return argument value as big integer
+ * @exception EBaseException failed to retrieve value
+ */
+ public BigInteger getValueAsBigInteger(String n) throws EBaseException;
+
+ /**
+ * Retrieves argument value as big integer.
+ *
+ * @param n key
+ * @param def default value to be returned if key is not present
+ * @return argument value as big integer
+ */
+ public BigInteger getValueAsBigInteger(String n, BigInteger def);
+
+ /**
+ * Retrieves argument value as object
+ *
+ * @param n key
+ * @return argument value as object
+ * @exception EBaseException failed to retrieve value
+ */
+ public Object getValue(Object n) throws EBaseException;
+
+ /**
+ * Retrieves argument value as object
+ *
+ * @param n key
+ * @param def default value to be returned if key is not present
+ * @return argument value as object
+ */
+ public Object getValue(Object n, Object def);
+
+ /**
+ * Gets boolean value. They should be "true" or "false".
+ *
+ * @param name name of the input type
+ * @return boolean type: <code>true</code> or <code>false</code>
+ * @exception EBaseException failed to retrieve value
+ */
+ public boolean getValueAsBoolean(String name) throws EBaseException;
+
+ /**
+ * Gets boolean value. They should be "true" or "false".
+ *
+ * @param name name of the input type
+ * @param def Default value to return.
+ * @return boolean type: <code>true</code> or <code>false</code>
+ */
+ public boolean getValueAsBoolean(String name, boolean def);
+
+ /**
+ * Gets KeyGenInfo
+ *
+ * @param name name of the input type
+ * @param def default value to return
+ * @exception EBaseException On error.
+ * @return KeyGenInfo object
+ */
+ public KeyGenInfo getValueAsKeyGenInfo(String name, KeyGenInfo def) throws EBaseException;
+
+ /**
+ * Gets PKCS10 request. This pkcs10 attribute does not
+ * contain header information.
+ *
+ * @param name name of the input type
+ * @return pkcs10 request
+ * @exception EBaseException failed to retrieve value
+ */
+ public PKCS10 getValueAsRawPKCS10(String name) throws EBaseException;
+
+ /**
+ * Gets PKCS10 request. This pkcs10 attribute does not
+ * contain header information.
+ *
+ * @param name name of the input type
+ * @param def default PKCS10
+ * @return pkcs10 request
+ * @exception EBaseException failed to retrieve value
+ */
+ public PKCS10 getValueAsRawPKCS10(String name, PKCS10 def) throws EBaseException;
+
+ /**
+ * Retrieves PKCS10
+ *
+ * @param name name of the input type
+ * @param checkheader true if header must be present
+ * @return PKCS10 object
+ * @exception EBaseException failed to retrieve value
+ */
+ public PKCS10 getValueAsPKCS10(String name, boolean checkheader) throws EBaseException;
+
+ /**
+ * Retrieves PKCS10
+ *
+ * @param name name of the input type
+ * @param checkheader true if header must be present
+ * @param def default PKCS10
+ * @return PKCS10 object
+ * @exception EBaseException on error
+ */
+ public PKCS10 getValueAsPKCS10(String name, boolean checkheader, PKCS10 def) throws EBaseException;
+
+ /**
+ * Retrieves PKCS10
+ *
+ * @param name name of the input type
+ * @param def default PKCS10
+ * @return PKCS10 object
+ * @exception EBaseException on error
+ */
+ public PKCS10 getValuePKCS10(String name, PKCS10 def) throws EBaseException;
+
+ /**
+ * Retrieves a list of argument keys.
+ *
+ * @return a list of string-based keys
+ */
+ public Enumeration elements();
+
+ /**
+ * Adds long-type arguments to this block.
+ *
+ * @param n key
+ * @param v value
+ * @return value
+ */
+ public Object addLongValue(String n, long v);
+
+ /**
+ * Adds integer-type arguments to this block.
+ *
+ * @param n key
+ * @param v value
+ * @return value
+ */
+ public Object addIntegerValue(String n, int v);
+
+ /**
+ * Adds boolean-type arguments to this block.
+ *
+ * @param n key
+ * @param v value
+ * @return value
+ */
+ public Object addBooleanValue(String n, boolean v);
+
+ /**
+ * Adds integer-type arguments to this block.
+ *
+ * @param n key
+ * @param v value
+ * @param radix radix
+ * @return value
+ */
+ public Object addBigIntegerValue(String n, BigInteger v, int radix);
+
+ /**
+ * Sets argument into this block.
+ *
+ * @param name key
+ * @param obj value
+ */
+ public void set(String name, Object obj);
+
+ /**
+ * Retrieves argument.
+ *
+ * @param name key
+ * @return object value
+ */
+ public Object get(String name);
+
+ /**
+ * Deletes argument by the given key.
+ *
+ * @param name key
+ */
+ public void delete(String name);
+
+ /**
+ * Retrieves a list of argument keys.
+ *
+ * @return a list of string-based keys
+ */
+ public Enumeration getElements();
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java b/pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java
new file mode 100644
index 000000000..4e8b0205d
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java
@@ -0,0 +1,72 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.io.Serializable;
+import java.util.Enumeration;
+
+
+/**
+ * This interface defines the abstraction for the generic collection
+ * of attributes indexed by string names.
+ * Set of cooperating implementations of this interface may exploit
+ * dot-separated attribute names to provide seamless access to the
+ * attributes of attribute value which also implements AttrSet
+ * interface as if it was direct attribute of the container
+ * E.g., ((AttrSet)container.get("x")).get("y") is equivalent to
+ * container.get("x.y");
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ **/
+public interface IAttrSet extends Serializable {
+
+ /**
+ * Sets an attribute value within this AttrSet.
+ *
+ * @param name the name of the attribute
+ * @param obj the attribute object.
+ * @exception EBaseException on attribute handling errors.
+ */
+ public void set(String name, Object obj)throws EBaseException;
+
+ /**
+ * Gets an attribute value.
+ *
+ * @param name the name of the attribute to return.
+ * @exception EBaseException on attribute handling errors.
+ */
+ public Object get(String name) throws EBaseException;
+
+ /**
+ * Deletes an attribute value from this AttrSet.
+ *
+ * @param name the name of the attribute to delete.
+ * @exception EBaseException on attribute handling errors.
+ */
+ public void delete(String name) throws EBaseException;
+
+ /**
+ * Returns an enumeration of the names of the attributes existing within
+ * this AttrSet.
+ *
+ * @return an enumeration of the attribute names.
+ */
+ public Enumeration getElements();
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IAuthInfo.java b/pki/base/common/src/com/netscape/certsrv/base/IAuthInfo.java
new file mode 100644
index 000000000..2006c8f23
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IAuthInfo.java
@@ -0,0 +1,36 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+import java.security.*;
+
+
+/**
+ * An interface represents an authentication context. This
+ * is an entity that encapsulates the authentication
+ * information of a service requestor. For example, CMS
+ * user needs to authenticate to CMS using SSL. The
+ * client certificate is expressed in authenticated context.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IAuthInfo {
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ICRLPrettyPrint.java b/pki/base/common/src/com/netscape/certsrv/base/ICRLPrettyPrint.java
new file mode 100644
index 000000000..902c0aad3
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ICRLPrettyPrint.java
@@ -0,0 +1,50 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * This interface represents a CRL pretty print handler.
+ * It converts a CRL object into a printable CRL string.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ICRLPrettyPrint {
+
+ /**
+ * Retrieves the printable CRL string.
+ *
+ * @param clientLocale end user clocale
+ * @param crlSize CRL size
+ * @param pageStart starting page number
+ * @param pageSize page size in rows
+ * @return printable CRL string
+ */
+ public String toString(Locale clientLocale, long crlSize, long pageStart, long pageSize);
+
+ /**
+ * Retrieves the printable CRL string.
+ *
+ * @param clientLocale end user clocale
+ * @return printable CRL string
+ */
+ public String toString(Locale clientLocale);
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ICertPrettyPrint.java b/pki/base/common/src/com/netscape/certsrv/base/ICertPrettyPrint.java
new file mode 100644
index 000000000..dc3186497
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ICertPrettyPrint.java
@@ -0,0 +1,40 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * This interface represents a certificate pretty print
+ * handler. This handler converts certificate object into
+ * a printable certificate string.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ICertPrettyPrint {
+
+ /**
+ * Returns printable certificate string.
+ *
+ * @param clientLocale end user locale
+ * @return printable certificate string
+ */
+ public String toString(Locale clientLocale);
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IConfigStore.java b/pki/base/common/src/com/netscape/certsrv/base/IConfigStore.java
new file mode 100644
index 000000000..b53e7c66f
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IConfigStore.java
@@ -0,0 +1,276 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.Enumeration;
+import java.math.BigInteger;
+
+
+/**
+ * An interface represents a configuration store.
+ * A configuration store is an abstraction of a hierarchical store
+ * to keep arbitrary data indexed by string names.<p>
+ * In the following example:
+ * <pre>
+ * param1=value1
+ * configStore1.param11=value11
+ * configStore1.param12=value12
+ * configStore1.subStore1.param111=value111
+ * configStore1.subStore1.param112=value112
+ * configStore2.param21=value21
+ * </pre>
+ * The top config store has parameters <i>param1</i> and sub-stores
+ * <i>configStore1</i> and <i>configStore2</i>. <br>
+ * The following illustrates how a config store is used.
+ * <pre>
+ * // the top config store is passed to the following method.
+ * public void init(IConfigStore config) throws EBaseException {
+ * IConfigStore store = config;
+ * String valx = config.getString("param1");
+ * // valx is "value1" <p>
+ *
+ * IConfigStore substore1 = config.getSubstore("configStore1");
+ * String valy = substore1.getString("param11");
+ * // valy is "value11" <p>
+ *
+ * IConfigStore substore2 = config.getSubstore("configStore2");
+ * String valz = substore2.getString("param21");
+ * // valz is "value21" <p>
+ * }
+ * </pre>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IConfigStore extends ISourceConfigStore {
+
+ /**
+ * Gets the name of this Configuration Store.
+ * <P>
+ * @return The name of this Configuration store
+ */
+ public String getName();
+
+ /**
+ * Retrieves the value of the given property as a string.
+ * <p>
+ * @param name The name of the property to get
+ * @return The value of the property as a String
+ * @exception EPropertyNotFound If the property is not present
+ * @exception EBaseException If an internal error occurred
+ */
+ public String getString(String name)
+ throws EPropertyNotFound, EBaseException;
+
+ /**
+ * Retrieves the value of a given property as a string or the
+ * given default value if the property is not present.
+ * <P>
+ * @param name The property to retrive
+ * @param defval The default value to return if the property is not present
+ * @return The roperty value as a string
+ * @exception EBaseException If an internal error occurred
+ */
+ public String getString(String name, String defval)
+ throws EBaseException;
+
+ /**
+ * Stores a property and its value as a string.
+ * <p>
+ * @param name The name of the property
+ * @param value The value as a string
+ */
+ public void putString(String name, String value);
+
+ /**
+ * Retrieves the value of a property as a byte array.
+ * <P>
+ * @param name The property name
+ * @return The property value as a byte array
+ * @exception EPropertyNotFound If the property is not present
+ * @exception EBaseException If an internal error occurred
+ */
+ public byte[] getByteArray(String name)
+ throws EPropertyNotFound, EBaseException;
+
+ /**
+ * Retrieves the value of a property as a byte array, using the
+ * given default value if property is not present.
+ * <P>
+ * @param name The name of the property
+ * @param defval The default value if the property is not present.
+ * @return The property value as a byte array.
+ * @exception EBaseException If an internal error occurred
+ */
+ public byte[] getByteArray(String name, byte defval[])
+ throws EBaseException;
+
+ /**
+ * Stores the given property and value as a byte array.
+ * <p>
+ * @param name The property name
+ * @param value The value as a byte array to store
+ */
+ public void putByteArray(String name, byte value[]);
+
+ /**
+ * Retrieves the given property as a boolean.
+ * <P>
+ * @param name The name of the property as a string.
+ * @return The value of the property as a boolean.
+ * @exception EPropertyNotFound If the property is not present
+ * @exception EBaseException If an internal error occurred
+ */
+ public boolean getBoolean(String name)
+ throws EPropertyNotFound, EBaseException;
+
+ /**
+ * Retrieves the given property as a boolean.
+ * <P>
+ * @param name The name of the property
+ * @param defval The default value to turn as a boolean if
+ * property is not present
+ * @return The value of the property as a boolean.
+ * @exception EBaseException If an internal error occurred
+ */
+ public boolean getBoolean(String name, boolean defval)
+ throws EBaseException;
+
+ /**
+ * Stores the given property and its value as a boolean.
+ * <P>
+ * @param name The property name
+ * @param value The value as a boolean
+ */
+ public void putBoolean(String name, boolean value);
+
+ /**
+ * Retrieves the given property as an integer.
+ * <P>
+ * @param name The property name
+ * @return The property value as an integer
+ * @exception EPropertyNotFound If property is not found
+ * @exception EBaseException If an internal error occurred
+ */
+ public int getInteger(String name)
+ throws EPropertyNotFound, EBaseException;
+
+ /**
+ * Retrieves the given property as an integer.
+ * <P>
+ * @param name The property name
+ * @return int The default value to return as an integer
+ * @exception EBaseException If the value cannot be converted to a
+ * integer
+ */
+ public int getInteger(String name, int defval)
+ throws EBaseException;
+
+ /**
+ * Sets a property and its value as an integer.
+ * <P>
+ * @param name parameter name
+ * @param value integer value
+ */
+ public void putInteger(String name, int value);
+
+ /**
+ * Retrieves the given property as a big integer.
+ * <P>
+ * @param name The property name
+ * @return The property value as a big integer
+ * @exception EPropertyNotFound If property is not found
+ * @exception EBaseException If an internal error occurred
+ */
+ public BigInteger getBigInteger(String name)
+ throws EPropertyNotFound, EBaseException;
+
+ /**
+ * Retrieves the given property as a big integer.
+ * <P>
+ * @param name The property name
+ * @return int The default value to return as a big integer
+ * @exception EBaseException If the value cannot be converted to a
+ * integer
+ */
+ public BigInteger getBigInteger(String name, BigInteger defval)
+ throws EBaseException;
+
+ /**
+ * Sets a property and its value as an integer.
+ * <P>
+ * @param name parameter name
+ * @param value big integer value
+ */
+ public void putBigInteger(String name, BigInteger value);
+
+ /**
+ * Creates a nested sub-store with the specified name.
+ * <P>
+ * @param name The name of the sub-store
+ * @return The sub-store created
+ */
+ public IConfigStore makeSubStore(String name);
+
+ /**
+ * Retrieves the given sub-store.
+ * <P>
+ * @param name The name of the sub-store
+ * @return The sub-store
+ */
+ public IConfigStore getSubStore(String name);
+
+ /**
+ * Removes sub-store with the given name.
+ * (Removes all properties and sub-stores under this sub-store.)
+ * <P>
+ * @param name The name of the sub-store to remove
+ */
+ public void removeSubStore(String name);
+
+ public void remove(String name);
+
+ /**
+ * Retrives and enumeration of all properties in this config-store.
+ * @return An enumeration of all properties in this config-store
+ */
+ public Enumeration getPropertyNames();
+
+ /**
+ * Returns an enumeration of the names of the substores of
+ * this config-store.
+ * <P>
+ * @return An enumeration of the names of the sub-stores of this
+ * config-store
+ */
+ public Enumeration getSubStoreNames();
+
+ /**
+ * Commits all the data into file immediately.
+ *
+ * @param createBackup true if a backup file should be created
+ * @exception EBaseException failed to commit
+ */
+ public void commit(boolean createBackup) throws EBaseException;
+
+ /**
+ * Return the number of items in this substore
+ */
+ public int size();
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IConfigStoreEventListener.java b/pki/base/common/src/com/netscape/certsrv/base/IConfigStoreEventListener.java
new file mode 100644
index 000000000..f2b6a03d4
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IConfigStoreEventListener.java
@@ -0,0 +1,50 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.Hashtable;
+
+
+/**
+ * ConfigStore Parameters Event Notification.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IConfigStoreEventListener {
+
+ /**
+ * Called to validate the config store parameters that changed
+ *
+ * @param action action
+ * @param params configuration parameters changed
+ * @exception EBaseException failed to validate
+ */
+ public void validateConfigParams(String action,
+ Hashtable params) throws EBaseException;
+
+ /**
+ * Validates the config store parameters that changed
+ *
+ * @param action action
+ * @param params configuration parameters changed
+ * @exception EBaseException failed to validate
+ */
+ public void doConfigParams(String action,
+ Hashtable params) throws EBaseException;
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IExtPrettyPrint.java b/pki/base/common/src/com/netscape/certsrv/base/IExtPrettyPrint.java
new file mode 100644
index 000000000..00f9c8460
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IExtPrettyPrint.java
@@ -0,0 +1,44 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import java.math.BigInteger;
+import java.security.cert.*;
+import java.security.*;
+
+
+/**
+ * This class will display the certificate content in predefined
+ * format.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IExtPrettyPrint {
+
+ /**
+ * Retrieves the printable extension string.
+ *
+ * @return printable extension string
+ */
+ public String toString();
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IExtendedPluginInfo.java b/pki/base/common/src/com/netscape/certsrv/base/IExtendedPluginInfo.java
new file mode 100644
index 000000000..ac98c6c36
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IExtendedPluginInfo.java
@@ -0,0 +1,84 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import com.netscape.certsrv.base.*;
+import java.util.*;
+import java.lang.*;
+import com.netscape.certsrv.common.*;
+
+
+/**
+ * Plugin which can return extended information to console
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IExtendedPluginInfo {
+
+ public static final String HELP_TOKEN = "HELP_TOKEN";
+ public static final String HELP_TEXT = "HELP_TEXT";
+
+ /**
+ * This method returns an array of strings. Each element of the
+ * array represents a configurable parameter, or some other
+ * meta-info (such as help-token)
+ *
+ * there is an entry indexed on that parameter name
+ * <param-name>;<type_info>[,required];<description>;...
+ *
+ * Where:
+ *
+ * type_info is either 'string', 'number', 'boolean', 'password' or
+ * 'choice(ch1,ch2,ch3,...)'
+ *
+ * If the marker 'required' is included after the type_info,
+ * the parameter will has some visually distinctive marking in
+ * the UI.
+ *
+ * 'description' is a short sentence describing the parameter
+ * 'choice' is rendered as a drop-down list. The first parameter in the
+ * list will be activated by default
+ * 'boolean' is rendered as a checkbox. The resulting parameter will be
+ * either 'true' or 'false'
+ * 'string' allows any characters
+ * 'number' allows only numbers
+ * 'password' is rendered as a password field (the characters are replaced
+ * with *'s when being types. This parameter is not passed through to
+ * the plugin. It is instead inserted directly into the password cache
+ * keyed on the instance name. The value of the parameter
+ * 'bindPWPrompt' (see example below) is set to the key.
+ *
+ * In addition to the configurable parameters, the following magic parameters
+ * may be defined:
+ *
+ * HELP_TOKEN;helptoken - a pointer to the online manual section for this plugin
+ * HELP_TEXT;helptext - a general help string describing the plugin
+ *
+ * For example:
+ * "username;string;The username you wish to login as"
+ * "bindPWPrompt;password;Enter password to bind as above user with"
+ * "algorithm;choice(RSA,DSA);Which algorithm do you want to use"
+ * "enable;boolean;Do you want to run this plugin"
+ * "port;number;Which port number do you want to use"
+ *
+ */
+ public String[] getExtendedPluginInfo(Locale locale);
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IPluginImpl.java b/pki/base/common/src/com/netscape/certsrv/base/IPluginImpl.java
new file mode 100644
index 000000000..a32dfc2ea
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IPluginImpl.java
@@ -0,0 +1,107 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+import netscape.ldap.*;
+import com.netscape.certsrv.base.*;
+
+/**
+ * This interface represents a plugin instance.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IPluginImpl {
+
+ public static final String PROP_IMPLNAME = "implName";
+
+ /**
+ * Gets the description for this plugin instance.
+ * <P>
+ * @return The Description for this plugin instance.
+ */
+ public String getDescription();
+
+ /**
+ * Returns the name of the plugin class.
+ * <P>
+ *
+ * @return The name of the plugin class.
+ */
+ public String getImplName();
+
+ /**
+ * Returns the name of the plugin instance.
+ * <P>
+ *
+ * @return The name of the plugin instance. If none is set
+ * the name of the implementation will be returned.xxxx
+ */
+ public String getInstanceName();
+
+ /**
+ * Initializes this plugin instance.
+ *
+ * @param sys parent subsystem
+ * @param instanceName instance name of this plugin
+ * @param className class name of this plugin
+ * @param config configuration store
+ * @exception EBaseException failed to initialize
+ */
+ public void init(ISubsystem sys, String instanceName, String className,
+ IConfigStore config)
+ throws EBaseException;
+
+ /**
+ * Shutdowns this plugin.
+ */
+ public void shutdown();
+
+ /**
+ * Retrieves the configuration store.
+ *
+ * @return configuration store
+ */
+ public IConfigStore getConfigStore();
+
+ /**
+ * Return configured parameters for a plugin instance.
+ *
+ * @return nvPairs A Vector of name/value pairs. Each name/value
+ * pair is constructed as a String in name=value format.
+ */
+ public Vector getInstanceParams();
+
+ /**
+ * Retrieves a list of configuration parameter names.
+ *
+ * @return a list of parameter names
+ */
+ public String[] getConfigParams();
+
+ /**
+ * Return default parameters for a plugin implementation.
+ *
+ * @return nvPairs A Vector of name/value pairs. Each name/value
+ * pair is constructed as a String in name=value.
+ */
+ public Vector getDefaultParams();
+
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IPrettyPrintFormat.java b/pki/base/common/src/com/netscape/certsrv/base/IPrettyPrintFormat.java
new file mode 100644
index 000000000..4c9626806
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/IPrettyPrintFormat.java
@@ -0,0 +1,72 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+
+
+/**
+ * This class will display the certificate content in predefined
+ * format.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IPrettyPrintFormat {
+
+ /**
+ * Retrieves a pretty print string of the given byte array.
+ *
+ * @param in byte array
+ * @param indentSize indentation size
+ * @param lineLen length of line
+ * @param separator separator string
+ * @return pretty print string
+ */
+ public String toHexString(byte[] in, int indentSize,
+ int lineLen, String separator);
+
+ /**
+ * Retrieves a pretty print string of the given byte array.
+ *
+ * @param in byte array
+ * @param indentSize indentation size
+ * @param lineLen length of line
+ * @return pretty print string
+ */
+ public String toHexString(byte[] in, int indentSize, int lineLen);
+
+ /**
+ * Retrieves a pretty print string of the given byte array.
+ *
+ * @param in byte array
+ * @param indentSize indentation size
+ * @return pretty print string
+ */
+ public String toHexString(byte[] in, int indentSize);
+
+ /**
+ * Retrieves a pretty print string of the given byte array.
+ *
+ * @param in byte array
+ * @return pretty print string
+ */
+ public String toHexString(byte[] in);
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java b/pki/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java
new file mode 100644
index 000000000..64aad508f
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ISecurityDomainSessionTable.java
@@ -0,0 +1,40 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+import java.util.*;
+import java.io.*;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.base.BaseResources;
+
+
+/**
+ * This interface defines the abstraction for the cookie table.
+ **/
+public interface ISecurityDomainSessionTable {
+ public void addEntry(String cookieId, String ip, String uid, String group);
+ public void removeEntry(String sessionId);
+ public boolean isSessionIdExist(String sessionId);
+ public String getIP(String sessionId);
+ public String getUID(String sessionId);
+ public String getGroup(String sessionId);
+ public long getBeginTime(String sessionId);
+ public int getSize();
+ public long getTimeToLive();
+ public Enumeration getSessionIds();
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ISourceConfigStore.java b/pki/base/common/src/com/netscape/certsrv/base/ISourceConfigStore.java
new file mode 100644
index 000000000..7a500bde6
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ISourceConfigStore.java
@@ -0,0 +1,82 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+
+
+/**
+ * An interface that represents the source that creates the configuration
+ * store tree. Note that the tree can be built based on the information
+ * from a text file or ldap entries.
+ * @see com.netscape.certsrv.base.IConfigStore
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ISourceConfigStore extends Serializable {
+
+ /**
+ * Gets a property.
+ * <P>
+ *
+ * @param name The property name
+ * @return property value
+ */
+ public Object get(String name);
+
+ /**
+ * Retrieves a property.
+ * <P>
+ *
+ * @param name The property name
+ * @param value The property value
+ */
+ public void put(String name, Object value);
+
+ /**
+ * Returns an enumeration of the config store's keys.
+ * <P>
+ *
+ * @return a list of keys
+ * @see java.util.Hashtable#elements
+ * @see java.util.Enumeration
+ */
+ public Enumeration keys();
+
+ /**
+ * Reads a config store from an input stream.
+ *
+ * @param in input stream where the properties are located
+ * @exception IOException If an IO error occurs while loading from input.
+ */
+ public void load(InputStream in) throws IOException;
+
+ /**
+ * Stores this config store to the specified output stream.
+ *
+ * @param out output stream where the properties should be serialized
+ * @param header optional header to be serialized
+ */
+ public void save(OutputStream out, String header);
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ISubsystem.java b/pki/base/common/src/com/netscape/certsrv/base/ISubsystem.java
new file mode 100644
index 000000000..d23895088
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ISubsystem.java
@@ -0,0 +1,82 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * An interface represents a CMS subsystem. CMS is made up of a list
+ * subsystems. Each subsystem is responsible for a set of
+ * speciailized functions.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ISubsystem {
+
+ /**
+ * Retrieves the name of this subsystem.
+ *
+ * @return subsystem identifier
+ */
+ public String getId();
+
+ /**
+ * Sets specific to this subsystem.
+ *
+ * @param id subsystem identifier
+ * @exception EBaseException failed to set id
+ */
+ public void setId(String id) throws EBaseException;
+
+ /**
+ * Initializes this subsystem with the given configuration
+ * store.
+ * <P>
+ *
+ * @param owner owner of this subsystem
+ * @param config configuration store
+ * @exception EBaseException failed to initialize
+ */
+ public void init(ISubsystem owner, IConfigStore config)
+ throws EBaseException;
+
+ /**
+ * Notifies this subsystem if owner is in running mode.
+ *
+ * @exception EBaseException failed to start up
+ */
+ public void startup() throws EBaseException;
+
+ /**
+ * Stops this system. The owner may call shutdown
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdown();
+
+ /**
+ * Returns the root configuration storage of this system.
+ * <P>
+ *
+ * @return configuration store of this subsystem
+ */
+ public IConfigStore getConfigStore();
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ISubsystemSource.java b/pki/base/common/src/com/netscape/certsrv/base/ISubsystemSource.java
new file mode 100644
index 000000000..ad89cc72b
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ISubsystemSource.java
@@ -0,0 +1,40 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * An interface represents a subsystem source. A subsystem
+ * source is a container that manages multiple subsystems.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ISubsystemSource {
+
+ /**
+ * Retrieves subsystem from the source.
+ *
+ * @param sid subsystem identifier
+ * @return subsystem
+ */
+ public ISubsystem getSubsystem(String sid);
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/ITimeSource.java b/pki/base/common/src/com/netscape/certsrv/base/ITimeSource.java
new file mode 100644
index 000000000..86ca5912e
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/ITimeSource.java
@@ -0,0 +1,43 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * This interface represents a time source where
+ * current time can be retrieved. CMS is installed
+ * with a default time source that returns
+ * current time based on the system time. It is
+ * possible to register a time source that returns
+ * the current time from a NTP server.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ITimeSource {
+
+ /**
+ * Retrieves current time and date.
+ *
+ * @return current time and date
+ */
+ public Date getCurrentDate();
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/KeyGenInfo.java b/pki/base/common/src/com/netscape/certsrv/base/KeyGenInfo.java
new file mode 100644
index 000000000..634b5d90e
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/KeyGenInfo.java
@@ -0,0 +1,225 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.lang.*;
+import java.io.IOException;
+import netscape.security.util.*;
+import netscape.security.x509.*;
+
+
+/**
+ *
+ * The <code>KeyGenInfo</code> represents the information generated by
+ * the KeyGen tag of the HTML forms. It provides the parsing and accessing
+ * mechanisms.<p>
+ *
+ * <pre>
+ * SignedPublicKeyAndChallenge ::= SEQUENCE {
+ * publicKeyAndChallenge PublicKeyAndChallenge,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signature BIT STRING
+ * }
+ *
+ * PublicKeyAndChallenge ::= SEQUENCE {
+ * spki SubjectPublicKeyInfo,
+ * challenge IA5STRING
+ * }
+ *</pre>
+ *
+ *
+ * @version $Revision$, $Date$
+ */
+
+public class KeyGenInfo {
+
+ /*==========================================================
+ * variables
+ *==========================================================*/
+ private String mSPKACString;
+ private byte mPKAC[];
+ private byte mSPKAC[];
+ private X509Key mSPKI;
+ private DerValue mDerSPKI;
+ private String mChallenge;
+ private DerValue mDerChallenge;
+ private byte mSignature[];
+ private AlgorithmId mAlgId;
+
+ /*==========================================================
+ * constructors
+ *==========================================================*/
+
+ /**
+ * Construct empty KeyGenInfo. Need to call decode function
+ * later to initialize.
+ */
+ public KeyGenInfo() {
+
+ }
+
+ /**
+ * Construct KeyGenInfo using the SignedPublicKeyAndChallenge
+ * string representation.
+ *
+ * @param spkac SignedPublicKeyAndChallenge string representation
+ */
+ public KeyGenInfo(String spkac)
+ throws IOException {
+ decode(spkac);
+ }
+
+ /*==========================================================
+ * public methods
+ *==========================================================*/
+
+ /**
+ * Initialize using the SPKAC string
+ *
+ * @param spkac SPKAC string from the end user
+ */
+ public void decode(String spkac) throws IOException {
+ mSPKACString = spkac;
+ mSPKAC = base64Decode(spkac);
+ derDecode(mSPKAC);
+ }
+
+ /**
+ * Der encoded into buffer
+ *
+ * @return Der encoded buffer
+ */
+ public byte[] encode() {
+ return mSPKAC;
+ }
+
+ /**
+ * Get SPKI in DerValue form
+ *
+ * @return SPKI in DerValue form
+ */
+ public DerValue getDerSPKI() {
+ return mDerSPKI;
+ }
+
+ /**
+ * Get SPKI as X509Key
+ *
+ * @return SPKI in X509Key form
+ */
+ public X509Key getSPKI() {
+ return mSPKI;
+ }
+
+ /**
+ * Get Challenge phrase in DerValue form
+ *
+ * @return Challenge in DerValue form. null if none.
+ */
+ public DerValue getDerChallenge() {
+ return mDerChallenge;
+ }
+
+ /**
+ * Get Challenge phrase in string format
+ *
+ * @return challenge phrase. null if none.
+ */
+ public String getChallenge() {
+ return mChallenge;
+ }
+
+ /**
+ * Get Signature
+ * @return signature
+ */
+ public byte[] getSignature() {
+ return mSignature;
+ }
+
+ /**
+ * Get Algorithm ID
+ * @return the algorithm id
+ */
+ public AlgorithmId getAlgorithmId() {
+ return mAlgId;
+ }
+
+ /**
+ * Validate Signature and Challenge Phrase
+ *
+ * @param challenge phrase; null if none
+ * @return true if validated; otherwise, false
+ */
+ public boolean validateChallenge(String challenge) {
+ if (challenge != null) {
+ if (!challenge.equals(mChallenge)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * String representation of KenGenInfo
+ *
+ * @return string representation of KeGenInfo
+ */
+ public String toString() {
+ if (mSPKACString != null)
+ return mSPKACString;
+ return "";
+ }
+
+ /*==========================================================
+ * private methods
+ *==========================================================*/
+
+ private byte[] base64Decode(String spkac)
+ throws IOException {
+
+ return com.netscape.osutil.OSUtil.AtoB(spkac);
+ }
+
+ private void derDecode(byte spkac[])
+ throws IOException {
+ DerInputStream derIn = new DerInputStream(spkac);
+
+ /* get SPKAC Algorithm & Signature */
+ DerValue derSPKACContent[] = derIn.getSequence(3);
+
+ mAlgId = AlgorithmId.parse(derSPKACContent[1]);
+ mSignature = derSPKACContent[2].getBitString();
+
+ /* get PKAC SPKI & Challenge */
+ mPKAC = derSPKACContent[0].toByteArray();
+ derIn = new DerInputStream(mPKAC);
+ DerValue derPKACContent[] = derIn.getSequence(2);
+
+ mDerSPKI = derPKACContent[0];
+ mSPKI = X509Key.parse(derPKACContent[0]);
+
+ mDerChallenge = derPKACContent[1];
+ if (mDerChallenge.length() != 0)
+ mChallenge = derPKACContent[1].getIA5String();
+
+ }
+
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/base/MessageFormatter.java b/pki/base/common/src/com/netscape/certsrv/base/MessageFormatter.java
new file mode 100644
index 000000000..796c4255b
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/MessageFormatter.java
@@ -0,0 +1,155 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import java.lang.reflect.*;
+
+
+/**
+ * Factors out common function of formatting internatinalized
+ * messages taking arguments and using java.util.ResourceBundle
+ * and java.text.MessageFormat mechanism.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ * @see java.text.MessageFormat
+ * @see java.util.ResourceBundle
+ */
+public class MessageFormatter {
+
+ private static final Class[] toStringSignature = { Locale.class };
+
+ /**
+ * Retrieves the localized string.
+ *
+ * @param locale end user locale
+ * @param resourceBundleBaseName resource bundle class name
+ * @param formatString format string
+ * @return localized string
+ */
+ public static String getLocalizedString(
+ Locale locale, String resourceBundleBaseName,
+ String formatString) {
+ return getLocalizedString(locale, resourceBundleBaseName,
+ formatString, null);
+ }
+
+ /**
+ * Retrieves the localized string.
+ *
+ * @param locale end user locale
+ * @param resourceBundleBaseName resource bundle class name
+ * @param formatString format string
+ * @param params parameters to be substituted
+ * @return localized string
+ */
+ public static String getLocalizedString(
+ Locale locale, String resourceBundleBaseName,
+ String formatString, Object params) {
+ Object o[] = new Object[1];
+
+ o[0] = params;
+ return getLocalizedString(locale, resourceBundleBaseName,
+ formatString, o);
+ }
+
+ /**
+ * Retrieves the localized string.
+ *
+ * @param locale end user locale
+ * @param resourceBundleBaseName resource bundle class name
+ * @param formatString format string
+ * @param params parameters to be substituted
+ * @return localized string
+ */
+ public static String getLocalizedString(
+ Locale locale, String resourceBundleBaseName,
+ String formatString, Object[] params) {
+
+ String localizedFormat = null;
+
+ try {
+ try {
+ // if you are worried about the efficiency of the
+ // following line, dont worry. ResourceBundle has
+ // an internal cache. So resource bundle wont be
+ // instantiated everytime you call toString().
+
+ localizedFormat = ResourceBundle.getBundle(
+ resourceBundleBaseName, locale).getString(formatString);
+ } catch (MissingResourceException e) {
+ return formatString;
+
+ }
+ Object[] localizedParams = params;
+ Object[] localeArg = null;
+
+ if (params != null) {
+ for (int i = 0; i < params.length; ++i) {
+ if (!(params[i] instanceof String) ||
+ !(params[i] instanceof Date) ||
+ !(params[i] instanceof Number)) {
+ if (localizedParams == params) {
+
+ // only done once
+ // NB if the following variant of cloning code is used
+ // localizedParams = (Object [])mParams.clone();
+ // it causes ArrayStoreException in
+ // localizedParams[i] = params[i].toString();
+ // below
+
+ localizedParams = new Object[params.length];
+ System.arraycopy(params, 0, localizedParams, 0,
+ params.length);
+ }
+ try {
+ Method toStringMethod = params[i].getClass().getMethod(
+ "toString", toStringSignature);
+
+ if (localeArg == null) {
+ // only done once
+ localeArg = new Object[] { locale };
+ }
+ localizedParams[i] = toStringMethod.invoke(
+ params[i], localeArg);
+ } catch (Exception e) {
+ // no method for localization, fall back
+ localizedParams[i] = params[i].toString();
+ }
+ }
+ }
+ }
+ try {
+ // XXX - runtime exception may be raised by the following function
+ MessageFormat format = new MessageFormat(localizedFormat);
+
+ return format.format(localizedParams);
+ } catch (IllegalArgumentException e) {
+ // XXX - for now, we just print the unformatted message
+ // if the exception is raised
+ return localizedFormat;
+ }
+ } catch (Exception e) {
+ return localizedFormat;
+ }
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java b/pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
new file mode 100644
index 000000000..fc8c8ec8a
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
@@ -0,0 +1,198 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import netscape.security.util.ObjectIdentifier;
+
+
+/**
+ * A class representing a meta attribute defintion.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class MetaAttributeDef {
+
+ private String mName;
+ private ObjectIdentifier mOid;
+ private Class mValueClass;
+ private static Hashtable mNameToAttrDef = new Hashtable();
+ private static Hashtable mOidToAttrDef = new Hashtable();
+
+ private MetaAttributeDef() {
+ }
+
+ /**
+ * Constructs a MetaAttribute defintion
+ * <P>
+ *
+ * @param name attribute name
+ * @param valueClass attribute value class
+ * @param oid attribute object identifier
+ */
+ private MetaAttributeDef(String name, Class valueClass,
+ ObjectIdentifier oid) {
+ mName = name;
+ mValueClass = valueClass;
+ mOid = oid;
+ }
+
+ /**
+ * Gets an attribute OID.
+ * <P>
+ *
+ * @return returns attribute OID or null if not defined.
+ */
+ public ObjectIdentifier getOID() {
+ return mOid;
+ }
+
+ /**
+ * Gets an Java class for the attribute values
+ * <P>
+ *
+ * @return returns Java class for the attribute values
+ */
+ public Class getValueClass() {
+ return mValueClass;
+ }
+
+ /**
+ * Gets attribute name
+ * <P>
+ *
+ * @return returns attribute name
+ */
+ public String getName() {
+ return mName;
+ }
+
+ /**
+ * Registers new MetaAttribute defintion
+ * Attribute is defined by name, Java class for attribute values and
+ * optional object identifier
+ * <P>
+ *
+ * @param name attribute name
+ * @param valueClass attribute value class
+ * @param oid attribute object identifier
+ * @exception IllegalArgumentException if name or valueClass are null, or
+ * conflicting attribute definition already exists
+ */
+ public static MetaAttributeDef register(String name, Class valueClass,
+ ObjectIdentifier oid) {
+ if (name == null) {
+ throw new IllegalArgumentException(
+ "Attribute name must not be null");
+ }
+ if (valueClass == null) {
+ throw new IllegalArgumentException(
+ "Attribute value class must not be null");
+ }
+
+ MetaAttributeDef newDef = new MetaAttributeDef(name, valueClass, oid);
+ MetaAttributeDef oldDef;
+
+ if ((oldDef = (MetaAttributeDef) mNameToAttrDef.get(name)) != null &&
+ !oldDef.equals(newDef)) {
+ throw new IllegalArgumentException(
+ "Attribute \'" + name + "\' is already defined");
+ }
+ if (oid != null &&
+ (oldDef = (MetaAttributeDef) mOidToAttrDef.get(oid)) != null &&
+ !oldDef.equals(newDef)) {
+ throw new IllegalArgumentException(
+ "OID \'" + oid + "\' is already in use");
+ }
+ mNameToAttrDef.put(name, newDef);
+ if (oid != null) {
+ mOidToAttrDef.put(oid, newDef);
+ }
+ return newDef;
+ }
+
+ /**
+ * Compares this attribute definition with another, for equality.
+ * <P>
+ *
+ * @return true iff names, valueClasses and object identifiers
+ * are identical.
+ */
+ public boolean equals(Object other) {
+ if (other == this)
+ return true;
+
+ if (other instanceof MetaAttributeDef) {
+ MetaAttributeDef otherDef = (MetaAttributeDef) other;
+
+ if ((mOid != null && otherDef.mOid != null &&
+ !mOid.equals(otherDef.mOid)) ||
+ (mOid == null && otherDef.mOid != null) ||
+ !mName.equals(otherDef.mName) ||
+ !mValueClass.equals(otherDef.mValueClass)) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Retrieves attribute definition by name
+ * <P>
+ *
+ * @param name attribute name
+ * @return attribute definition or null if not found
+ */
+ public static MetaAttributeDef forName(String name) {
+ return (MetaAttributeDef) mNameToAttrDef.get(name);
+ }
+
+ /**
+ * Retrieves attribute definition by object identifier
+ * <P>
+ *
+ * @param oid attribute object identifier
+ * @return attribute definition or null if not found
+ */
+ public static MetaAttributeDef forOID(ObjectIdentifier oid) {
+ return (MetaAttributeDef) mOidToAttrDef.get(oid);
+ }
+
+ /**
+ * Returns enumeration of the registered attribute names
+ * <P>
+ *
+ * @return returns enumeration of the registered attribute names
+ */
+ public static Enumeration getAttributeNames() {
+ return mNameToAttrDef.keys();
+ }
+
+ /**
+ * Returns enumeration of the registered attribute object identifiers
+ * <P>
+ *
+ * @return returns enumeration of the attribute object identifiers
+ */
+ public static Enumeration getAttributeNameOids() {
+ return mOidToAttrDef.keys();
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/MetaInfo.java b/pki/base/common/src/com/netscape/certsrv/base/MetaInfo.java
new file mode 100644
index 000000000..7db522547
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/MetaInfo.java
@@ -0,0 +1,116 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import com.netscape.certsrv.base.IAttrSet;
+import com.netscape.certsrv.base.AttributeNameHelper;
+import com.netscape.certsrv.base.EBaseException;
+
+
+/**
+ * A class represents meta information. A meta information
+ * object is just a generic hashtable that is embedded into
+ * a request object.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class MetaInfo implements IAttrSet {
+
+ public static final String REQUEST_ID = "requestId";
+ public static final String IN_LDAP_PUBLISH_DIR = "inLdapPublishDir";
+
+ private Hashtable content = new Hashtable();
+
+ /**
+ * Constructs a meta information.
+ * <P>
+ */
+ public MetaInfo() {
+ }
+
+ /**
+ * Returns a short string describing this certificate attribute.
+ * <P>
+ *
+ * @return information about this certificate attribute.
+ */
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("[\n");
+ sb.append(" Meta information:\n");
+ Enumeration enum1 = content.keys();
+
+ while (enum1.hasMoreElements()) {
+ String key = (String) enum1.nextElement();
+
+ sb.append(" " + key + " : " + content.get(key) + "\n");
+ }
+ sb.append("]\n");
+ return sb.toString();
+ }
+
+ /**
+ * Gets an attribute value.
+ * <P>
+ *
+ * @param name the name of the attribute to return.
+ * @exception EBaseException on attribute handling errors.
+ */
+ public Object get(String name) throws EBaseException {
+ return content.get(name);
+ }
+
+ /**
+ * Sets an attribute value.
+ *
+ * @param name the name of the attribute
+ * @param obj the attribute object.
+ *
+ * @exception EBaseException on attribute handling errors.
+ */
+ public void set(String name, Object obj) throws EBaseException {
+ content.put(name, obj);
+ }
+
+ /**
+ * Deletes an attribute value from this CertAttrSet.
+ * <P>
+ *
+ * @param name the name of the attribute to delete.
+ * @exception EBaseException on attribute handling errors.
+ */
+ public void delete(String name) throws EBaseException {
+ content.remove(name);
+ }
+
+ /**
+ * Returns an enumeration of the names of the attributes existing within
+ * this attribute.
+ * <P>
+ *
+ * @return an enumeration of the attribute names.
+ */
+ public Enumeration getElements() {
+ return content.keys();
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/Nonces.java b/pki/base/common/src/com/netscape/certsrv/base/Nonces.java
new file mode 100644
index 000000000..e1d992e40
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/Nonces.java
@@ -0,0 +1,128 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+import java.util.*;
+import java.security.cert.X509Certificate;
+
+
+/**
+ * This class manages nonces sometimes used to control request state flow.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class Nonces implements IAuthInfo {
+
+ private Hashtable mNonces = new Hashtable();
+ private Vector mNonceList = new Vector();
+ private int mNonceLimit;
+
+ /**
+ * Constructs nonces.
+ */
+ public Nonces() {
+ mNonceLimit = 100;
+ Vector mNonceList = new Vector();
+ Hashtable mNonces = new Hashtable();
+ }
+
+ public Nonces(int limit) {
+ mNonceLimit = limit;
+ Vector mNonceList = new Vector();
+ Hashtable mNonces = new Hashtable();
+ }
+
+ public long addNonce(long nonce, X509Certificate cert) {
+ long i;
+ long k = 0;
+ long n = nonce;
+ long m = (long)((mNonceLimit / 2) + 1);
+
+ for (i = 0; i < m; i++) {
+ k = n + i;
+ // avoid collisions
+ if (!mNonceList.contains((Object)k)) {
+ break;
+ }
+ k = n - i;
+ // avoid collisions
+ if (!mNonceList.contains((Object)k)) {
+ break;
+ }
+ }
+ if (i < m) {
+ mNonceList.add(k);
+ mNonces.put(k, cert);
+ if (mNonceList.size() > mNonceLimit) {
+ n = ((Long)(mNonceList.firstElement())).longValue();
+ mNonceList.remove(0);
+ mNonces.remove((Object)n);
+ }
+ } else {
+ // failed to resolved collision
+ k = -nonce;
+ }
+ return k;
+ }
+
+ public X509Certificate getCertificate(long nonce) {
+ X509Certificate cert = (X509Certificate)mNonces.get(nonce);
+ return cert;
+ }
+
+ public X509Certificate getCertificate(int index) {
+ X509Certificate cert = null;
+ if (index >= 0 && index < mNonceList.size()) {
+ long nonce = ((Long)(mNonceList.elementAt(index))).longValue();
+ cert = (X509Certificate)mNonces.get(nonce);
+ }
+ return cert;
+ }
+
+ public long getNonce(int index) {
+ long nonce = 0;
+ if (index >= 0 && index < mNonceList.size()) {
+ nonce = ((Long)(mNonceList.elementAt(index))).longValue();
+ }
+ return nonce;
+ }
+
+ public void removeNonce(long nonce) {
+ mNonceList.remove((Object)nonce);
+ mNonces.remove((Object)nonce);
+ }
+
+
+ public int size() {
+ return mNonceList.size();
+ }
+
+ public int maxSize() {
+ return mNonceLimit;
+ }
+
+ public void clear() {
+ mNonceList.clear();
+ mNonces.clear();
+ }
+
+ public boolean isInSync() {
+ return (mNonceList.size() == mNonces.size());
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/PasswordResources.java b/pki/base/common/src/com/netscape/certsrv/base/PasswordResources.java
new file mode 100644
index 000000000..e0cfe429b
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/PasswordResources.java
@@ -0,0 +1,45 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * A class represents a resource bundle for the password checker.
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ * @see java.util.ListResourceBundle
+ */
+public class PasswordResources extends ListResourceBundle {
+
+ /**
+ * Returns the content of this resource.
+ */
+ public Object[][] getContents() {
+ return contents;
+ }
+
+ /*
+ * Constants. The suffix represents the number of possible parameters.
+ */
+ static final Object[][] contents = {};
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/base/Plugin.java b/pki/base/common/src/com/netscape/certsrv/base/Plugin.java
new file mode 100644
index 000000000..0b7d7ee86
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/Plugin.java
@@ -0,0 +1,65 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import com.netscape.certsrv.base.*;
+import java.util.*;
+import java.lang.*;
+
+
+/**
+ * This represents a generici CMS plugin.
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ */
+public class Plugin {
+
+ private String mId = null;
+ private String mClassPath = null;
+
+ /**
+ * Constructs a plugin.
+ *
+ * @param id plugin implementation name
+ * @param classPath class path
+ */
+ public Plugin(String id, String classPath) {
+ mId = id;
+ mClassPath = classPath;
+ }
+
+ /**
+ * Returns the plugin identifier.
+ *
+ * @return plugin id
+ */
+ public String getId() {
+ return mId;
+ }
+
+ /**
+ * Returns the plugin classpath.
+ *
+ * @return plugin classpath
+ */
+ public String getClassPath() {
+ return mClassPath;
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/base/SessionContext.java b/pki/base/common/src/com/netscape/certsrv/base/SessionContext.java
new file mode 100644
index 000000000..79d429d71
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/base/SessionContext.java
@@ -0,0 +1,163 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.base;
+
+
+import java.util.*;
+
+
+/**
+ * This class specifies the context object that includes
+ * authentication environment and connection information.
+ * This object is later used in access control evaluation.
+ * This is a global object that can be accessible
+ * throughout the server. It is useful for passing
+ * global and per-thread infomration in methods.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class SessionContext extends Hashtable implements IAuthInfo {
+
+ /**
+ * End user locale of the current processing request in the current thread.
+ */
+ public static final String LOCALE = "locale"; // Locale
+
+ /**
+ * Authentication token in the current thread.
+ */
+ public static final String AUTH_TOKEN = "AuthToken"; // IAuthToken
+
+ /**
+ * ID of the authentication manager in the current thread.
+ */
+ public static final String AUTH_MANAGER_ID = "authManagerId"; // String
+
+ /**
+ * User object of the authenticated user in the current thread.
+ */
+ public static final String USER = "user"; // IUser
+
+ /**
+ * User ID of the authenticated user in the current thread.
+ */
+ public static final String USER_ID = "userid"; // String
+
+ /**
+ * Group ID of the authenticated user in the current thread.
+ */
+ public static final String GROUP_ID = "groupid"; //String
+
+ /**
+ * ID of the processing request in the current thread.
+ */
+ public static final String REQUESTER_ID = "requesterID"; // String
+
+ /**
+ * Recovery ID of a recovery operation in KRA in the current thread.
+ */
+ public static final String RECOVERY_ID = "recoveryID"; // String
+
+ /**
+ * IP Address of the requestor of the request in the current thread.
+ */
+ public static final String IPADDRESS = "ipAddress";
+
+ private static Hashtable mContexts = new Hashtable();
+
+ /**
+ * Constructs a session context.
+ */
+ public SessionContext() {
+ super();
+ }
+
+ /**
+ * Creates a new context and associates it with
+ * the current thread. If the current thread is
+ * also associated with a old context, the old
+ * context will be replaced.
+ */
+ private static SessionContext createContext() {
+ SessionContext sc = new SessionContext();
+
+ setContext(sc);
+ return sc;
+ }
+
+ /**
+ * Sets the current context. This allows the
+ * caller to associate a specific session context
+ * with the current thread.
+ * This methods makes custom session context
+ * possible.
+ *
+ * @param sc session context
+ */
+ public static void setContext(SessionContext sc) {
+ mContexts.put(Thread.currentThread(), sc);
+ }
+
+ /**
+ * Retrieves the session context associated with
+ * the current thread. If no context is associated,
+ * a context is created.
+ *
+ * @return sesssion context
+ */
+ public static SessionContext getContext() {
+ SessionContext sc = (SessionContext) mContexts.get(
+ Thread.currentThread());
+
+ if (sc == null) {
+ sc = createContext();
+ }
+ return sc;
+ }
+
+ /**
+ * Retrieves the session context associated with
+ * the current thread. If no context is associated,
+ * null is returned.
+ *
+ * @return sesssion context
+ */
+ public static SessionContext getExistingContext() {
+ SessionContext sc = (SessionContext)
+ mContexts.get(Thread.currentThread());
+
+ if (sc == null) {
+ return null;
+ }
+
+ return sc;
+ }
+
+ /**
+ * Releases the current session context.
+ */
+ public static void releaseContext() {
+ SessionContext sc = (SessionContext) mContexts.get(
+ Thread.currentThread());
+
+ if (sc != null) {
+ mContexts.remove(Thread.currentThread());
+ }
+ }
+}