Source Code Cross Referenced for JGuardCredential.java in  » Authentication-Authorization » jguard » net » sf » jguard » core » authentication » credentials » 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 » jguard » net.sf.jguard.core.authentication.credentials 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        jGuard is a security framework based on top of jaas (java authentication and authorization security).
003:        it is written for web applications, to resolve simply, access control problems.
004:        version $Name$
005:        http://sourceforge.net/projects/jguard/
006:
007:        Copyright (C) 2004  Charles GAY
008:
009:        This library is free software; you can redistribute it and/or
010:        modify it under the terms of the GNU Lesser General Public
011:        License as published by the Free Software Foundation; either
012:        version 2.1 of the License, or (at your option) any later version.
013:
014:        This library is distributed in the hope that it will be useful,
015:        but WITHOUT ANY WARRANTY; without even the implied warranty of
016:        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:        Lesser General Public License for more details.
018:
019:        You should have received a copy of the GNU Lesser General Public
020:        License along with this library; if not, write to the Free Software
021:        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:
023:
024:        jGuard project home page:
025:        http://sourceforge.net/projects/jguard/
026:
027:         */
028:        package net.sf.jguard.core.authentication.credentials;
029:
030:        import java.io.Serializable;
031:        import java.lang.reflect.InvocationTargetException;
032:        import java.lang.reflect.Method;
033:        import java.util.logging.Logger;
034:
035:        /**
036:         * Class which wrap security credential.
037:         * @author <a href="mailto:diabolo512@users.sourceforge.net">Charles Gay</a>
038:         *
039:         */
040:        public class JGuardCredential implements  Serializable, Cloneable {
041:
042:            //TODO may implements Refreshable and Destroyable interfaces
043:            // cf http://java.sun.com/security/jaas/doc/api.html
044:            private static final long serialVersionUID = 2251806339549583892L;
045:            private Logger logger = Logger.getLogger(JGuardCredential.class
046:                    .getName());
047:            private String id = null;
048:            private Object value = null;
049:            private boolean digestNeeded;
050:            private boolean identity;
051:
052:            /**
053:             * @return Returns the id.
054:             */
055:            public String getId() {
056:                return id;
057:            }
058:
059:            /**
060:             * @param id The id to set.
061:             */
062:            public void setId(String id) {
063:                this .id = id;
064:            }
065:
066:            /**
067:             * @return Returns the value.
068:             */
069:            public Object getValue() {
070:                return value;
071:            }
072:
073:            /**
074:             * @param value The value to set.
075:             */
076:            public void setValue(Object value) {
077:                this .value = value;
078:            }
079:
080:            /**
081:             * used to compare an object to this credential.
082:             * @param obj object to compare
083:             * @return <i>true</i> if equals, <i>false</i> otherwise
084:             */
085:            public boolean equals(Object obj) {
086:                JGuardCredential cred = null;
087:                if (obj instanceof  JGuardCredential) {
088:                    cred = (JGuardCredential) obj;
089:                } else {
090:                    return false;
091:                }
092:                if (this .id.equals(cred.id) && this .value.equals(cred.value)) {
093:                    return true;
094:                }
095:                return false;
096:            }
097:
098:            public int hashCode() {
099:                if (id != null && value != null) {
100:                    return id.hashCode() + value.hashCode();
101:                } else if (value == null) {
102:                    return id.hashCode();
103:                } else {
104:                    return -1;
105:                }
106:            }
107:
108:            public String toString() {
109:                StringBuffer sb = new StringBuffer();
110:                sb.append("\n");
111:                sb.append("id=");
112:                sb.append(id);
113:                sb.append("\n");
114:                sb.append("value=");
115:                sb.append(value);
116:                sb.append("\n");
117:                return sb.toString();
118:            }
119:
120:            public boolean isDigestNeeded() {
121:                return digestNeeded;
122:            }
123:
124:            public void setDigestNeeded(boolean digestNeeded) {
125:                this .digestNeeded = digestNeeded;
126:            }
127:
128:            public boolean isIdentity() {
129:                return identity;
130:            }
131:
132:            public void setIdentity(boolean identity) {
133:                this .identity = identity;
134:            }
135:
136:            public Object clone() throws CloneNotSupportedException {
137:                JGuardCredential clone = (JGuardCredential) super .clone();
138:                clone.setDigestNeeded(digestNeeded);
139:                clone.setId(id);
140:                clone.setIdentity(identity);
141:                if (value == null) {
142:                    clone.setValue(null);
143:                    return clone;
144:                }
145:                if (value instanceof  Cloneable) {
146:                    Class[] clazz = new Class[] { null };
147:                    try {
148:                        Method cloneMethod = value.getClass().getMethod(
149:                                "clone", clazz);
150:                        Object clonedValue = cloneMethod.invoke(value, null);
151:                        clone.setValue(clonedValue);
152:                    } catch (SecurityException e) {
153:                        logger.severe(e.getMessage());
154:                        throw new CloneNotSupportedException(e.getMessage());
155:                    } catch (NoSuchMethodException e) {
156:                        logger.severe(e.getMessage());
157:                        throw new CloneNotSupportedException(e.getMessage());
158:                    } catch (IllegalArgumentException e) {
159:                        logger.severe(e.getMessage());
160:                        throw new CloneNotSupportedException(e.getMessage());
161:                    } catch (IllegalAccessException e) {
162:                        logger.severe(e.getMessage());
163:                        throw new CloneNotSupportedException(e.getMessage());
164:                    } catch (InvocationTargetException e) {
165:                        logger.severe(e.getMessage());
166:                        throw new CloneNotSupportedException(e.getMessage());
167:                    }
168:
169:                } else {
170:                    throw new CloneNotSupportedException(value.getClass()
171:                            + " does not support cloning mechanism ");
172:                }
173:
174:                return clone;
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.