summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/certsrv/notification
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-03-24 02:27:47 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2012-03-26 11:43:54 -0500
commit621d9e5c413e561293d7484b93882d985b3fe15f (patch)
tree638f3d75761c121d9a8fb50b52a12a6686c5ac5c /base/common/src/com/netscape/certsrv/notification
parent40d3643b8d91886bf210aa27f711731c81a11e49 (diff)
downloadpki-621d9e5c413e561293d7484b93882d985b3fe15f.tar.gz
pki-621d9e5c413e561293d7484b93882d985b3fe15f.tar.xz
pki-621d9e5c413e561293d7484b93882d985b3fe15f.zip
Removed unnecessary pki folder.
Previously the source code was located inside a pki folder. This folder was created during svn migration and is no longer needed. This folder has now been removed and the contents have been moved up one level. Ticket #131
Diffstat (limited to 'base/common/src/com/netscape/certsrv/notification')
-rw-r--r--base/common/src/com/netscape/certsrv/notification/ENotificationException.java77
-rw-r--r--base/common/src/com/netscape/certsrv/notification/IEmailFormProcessor.java79
-rw-r--r--base/common/src/com/netscape/certsrv/notification/IEmailResolver.java40
-rw-r--r--base/common/src/com/netscape/certsrv/notification/IEmailResolverKeys.java35
-rw-r--r--base/common/src/com/netscape/certsrv/notification/IEmailTemplate.java48
-rw-r--r--base/common/src/com/netscape/certsrv/notification/IMailNotification.java80
-rw-r--r--base/common/src/com/netscape/certsrv/notification/NotificationResources.java43
7 files changed, 402 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/certsrv/notification/ENotificationException.java b/base/common/src/com/netscape/certsrv/notification/ENotificationException.java
new file mode 100644
index 000000000..fffc8edeb
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/notification/ENotificationException.java
@@ -0,0 +1,77 @@
+// --- 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.notification;
+
+import com.netscape.certsrv.base.EBaseException;
+
+/**
+ * A class represents a notification exception.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class ENotificationException extends EBaseException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2101529206306996303L;
+ /**
+ * Identity resource class name.
+ */
+ private static final String NOTIFICATION_RESOURCES = NotificationResources.class.getName();
+
+ /**
+ * Constructs a notification exception
+ * <P>
+ */
+ public ENotificationException(String msgFormat) {
+ super(msgFormat);
+ }
+
+ /**
+ * Constructs a Identity exception.
+ * <P>
+ */
+ public ENotificationException(String msgFormat, String param) {
+ super(msgFormat, param);
+ }
+
+ /**
+ * Constructs a Identity exception.
+ * <P>
+ */
+ public ENotificationException(String msgFormat, Exception e) {
+ super(msgFormat, e);
+ }
+
+ /**
+ * Constructs a Identity exception.
+ * <P>
+ */
+ public ENotificationException(String msgFormat, Object params[]) {
+ super(msgFormat, params);
+ }
+
+ /**
+ * Retrieves bundle name.
+ */
+ protected String getBundleName() {
+ return NOTIFICATION_RESOURCES;
+ }
+}
diff --git a/base/common/src/com/netscape/certsrv/notification/IEmailFormProcessor.java b/base/common/src/com/netscape/certsrv/notification/IEmailFormProcessor.java
new file mode 100644
index 000000000..40114bd1e
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/notification/IEmailFormProcessor.java
@@ -0,0 +1,79 @@
+// --- 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.notification;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * formulates the final email. Escape character '\' is understood.
+ * '$' is used preceeding a token name. A token name should not be a
+ * substring of any other token name
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IEmailFormProcessor {
+
+ // list of token names
+ public final static String TOKEN_ID = "InstanceID";
+ public final static String TOKEN_SERIAL_NUM = "SerialNumber";
+ public final static String TOKEN_HEX_SERIAL_NUM = "HexSerialNumber";
+ public final static String TOKEN_REQUEST_ID = "RequestId";
+ public final static String TOKEN_HTTP_HOST = "HttpHost";
+ public final static String TOKEN_HTTP_PORT = "HttpPort";
+ public final static String TOKEN_ISSUER_DN = "IssuerDN";
+ public final static String TOKEN_SUBJECT_DN = "SubjectDN";
+ public final static String TOKEN_REQUESTOR_EMAIL = "RequestorEmail";
+ public final static String TOKEN_CERT_TYPE = "CertType";
+ public final static String TOKEN_REQUEST_TYPE = "RequestType";
+ public final static String TOKEN_STATUS = "Status";
+ public final static String TOKEN_NOT_AFTER = "NotAfter";
+ public final static String TOKEN_NOT_BEFORE = "NotBefore";
+ public final static String TOKEN_SENDER_EMAIL = "SenderEmail";
+ public final static String TOKEN_RECIPIENT_EMAIL = "RecipientEmail";
+ public final static String TOKEN_SUMMARY_ITEM_LIST = "SummaryItemList";
+ public final static String TOKEN_SUMMARY_TOTAL_NUM = "SummaryTotalNum";
+ public final static String TOKEN_SUMMARY_SUCCESS_NUM = "SummaryTotalSuccess";
+ public final static String TOKEN_SUMMARY_FAILURE_NUM = "SummaryTotalFailure";
+ public final static String TOKEN_EXECUTION_TIME = "ExecutionTime";
+
+ public final static String TOKEN_REVOCATION_DATE = "RevocationDate";
+
+ /*
+ * takes the form template, parse and replace all $tokens with the
+ * right values. It handles escape character '\'
+ * @param form The locale specific form template,
+ * @param tok2vals a hashtable containing one to one mapping
+ * from $tokens used by the admins in the form template to the real
+ * values corresponding to the $tokens
+ * @return mail content
+ */
+ public String getEmailContent(String form,
+ Hashtable<String, Object> tok2vals);
+
+ /**
+ * takes a vector of strings and concatenate them
+ */
+ public String formContent(Vector<String> vec);
+
+ /**
+ * logs an entry in the log file.
+ */
+ public void log(int level, String msg);
+}
diff --git a/base/common/src/com/netscape/certsrv/notification/IEmailResolver.java b/base/common/src/com/netscape/certsrv/notification/IEmailResolver.java
new file mode 100644
index 000000000..39e5bed37
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/notification/IEmailResolver.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.notification;
+
+import com.netscape.certsrv.base.EBaseException;
+
+/**
+ * An email resolver that first checks the request email, if none,
+ * then follows by checking the subjectDN of the certificate
+ * <p>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IEmailResolver {
+
+ /**
+ * returns an email address by using the resolver keys. The
+ * return value can possibly be null
+ *
+ * @param keys list of keys used for resolving the email address
+ */
+ public String getEmail(IEmailResolverKeys keys)
+ throws EBaseException, ENotificationException;
+
+}
diff --git a/base/common/src/com/netscape/certsrv/notification/IEmailResolverKeys.java b/base/common/src/com/netscape/certsrv/notification/IEmailResolverKeys.java
new file mode 100644
index 000000000..1363a9e09
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/notification/IEmailResolverKeys.java
@@ -0,0 +1,35 @@
+// --- 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.notification;
+
+import com.netscape.certsrv.base.IAttrSet;
+
+/**
+ * An interface represents email resolver (ordered) keys for resolving
+ * emails
+ * e.g. request/cert, cert/request, request, request/cert/subjectalternatename etc.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IEmailResolverKeys extends IAttrSet {
+
+ public static final String KEY_REQUEST = "request";
+ public static final String KEY_CERT = "cert";
+
+}
diff --git a/base/common/src/com/netscape/certsrv/notification/IEmailTemplate.java b/base/common/src/com/netscape/certsrv/notification/IEmailTemplate.java
new file mode 100644
index 000000000..cbdea8436
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/notification/IEmailTemplate.java
@@ -0,0 +1,48 @@
+// --- 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.notification;
+
+/**
+ * Files to be processed and returned to the requested parties. It
+ * is a template with $tokens to be used by the form/template processor.
+ *
+ * @version $Revision$, $Date$
+ */
+
+public interface IEmailTemplate {
+
+ public boolean init();
+
+ /**
+ * @return Template Name in string form
+ */
+ public String getTemplateName();
+
+ /**
+ * @return true if template is an html file, false otherwise
+ */
+ public boolean isHTML();
+
+ /**
+ * @return Content of the template
+ */
+ public String toString();
+
+ public int length();
+
+}
diff --git a/base/common/src/com/netscape/certsrv/notification/IMailNotification.java b/base/common/src/com/netscape/certsrv/notification/IMailNotification.java
new file mode 100644
index 000000000..356a6bba3
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/notification/IMailNotification.java
@@ -0,0 +1,80 @@
+// --- 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.notification;
+
+import java.io.IOException;
+import java.util.Vector;
+
+/**
+ * This class handles mail notification via SMTP.
+ * This class uses <b>smtp.host</b> in the configuration for smtp
+ * host. The port default (25) is used. If no smtp specified, local
+ * host is used
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IMailNotification {
+
+ /**
+ * send one message to one or more addressees
+ */
+ public void sendNotification() throws IOException, ENotificationException;
+
+ /**
+ * sets the "From" field
+ *
+ * @param from email address of the sender
+ */
+ public void setFrom(String from);
+
+ /**
+ * sets the "Subject" field
+ *
+ * @param subject subject of the email
+ */
+ public void setSubject(String subject);
+
+ /**
+ * sets the "Content-Type" field
+ *
+ * @param contentType content type of the email
+ */
+ public void setContentType(String contentType);
+
+ /**
+ * sets the content of the email
+ *
+ * @param content the message content
+ */
+ public void setContent(String content);
+
+ /**
+ * sets the recipients' email addresses
+ *
+ * @param addresses a list of email addresses of the recipients
+ */
+ public void setTo(Vector<String> addresses);
+
+ /**
+ * sets the recipient's email address
+ *
+ * @param to address of the recipient email address
+ */
+ public void setTo(String to);
+
+}
diff --git a/base/common/src/com/netscape/certsrv/notification/NotificationResources.java b/base/common/src/com/netscape/certsrv/notification/NotificationResources.java
new file mode 100644
index 000000000..b81443999
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/notification/NotificationResources.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.notification;
+
+import java.util.ListResourceBundle;
+
+/**
+ * A class represents a resource bundle for the
+ * Mail Notification package
+ *
+ * @version $Revision$, $Date$
+ */
+public class NotificationResources 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 = {};
+}