Source Code Cross Referenced for UserDataVO.java in  » Authentication-Authorization » ejbca » org » ejbca » core » model » ra » 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.ra 
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.ra;
013:
014:        import java.io.Serializable;
015:        import java.util.Date;
016:        import java.util.HashMap;
017:
018:        import javax.ejb.EJBException;
019:
020:        import org.ejbca.core.ejb.ra.UserDataBean;
021:        import org.ejbca.core.model.SecConst;
022:        import org.ejbca.core.model.ra.ExtendedInformation;
023:        import org.ejbca.util.Base64GetHashMap;
024:        import org.ejbca.util.StringTools;
025:
026:        /**
027:         * Holds admin data collected from UserData in the database. Strings are stored in Base64 encoded format to be safe for storing in database, xml etc.
028:         *
029:         * @version $Id: UserDataVO.java,v 1.12 2008/01/14 14:04:13 anatom Exp $
030:         */
031:        public class UserDataVO implements  Serializable {
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 = 3837505643343885941L;
043:
044:            // Public constants
045:            public static final int NO_ENDENTITYPROFILE = 0;
046:            public static final int NO_CERTIFICATEPROFILE = 0;
047:
048:            private String username;
049:            private String subjectDN;
050:            private int caid;
051:            private String subjectAltName;
052:            private String subjectEmail;
053:            private String password;
054:            private int status;
055:            /** Type of user, from SecConst */
056:            private int type;
057:            private int endentityprofileid;
058:            private int certificateprofileid;
059:            private Date timecreated;
060:            private Date timemodified;
061:            private int tokentype;
062:            private int hardtokenissuerid;
063:            private ExtendedInformation extendedinformation;
064:
065:            /** Creates new empty UserDataVO */
066:            public UserDataVO() {
067:            }
068:
069:            /**
070:             * Creates new UserDataVO. All fields are almos required in this constructor. Password must
071:             * be set amnually though. This is so you should be sure what you do with the password.
072:             *
073:             * @param user DOCUMENT ME!
074:             * @param caid CA id of the CA that the user is registered with
075:             * @param dn DOCUMENT ME!
076:             * @param subjectaltname DOCUMENT ME!
077:             * @param email DOCUMENT ME!
078:             * @param status DOCUMENT ME!
079:             * @param type one of SecConst.ENDUSER || ...
080:             * @param endentityprofileid DOCUMENT ME!
081:             * @param certificateprofileid DOCUMENT ME!
082:             * @param timecreated DOCUMENT ME!
083:             * @param timemodified DOCUMENT ME!
084:             * @param tokentype DOCUMENT ME!
085:             * @param hardtokenissuerid DOCUMENT ME!
086:             */
087:            public UserDataVO(String user, String dn, int caid,
088:                    String subjectaltname, String email, int status, int type,
089:                    int endentityprofileid, int certificateprofileid,
090:                    Date timecreated, Date timemodified, int tokentype,
091:                    int hardtokenissuerid, ExtendedInformation extendedinfo) {
092:                setUsername(user);
093:                setPassword(null);
094:                setDN(dn);
095:                setCAId(caid);
096:                setSubjectAltName(subjectaltname);
097:                setEmail(email);
098:                setStatus(status);
099:                setType(type);
100:                setEndEntityProfileId(endentityprofileid);
101:                setCertificateProfileId(certificateprofileid);
102:                setTimeCreated(timecreated);
103:                setTimeModified(timemodified);
104:                setTokenType(tokentype);
105:                setHardTokenIssuerId(hardtokenissuerid);
106:                setExtendedinformation(extendedinfo);
107:            }
108:
109:            /**
110:             * Creates new UserDataVO. This constructor should only be used from UserDataSource 
111:             * implementations. Status and dates aren't used in these cases.
112:             * 
113:             * @param user 
114:             * @param dn 
115:             * @param caid CA id of the CA that the user is registered with
116:             * @param subjectaltname 
117:             * @param email 
118:             * @param type one of SecConst.ENDUSER || ...
119:             * @param endentityprofileid 
120:             * @param certificateprofileid 
121:             * @param tokentype 
122:             * @param hardtokenissuerid 
123:             * @param extendedinfo
124:             */
125:            public UserDataVO(String user, String dn, int caid,
126:                    String subjectaltname, String email, int type,
127:                    int endentityprofileid, int certificateprofileid,
128:                    int tokentype, int hardtokenissuerid,
129:                    ExtendedInformation extendedinfo) {
130:                setUsername(user);
131:                setPassword(null);
132:                setDN(dn);
133:                setCAId(caid);
134:                setSubjectAltName(subjectaltname);
135:                setEmail(email);
136:                setType(type);
137:                setEndEntityProfileId(endentityprofileid);
138:                setCertificateProfileId(certificateprofileid);
139:                setTokenType(tokentype);
140:                setHardTokenIssuerId(hardtokenissuerid);
141:                setExtendedinformation(extendedinfo);
142:            }
143:
144:            public void setUsername(String user) {
145:                this .username = StringTools.putBase64String(StringTools
146:                        .strip(user));
147:            }
148:
149:            public String getUsername() {
150:                return StringTools.getBase64String(username);
151:            }
152:
153:            public void setDN(String dn) {
154:                this .subjectDN = StringTools.putBase64String(dn);
155:            }
156:
157:            public String getDN() {
158:                return StringTools.getBase64String(subjectDN);
159:            }
160:
161:            public int getCAId() {
162:                return this .caid;
163:            }
164:
165:            public void setCAId(int caid) {
166:                this .caid = caid;
167:            }
168:
169:            public void setSubjectAltName(String subjectaltname) {
170:                this .subjectAltName = StringTools
171:                        .putBase64String(subjectaltname);
172:            }
173:
174:            public String getSubjectAltName() {
175:                return StringTools.getBase64String(subjectAltName);
176:            }
177:
178:            public void setEmail(String email) {
179:                this .subjectEmail = StringTools.putBase64String(email);
180:            }
181:
182:            public String getEmail() {
183:                return StringTools.getBase64String(subjectEmail);
184:            }
185:
186:            public void setPassword(String pwd) {
187:                this .password = StringTools.putBase64String(pwd);
188:            }
189:
190:            public String getPassword() {
191:                return StringTools.getBase64String(password);
192:            }
193:
194:            public void setStatus(int status) {
195:                this .status = status;
196:            }
197:
198:            public int getStatus() {
199:                return status;
200:            }
201:
202:            public void setType(int type) {
203:                this .type = type;
204:            }
205:
206:            public int getType() {
207:                return type;
208:            }
209:
210:            public void setEndEntityProfileId(int endentityprofileid) {
211:                this .endentityprofileid = endentityprofileid;
212:            }
213:
214:            public int getEndEntityProfileId() {
215:                return this .endentityprofileid;
216:            }
217:
218:            public void setCertificateProfileId(int certificateprofileid) {
219:                this .certificateprofileid = certificateprofileid;
220:            }
221:
222:            public int getCertificateProfileId() {
223:                return this .certificateprofileid;
224:            }
225:
226:            public void setTimeCreated(Date timecreated) {
227:                this .timecreated = timecreated;
228:            }
229:
230:            public Date getTimeCreated() {
231:                return this .timecreated;
232:            }
233:
234:            public void setTimeModified(Date timemodified) {
235:                this .timemodified = timemodified;
236:            }
237:
238:            public Date getTimeModified() {
239:                return this .timemodified;
240:            }
241:
242:            public int getTokenType() {
243:                return this .tokentype;
244:            }
245:
246:            public void setTokenType(int tokentype) {
247:                this .tokentype = tokentype;
248:            }
249:
250:            public int getHardTokenIssuerId() {
251:                return this .hardtokenissuerid;
252:            }
253:
254:            public void setHardTokenIssuerId(int hardtokenissuerid) {
255:                this .hardtokenissuerid = hardtokenissuerid;
256:            }
257:
258:            public boolean getAdministrator() {
259:                return (type & SecConst.USER_ADMINISTRATOR) == SecConst.USER_ADMINISTRATOR;
260:            }
261:
262:            public void setAdministrator(boolean administrator) {
263:                if (administrator)
264:                    type = type | SecConst.USER_ADMINISTRATOR;
265:                else
266:                    type = type & (~SecConst.USER_ADMINISTRATOR);
267:            }
268:
269:            public boolean getKeyRecoverable() {
270:                return (type & SecConst.USER_KEYRECOVERABLE) == SecConst.USER_KEYRECOVERABLE;
271:            }
272:
273:            public void setKeyRecoverable(boolean keyrecoverable) {
274:                if (keyrecoverable)
275:                    type = type | SecConst.USER_KEYRECOVERABLE;
276:                else
277:                    type = type & (~SecConst.USER_KEYRECOVERABLE);
278:            }
279:
280:            public boolean getSendNotification() {
281:                return (type & SecConst.USER_SENDNOTIFICATION) == SecConst.USER_SENDNOTIFICATION;
282:            }
283:
284:            public void setSendNotification(boolean sendnotification) {
285:                if (sendnotification)
286:                    type = type | SecConst.USER_SENDNOTIFICATION;
287:                else
288:                    type = type & (~SecConst.USER_SENDNOTIFICATION);
289:            }
290:
291:            public boolean getPrintUserData() {
292:                return (type & SecConst.USER_SENDNOTIFICATION) == SecConst.USER_SENDNOTIFICATION;
293:            }
294:
295:            public void setPrintUserData(boolean printUserData) {
296:                if (printUserData)
297:                    type = type | SecConst.USER_PRINT;
298:                else
299:                    type = type & (~SecConst.USER_PRINT);
300:            }
301:
302:            /**
303:             * @return Returns the extendedinformation.
304:             */
305:            public ExtendedInformation getExtendedinformation() {
306:                // If there is no extended information for this user, we return a new emtpy one
307:                if (extendedinformation == null) {
308:                    return new ExtendedInformation();
309:                }
310:                return extendedinformation;
311:            }
312:
313:            /**
314:             * @param extendedinformation The extendedinformation to set.
315:             */
316:            public void setExtendedinformation(
317:                    ExtendedInformation extendedinformation) {
318:                this .extendedinformation = extendedinformation;
319:            }
320:
321:            /**
322:             * Help Method used to create an ExtendedInformation from String representation.
323:             * Used when creating an ExtendedInformation from queries.
324:             */
325:            public static ExtendedInformation getExtendedInformation(
326:                    String extendedinfostring) {
327:                ExtendedInformation returnval = null;
328:                if (extendedinfostring != null) {
329:                    java.beans.XMLDecoder decoder;
330:                    try {
331:                        decoder = new java.beans.XMLDecoder(
332:                                new java.io.ByteArrayInputStream(
333:                                        extendedinfostring.getBytes("UTF8")));
334:
335:                        HashMap h = (HashMap) decoder.readObject();
336:                        decoder.close();
337:                        // Handle Base64 encoded string values
338:                        HashMap data = new Base64GetHashMap(h);
339:
340:                        int type = ((Integer) data
341:                                .get(ExtendedInformation.TYPE)).intValue();
342:                        switch (type) {
343:                        case ExtendedInformation.TYPE_BASIC:
344:                            returnval = (ExtendedInformation) UserDataBean.class
345:                                    .getClassLoader()
346:                                    .loadClass(
347:                                            ExtendedInformation.class.getName())
348:                                    .newInstance();
349:                            returnval.loadData(data);
350:                            break;
351:
352:                        }
353:                    } catch (Exception e) {
354:                        throw new EJBException(
355:                                "Problems generating extended information from String",
356:                                e);
357:                    }
358:                }
359:                return returnval;
360:            }
361:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.