Source Code Cross Referenced for LogEntry.java in  » Authentication-Authorization » ejbca » org » ejbca » core » model » log » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Authentication Authorization » ejbca » org.ejbca.core.model.log 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*************************************************************************
002:         *                                                                       *
003:         *  EJBCA: The OpenSource Certificate Authority                          *
004:         *                                                                       *
005:         *  This software is free software; you can redistribute it and/or       *
006:         *  modify it under the terms of the GNU Lesser General Public           *
007:         *  License as published by the Free Software Foundation; either         *
008:         *  version 2.1 of the License, or any later version.                    *
009:         *                                                                       *
010:         *  See terms of license at gnu.org.                                     *
011:         *                                                                       *
012:         *************************************************************************/package org.ejbca.core.model.log;
013:
014:        import java.io.Serializable;
015:        import java.io.UnsupportedEncodingException;
016:        import java.security.MessageDigest;
017:        import java.security.NoSuchAlgorithmException;
018:        import java.security.NoSuchProviderException;
019:        import java.util.Date;
020:
021:        import org.bouncycastle.util.encoders.Hex;
022:        import org.ejbca.core.model.protect.Protectable;
023:        import org.ejbca.core.model.protect.TableVerifyResult;
024:
025:        /**
026:         *  This is a  class containing information about one log event in the database. Used mainly during database queries by the web interface.
027:         *
028:         * @author  TomSelleck
029:         * @version $Id: LogEntry.java,v 1.13 2007/12/04 14:21:53 jeklund Exp $
030:         */
031:        public class LogEntry implements  Serializable, Protectable {
032:
033:            /**
034:             * Determines if a de-serialized file is compatible with this class.
035:             *
036:             * Maintainers must change this value if and only if the new version
037:             * of this class is not compatible with old versions. See Sun docs
038:             * for <a href=http://java.sun.com/products/jdk/1.1/docs/guide
039:             * /serialization/spec/version.doc.html> details. </a>
040:             *
041:             */
042:            private static final long serialVersionUID = -1L;
043:
044:            /**
045:             * Function used by EJBCA to log information.
046:             *
047:             * @param admintype is pricipally the type of data stored in the admindata field, should be one of org.ejbca.core.model.log.Admin.TYPE_ constants.
048:             * @param admindata is the data identifying the administrator, should be certificate snr or ip-address when no certificate could be retrieved.
049:             * @param module indicates from which module the event was logged. i.e one of the constans LogConstants.MODULE_RA, LogConstants.MODULE_CA ....
050:             * @param time the time the event occured.
051:             * @param username the name of the user involved or null if no user is involved.
052:             * @param certificate the certificate involved in the event or null if no certificate is involved.
053:             * @param event id of the event, should be one of the org.ejbca.core.model.log.LogConstants.EVENT_ constants.
054:             * @param comment comment of the event.
055:             */
056:
057:            public LogEntry(int id, int admintype, String admindata, int caid,
058:                    int module, Date time, String username,
059:                    String certificatesnr, int event, String comment) {
060:                this .id = id;
061:                this .admintype = admintype;
062:                this .admindata = admindata;
063:                this .caid = caid;
064:                this .module = module;
065:                this .time = time;
066:                this .username = username;
067:                this .certificatesnr = certificatesnr;
068:                this .event = event;
069:                this .comment = comment;
070:            }
071:
072:            // Public methods
073:
074:            /**
075:             * Method used to map between event id and a string representation of event
076:             *
077:             * @return a string representation of the event.
078:             */
079:            public String getEventName() {
080:                if (this .event < LogConstants.EVENT_ERROR_BOUNDRARY) {
081:                    return LogConstants.EVENTNAMES_INFO[this .event];
082:                }
083:                if (this .event < LogConstants.EVENT_SYSTEM_BOUNDRARY) {
084:                    return LogConstants.EVENTNAMES_ERROR[this .event
085:                            - LogConstants.EVENT_ERROR_BOUNDRARY];
086:                }
087:                return LogConstants.EVENTNAMES_SYSTEM[this .event
088:                        - LogConstants.EVENT_SYSTEM_BOUNDRARY];
089:            }
090:
091:            /**
092:             * Method used to map between event id and a string representation of event
093:             *
094:             * @return a string representation of the event.
095:             */
096:            static public String getEventName(int eventId) {
097:                if (eventId < LogConstants.EVENT_ERROR_BOUNDRARY) {
098:                    return LogConstants.EVENTNAMES_INFO[eventId];
099:                }
100:                if (eventId < LogConstants.EVENT_SYSTEM_BOUNDRARY) {
101:                    return LogConstants.EVENTNAMES_ERROR[eventId
102:                            - LogConstants.EVENT_ERROR_BOUNDRARY];
103:                }
104:                return LogConstants.EVENTNAMES_SYSTEM[eventId
105:                        - LogConstants.EVENT_SYSTEM_BOUNDRARY];
106:            }
107:
108:            public int getId() {
109:                return this .id;
110:            }
111:
112:            public int getAdminType() {
113:                return this .admintype;
114:            }
115:
116:            public String getAdminData() {
117:                return this .admindata;
118:            }
119:
120:            public int getCAId() {
121:                return this .caid;
122:            }
123:
124:            public int getModule() {
125:                return this .module;
126:            }
127:
128:            public Date getTime() {
129:                return this .time;
130:            }
131:
132:            public String getUsername() {
133:                return this .username;
134:            }
135:
136:            public String getCertificateSNR() {
137:                return this .certificatesnr;
138:            }
139:
140:            public int getEvent() {
141:                return this .event;
142:            }
143:
144:            public String getComment() {
145:                return this .comment;
146:            }
147:
148:            public String getVerifyResult() {
149:                return this .verifyResult;
150:            }
151:
152:            public void setVerifyResult(String result) {
153:                this .verifyResult = result;
154:            }
155:
156:            // 
157:            // Protectable
158:            //
159:            public int getHashVersion() {
160:                return 1;
161:            }
162:
163:            public String getDbKeyString() {
164:                return Integer.toString(id);
165:            }
166:
167:            public String getEntryType() {
168:                return "LOGENTRY";
169:            }
170:
171:            public String getHash() throws NoSuchAlgorithmException,
172:                    NoSuchProviderException, UnsupportedEncodingException {
173:                StringBuffer buf = new StringBuffer();
174:                buf.append(id).append(admintype).append(admindata).append(caid)
175:                        .append(module).append(time.getTime()).append(username)
176:                        .append(certificatesnr).append(event).append(comment);
177:                MessageDigest digest = MessageDigest.getInstance("SHA-256",
178:                        "BC");
179:                byte[] result = digest.digest(buf.toString().getBytes("UTF-8"));
180:                return new String(Hex.encode(result));
181:            }
182:
183:            public String getHash(int version) throws NoSuchAlgorithmException,
184:                    NoSuchProviderException, UnsupportedEncodingException {
185:                return getHash();
186:            }
187:
188:            // Private methods
189:
190:            // Private fields
191:            private int id;
192:            private int admintype;
193:            private String admindata;
194:            private int caid;
195:            private int module;
196:            private Date time;
197:            private String username;
198:            private String certificatesnr;
199:            private int event;
200:            private String comment;
201:            private String verifyResult = TableVerifyResult.VERIFY_DISABLED_MSG;
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.