Source Code Cross Referenced for LogEntryView.java in  » Authentication-Authorization » ejbca » org » ejbca » ui » web » admin » loginterface » 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.ui.web.admin.loginterface 
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.ui.web.admin.loginterface;
013:
014:        import java.util.Date;
015:        import java.util.HashMap;
016:        import java.text.DateFormat;
017:        import java.rmi.RemoteException;
018:
019:        import org.ejbca.core.model.log.Admin;
020:        import org.ejbca.core.model.log.LogConstants;
021:        import org.ejbca.core.model.log.LogEntry;
022:        import org.ejbca.ui.web.admin.rainterface.SortBy;
023:        import org.ejbca.util.dn.DNFieldExtractor;
024:
025:        /**
026:         * A class used as a help class for displaying LogEntries.
027:         *
028:         * @author  TomSelleck
029:         * @version $Id: LogEntryView.java,v 1.5 2007/12/04 18:43:36 jeklund Exp $
030:         */
031:        public class LogEntryView implements  java.io.Serializable, Cloneable,
032:                Comparable {
033:            // Public constants.
034:            public static final int TIME = 0;
035:            public static final int ADMINTYPE = 1;
036:            public static final int ADMINDATA = 2;
037:            public static final int ADMINCERTSERNO = 3;
038:            public static final int CA = 4;
039:            public static final int MODULE = 5;
040:            public static final int USERNAME = 6;
041:            public static final int CERTIFICATE = 7;
042:            public static final int CERTIFICATESERNO = 8;
043:            public static final int EVENT = 9;
044:            public static final int COMMENT = 10;
045:            public static final int VERIFY = 11;
046:
047:            public static final String TRUE = "T";
048:            public static final String FALSE = "F";
049:
050:            public static final int NUMBEROF_FIELDS = 12;
051:
052:            /** Creates a new instance of UserView */
053:            public LogEntryView(SubjectDNProxy dnproxy) {
054:                logentrydata = new String[NUMBEROF_FIELDS];
055:                for (int i = 0; i < NUMBEROF_FIELDS; i++) {
056:                    logentrydata[i] = "";
057:                }
058:                this .dnproxy = dnproxy;
059:            }
060:
061:            public LogEntryView(LogEntry logentry, SubjectDNProxy dnproxy,
062:                    String[] localinfoeventnames,
063:                    String[] localerroreventnames,
064:                    String[] localsystemeventnames, String[] localmodulenames,
065:                    HashMap caidtonamemap) throws RemoteException {
066:                logentrydata = new String[NUMBEROF_FIELDS];
067:                for (int i = 0; i < NUMBEROF_FIELDS; i++) {
068:                    logentrydata[i] = "";
069:                }
070:                this .dnproxy = dnproxy;
071:                setValues(logentry, localinfoeventnames, localerroreventnames,
072:                        localsystemeventnames, localmodulenames, caidtonamemap);
073:            }
074:
075:            // Public methods.
076:            /** Method that returns the specific logentry pointed by the parameter. */
077:            public String getValue(int parameter) {
078:                return logentrydata[parameter];
079:            }
080:
081:            /** Method that returns the specific logentry pointed by the parameter. */
082:            public void setValue(int parameter, String value) {
083:                logentrydata[parameter] = value;
084:            }
085:
086:            /** Method that returns the logentrydata as a String array */
087:            public String[] getValues() {
088:                return logentrydata;
089:            }
090:
091:            /* Sets the values according to the values in the LogEntry object.*/
092:            public void setValues(LogEntry logentry,
093:                    String[] localinfoeventnames,
094:                    String[] localerroreventnames,
095:                    String[] localsystemeventnames, String[] localmodulenames,
096:                    HashMap caidtonamemap) throws RemoteException {
097:
098:                logentrydata[TIME] = DateFormat.getDateTimeInstance(
099:                        DateFormat.SHORT, DateFormat.SHORT).format(
100:                        logentry.getTime());
101:                this .time = logentry.getTime();
102:
103:                logentrydata[ADMINTYPE] = Integer.toString(logentry
104:                        .getAdminType());
105:                if (logentry.getAdminType() == Admin.TYPE_CLIENTCERT_USER) {
106:                    String dnstring = dnproxy.getSubjectDN(logentry
107:                            .getAdminData());
108:                    if (dnstring != null) {
109:                        DNFieldExtractor dn = new DNFieldExtractor(dnstring,
110:                                DNFieldExtractor.TYPE_SUBJECTDN);
111:                        logentrydata[ADMINCERTSERNO] = logentry.getAdminData();
112:                        logentrydata[ADMINDATA] = dn.getField(
113:                                DNFieldExtractor.CN, 0)
114:                                + ", " + dn.getField(DNFieldExtractor.O, 0);
115:                    }
116:                } else {
117:                    if (logentry.getAdminType() == Admin.TYPE_PUBLIC_WEB_USER) {
118:                        if (logentry.getAdminData() != null)
119:                            logentrydata[ADMINDATA] = "IP : "
120:                                    + logentry.getAdminData();
121:                        if (logentrydata[ADMINDATA] == null)
122:                            logentrydata[ADMINDATA] = "";
123:                    } else {
124:                        if (logentry.getAdminData() != null)
125:                            logentrydata[ADMINDATA] = logentry.getAdminData();
126:                        if (logentrydata[ADMINDATA] == null)
127:                            logentrydata[ADMINDATA] = "";
128:                    }
129:                }
130:
131:                logentrydata[CA] = (String) caidtonamemap.get(new Integer(
132:                        logentry.getCAId()));
133:
134:                logentrydata[MODULE] = localmodulenames[logentry.getModule()];
135:
136:                logentrydata[USERNAME] = logentry.getUsername();
137:                if (logentrydata[USERNAME] != null
138:                        && logentrydata[USERNAME].trim().equals(""))
139:                    logentrydata[USERNAME] = null;
140:
141:                logentrydata[CERTIFICATESERNO] = logentry.getCertificateSNR();
142:                if (logentry.getCertificateSNR() != null)
143:                    if (logentry.getCertificateSNR().trim().equals(""))
144:                        logentrydata[CERTIFICATESERNO] = null;
145:                    else
146:                        logentrydata[CERTIFICATESERNO] = logentry
147:                                .getCertificateSNR();
148:
149:                if (logentrydata[CERTIFICATESERNO] != null) {
150:                    String dnstring = dnproxy.getSubjectDN(logentry
151:                            .getCertificateSNR());
152:                    if (dnstring != null) {
153:                        DNFieldExtractor dn = new DNFieldExtractor(dnstring,
154:                                DNFieldExtractor.TYPE_SUBJECTDN);
155:                        logentrydata[CERTIFICATE] = dn.getField(
156:                                DNFieldExtractor.CN, 0)
157:                                + ", " + dn.getField(DNFieldExtractor.O, 0);
158:                    }
159:                }
160:
161:                if (logentry.getEvent() < LogConstants.EVENT_ERROR_BOUNDRARY) {
162:                    logentrydata[EVENT] = localinfoeventnames[logentry
163:                            .getEvent()];
164:                } else if (logentry.getEvent() < LogConstants.EVENT_SYSTEM_BOUNDRARY) {
165:                    logentrydata[EVENT] = localerroreventnames[logentry
166:                            .getEvent()
167:                            - LogConstants.EVENT_ERROR_BOUNDRARY];
168:                } else {
169:                    logentrydata[EVENT] = localsystemeventnames[logentry
170:                            .getEvent()
171:                            - LogConstants.EVENT_SYSTEM_BOUNDRARY];
172:                }
173:
174:                logentrydata[COMMENT] = logentry.getComment();
175:                logentrydata[VERIFY] = logentry.getVerifyResult();
176:            }
177:
178:            public int compareTo(Object obj) {
179:                int returnvalue = -1;
180:                int sortby = this .sortby.getSortBy();
181:                switch (sortby) {
182:                case SortBy.USERNAME:
183:                    returnvalue = logentrydata[USERNAME]
184:                            .compareTo(((LogEntryView) obj).getValue(USERNAME));
185:                    break;
186:                case SortBy.ADMINTYPE:
187:                    returnvalue = logentrydata[ADMINTYPE]
188:                            .compareTo(((LogEntryView) obj).getValue(ADMINTYPE));
189:                    break;
190:                case SortBy.ADMINDATA:
191:                    returnvalue = logentrydata[ADMINDATA]
192:                            .compareTo(((LogEntryView) obj).getValue(ADMINDATA));
193:                    break;
194:                case SortBy.CA:
195:                    returnvalue = logentrydata[CA]
196:                            .compareTo(((LogEntryView) obj).getValue(CA));
197:                    break;
198:                case SortBy.MODULE:
199:                    returnvalue = logentrydata[MODULE]
200:                            .compareTo(((LogEntryView) obj).getValue(MODULE));
201:                    break;
202:                case SortBy.CERTIFICATE:
203:                    returnvalue = logentrydata[CERTIFICATE]
204:                            .compareTo(((LogEntryView) obj)
205:                                    .getValue(CERTIFICATE));
206:                    break;
207:                case SortBy.EVENT:
208:                    returnvalue = logentrydata[EVENT]
209:                            .compareTo(((LogEntryView) obj).getValue(EVENT));
210:                    break;
211:                case SortBy.COMMENT:
212:                    returnvalue = logentrydata[COMMENT]
213:                            .compareTo(((LogEntryView) obj).getValue(COMMENT));
214:                    break;
215:                case SortBy.TIME:
216:                    returnvalue = time
217:                            .compareTo(((LogEntryView) obj).getTime());
218:                    break;
219:                default:
220:                    returnvalue = time
221:                            .compareTo(((LogEntryView) obj).getTime());
222:                }
223:                if (this .sortby.getSortOrder() == SortBy.DECENDING)
224:                    returnvalue = 0 - returnvalue;
225:
226:                return returnvalue;
227:            }
228:
229:            public void setSortBy(SortBy sortby) {
230:                this .sortby = sortby;
231:            }
232:
233:            public Date getTime() {
234:                return time;
235:            }
236:
237:            // Private constants.  
238:
239:            // Private methods.
240:            private String[] logentrydata;
241:            private SortBy sortby;
242:            private Date time;
243:            private SubjectDNProxy dnproxy;
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.