Source Code Cross Referenced for ConfirmPasswordDataType.java in  » Database-ORM » MMBase » org » mmbase » datatypes » 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 » Database ORM » MMBase » org.mmbase.datatypes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        This software is OSI Certified Open Source Software.
004:        OSI Certified is a certification mark of the Open Source Initiative.
005:
006:        The license (Mozilla version 1.0) can be read at the MMBase site.
007:        See http://www.MMBase.org/license
008:
009:         */
010:        package org.mmbase.datatypes;
011:
012:        import java.util.*;
013:        import org.mmbase.bridge.*;
014:        import org.mmbase.datatypes.processors.Processor;
015:        import org.mmbase.util.LocalizedString;
016:        import org.mmbase.util.logging.*;
017:
018:        /**
019:         * A confirmed password datatype must have the same value as another field of the node (and makes
020:         * only sense as a field of a node).
021:         *
022:         * @author Michiel Meeuwissen
023:         * @version $Id: ConfirmPasswordDataType.java,v 1.14 2007/06/21 07:32:31 pierre Exp $
024:         * @since MMBase-1.8
025:         */
026:        public class ConfirmPasswordDataType extends StringDataType {
027:            private static final Logger log = Logging
028:                    .getLoggerInstance(ConfirmPasswordDataType.class);
029:
030:            private static final long serialVersionUID = 1L; // increase this if object serialization changes (which we shouldn't do!)
031:
032:            protected PasswordRestriction passwordRestriction = new PasswordRestriction(
033:                    "password");
034:
035:            /**
036:             * Constructor for string data type.
037:             * @param name the name of the data type
038:             */
039:            public ConfirmPasswordDataType(String name) {
040:                super (name);
041:            }
042:
043:            protected void inheritRestrictions(BasicDataType origin) {
044:                super .inheritRestrictions(origin);
045:                if (origin instanceof  ConfirmPasswordDataType) {
046:                    ConfirmPasswordDataType dataType = (ConfirmPasswordDataType) origin;
047:                    passwordRestriction.inherit(dataType.passwordRestriction);
048:                }
049:            }
050:
051:            protected void cloneRestrictions(BasicDataType origin) {
052:                super .cloneRestrictions(origin);
053:                if (origin instanceof  ConfirmPasswordDataType) {
054:                    ConfirmPasswordDataType dataType = (ConfirmPasswordDataType) origin;
055:                    passwordRestriction = new PasswordRestriction(
056:                            dataType.passwordRestriction);
057:                }
058:            }
059:
060:            public int getEnforceStrength() {
061:                return Math.max(super .getEnforceStrength(), passwordRestriction
062:                        .getEnforceStrength());
063:            }
064:
065:            protected Collection<LocalizedString> validateCastValue(
066:                    Collection<LocalizedString> errors, Object castValue,
067:                    Object value, Node node, Field field) {
068:                errors = super .validateCastValue(errors, castValue, value,
069:                        node, field);
070:                errors = passwordRestriction.validate(errors, castValue, node,
071:                        field);
072:                return errors;
073:            }
074:
075:            /**
076:             * The field property is the name of the other password field that this fields 'confirms'. It default to 'password'.
077:             * In datatype XML it can be set with the generic &lt;property name="field" value="..." /&gt;
078:             */
079:            public void setField(String field) {
080:                passwordRestriction.setValue(field);
081:            }
082:
083:            /**
084:             * Returns the name of the field which is 'confirmed' by this datatype.
085:             */
086:            public String getField() {
087:                edit();
088:                return passwordRestriction.getField();
089:            }
090:
091:            protected StringBuilder toStringBuilder() {
092:                StringBuilder buf = super .toStringBuilder();
093:                buf.append(" confirm(").append(passwordRestriction.getValue())
094:                        .append(")");
095:                return buf;
096:            }
097:
098:            protected class PasswordRestriction extends AbstractRestriction {
099:                PasswordRestriction(PasswordRestriction source) {
100:                    super (source);
101:                }
102:
103:                PasswordRestriction(String field) {
104:                    super ("confirmpassword", field);
105:                }
106:
107:                protected final String getField() {
108:                    return (String) value;
109:                }
110:
111:                protected boolean simpleValid(final Object v, final Node node,
112:                        final Field field) {
113:                    if (node != null && field != null && v != null) {
114:                        if (!node.isChanged(getField()))
115:                            return true;
116:
117:                        Field passwordField = node.getNodeManager().getField(
118:                                getField());
119:                        Processor setProcessor = passwordField.getDataType()
120:                                .getProcessor(PROCESS_SET);
121:                        Object processedValue = setProcessor.process(node,
122:                                field, v);
123:                        String passwordValue = (String) node
124:                                .getObjectValue(getField());
125:                        if (log.isDebugEnabled()) {
126:                            log.debug("Password checking "
127:                                    + (node.isNew() ? "new" : "existing")
128:                                    + " node. Password field " + passwordField
129:                                    + " set-processor " + setProcessor);
130:                            log.debug("Offered value '" + v + "' --> '"
131:                                    + processedValue);
132:                            log.debug("Comparing '" + passwordValue
133:                                    + "' with '" + processedValue + "'(" + v
134:                                    + ")");
135:                        }
136:                        return passwordValue.equals(v)
137:                                || passwordValue.equals(processedValue);
138:                    } else {
139:                        return true;
140:                    }
141:                }
142:            }
143:
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.