--- /dev/null
+/*******************************************************************************\r
+ * ============LICENSE_START==================================================\r
+ * * org.onap.dmaap\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ * * http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ * * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+\r
+\r
+package org.onap.dmaap.datarouter.provisioning.beans;\r
+\r
+import java.security.cert.X509Certificate;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import org.onap.dmaap.datarouter.provisioning.BaseServlet;\r
+\r
+/**\r
+ * This class is used to log provisioning server events. Each event consists of a who\r
+ * (who made the provisioning request including the IP address, the X-ATT-DR-ON-BEHALF-OF\r
+ * header value, and the client certificate), a what (what request was made; the method\r
+ * and servlet involved), and a how (how the request was handled; the result code and\r
+ * message returned to the client). EventLogRecords are logged using log4j at the INFO level.\r
+ *\r
+ * @author Robert Eby\r
+ * @version $Id: EventLogRecord.java,v 1.1 2013/04/26 21:00:25 eby Exp $\r
+ */\r
+public class EventLogRecord {\r
+ private final String ipaddr; // Who\r
+ private final String behalfof;\r
+ private final String clientSubject;\r
+ private final String method; // What\r
+ private final String servlet;\r
+ private int result; // How\r
+ private String message;\r
+\r
+ public EventLogRecord(HttpServletRequest request) {\r
+ // Who is making the request\r
+ this.ipaddr = request.getRemoteAddr();\r
+ String s = request.getHeader(BaseServlet.BEHALF_HEADER);\r
+ this.behalfof = (s != null) ? s : "";\r
+ X509Certificate certs[] = (X509Certificate[]) request.getAttribute(BaseServlet.CERT_ATTRIBUTE);\r
+ this.clientSubject = (certs != null && certs.length > 0)\r
+ ? certs[0].getSubjectX500Principal().getName() : "";\r
+\r
+ // What is the request\r
+ this.method = request.getMethod();\r
+ this.servlet = request.getServletPath();\r
+\r
+ // How was it dealt with\r
+ this.result = -1;\r
+ this.message = "";\r
+ }\r
+ public void setResult(int result) {\r
+ this.result = result;\r
+ }\r
+ public void setMessage(String message) {\r
+ this.message = message;\r
+ }\r
+ @Override\r
+ public String toString() {\r
+ return String.format(\r
+ "%s %s \"%s\" %s %s %d \"%s\"",\r
+ ipaddr, behalfof, clientSubject,\r
+ method, servlet,\r
+ result, message\r
+ );\r
+ }\r
+}\r