Source Code Cross Referenced for ValidateEmailServiceImpl.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » core » identity » services » workflow » impl » 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 » Portal » jboss portal 2.6.4 » org.jboss.portal.core.identity.services.workflow.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.core.identity.services.workflow.impl;
023:
024:        import java.util.Locale;
025:
026:        import org.jboss.logging.Logger;
027:        import org.jboss.portal.common.io.IOTools;
028:        import org.jboss.portal.core.identity.services.IdentityConstants;
029:        import org.jboss.portal.core.identity.services.IdentityUserManagementService;
030:        import org.jboss.portal.core.identity.services.metadata.CoreIdentityConfigurationException;
031:        import org.jboss.portal.core.identity.services.metadata.IdentityUIConfigurationService;
032:        import org.jboss.portal.core.identity.services.workflow.UserContainer;
033:        import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
034:        import org.jboss.portal.identity.User;
035:        import org.jboss.portal.jems.as.JNDI;
036:        import org.jboss.portal.jems.as.system.AbstractJBossService;
037:        import org.jboss.portal.workflow.service.WorkflowService;
038:        import org.jbpm.JbpmContext;
039:        import org.jbpm.graph.exe.ProcessInstance;
040:        import org.jbpm.graph.exe.Token;
041:
042:        /**
043:         * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
044:         * @version $Revision$
045:         */
046:        public class ValidateEmailServiceImpl extends AbstractJBossService
047:                implements  ValidateEmailService {
048:
049:            /** The e-mail validation process name */
050:            private String processName = IdentityConstants.jbp_identity_validate_email_process_name;
051:
052:            /** The core-identity configuration service */
053:            private IdentityUIConfigurationService identityUIConfigurationService;
054:
055:            /** The core-identity user management service */
056:            private IdentityUserManagementService identityUserManagementService;
057:
058:            /** The workflow service */
059:            private WorkflowService workflowService = null;
060:
061:            /** The logger */
062:            private static final Logger log = Logger
063:                    .getLogger(ValidateEmailService.class);
064:
065:            /** The JNDI binding */
066:            private JNDI.Binding jndiBinding;
067:
068:            /** The jndi name */
069:            private String jndiName = null;
070:
071:            public void startService() throws Exception {
072:                super .startService();
073:
074:                if (this .jndiName != null) {
075:                    jndiBinding = new JNDI.Binding(jndiName, this );
076:                    jndiBinding.bind();
077:                }
078:            }
079:
080:            public void stopService() throws Exception {
081:                super .stopService();
082:
083:                if (jndiBinding != null) {
084:                    jndiBinding.unbind();
085:                    jndiBinding = null;
086:                }
087:            }
088:
089:            public WorkflowService getWorkflowService()
090:                    throws CoreIdentityConfigurationException {
091:                if (workflowService == null) {
092:                    workflowService = (WorkflowService) identityUIConfigurationService
093:                            .getWorkflowService();
094:                }
095:                return this .workflowService;
096:            }
097:
098:            public void setWorkflowService(WorkflowService workflowService) {
099:                this .workflowService = workflowService;
100:            }
101:
102:            public String getJNDIName() {
103:                return this .jndiName;
104:            }
105:
106:            public void setJNDIName(String jndiName) {
107:                this .jndiName = jndiName;
108:            }
109:
110:            public IdentityUIConfigurationService getIdentityUIConfigurationService() {
111:                return identityUIConfigurationService;
112:            }
113:
114:            public void setIdentityUIConfigurationService(
115:                    IdentityUIConfigurationService identityUIConfigurationService) {
116:                this .identityUIConfigurationService = identityUIConfigurationService;
117:            }
118:
119:            public IdentityUserManagementService getIdentityUserManagementService() {
120:                return identityUserManagementService;
121:            }
122:
123:            public void setIdentityUserManagementService(
124:                    IdentityUserManagementService identityUserManagementService) {
125:                this .identityUserManagementService = identityUserManagementService;
126:            }
127:
128:            public String changeEmail(String url, User user, String email,
129:                    Locale locale) throws CoreIdentityConfigurationException {
130:                if (!this .identityUIConfigurationService.getConfiguration()
131:                        .enableWorkflow()) {
132:                    this .getIdentityUserManagementService().updateEmail(
133:                            user.getUserName(), email);
134:                    return IdentityConstants.REGISTRATION_REGISTERED;
135:                } else {
136:                    this .changeEmailWorkflow(url, user, email, locale);
137:                    return IdentityConstants.REGISTRATION_PENDING;
138:                }
139:            }
140:
141:            public void changeEmailWorkflow(String url, User user,
142:                    String email, Locale locale)
143:                    throws CoreIdentityConfigurationException {
144:                JbpmContext jbpmContext = null;
145:                ProcessInstance processInstance = null;
146:                // String registrationHash = this.hashGen(); - generated when sending email
147:                boolean success = false;
148:                try {
149:                    jbpmContext = this .getWorkflowService()
150:                            .getJbpmConfiguration().createJbpmContext();
151:                    processInstance = jbpmContext
152:                            .newProcessInstance(this .processName);
153:                    Token token = processInstance.getRootToken();
154:
155:                    processInstance.getContextInstance().setVariable(
156:                            IdentityConstants.PORTAL_URL, url);
157:                    processInstance.getContextInstance().setVariable(
158:                            IdentityConstants.VARIABLE_USER,
159:                            new UserContainer(user));
160:                    processInstance.getContextInstance().setVariable(
161:                            IdentityConstants.VARIABLE_EMAIL, email);
162:                    processInstance.getContextInstance().setVariable(
163:                            IdentityConstants.VARIABLE_LOCALE, locale);
164:                    processInstance.getContextInstance().setVariable(
165:                            IdentityConstants.ACTION,
166:                            IdentityConstants.ACTION_CHANGE_EMAIL);
167:
168:                    token.signal();
169:                    success = true;
170:                } finally {
171:                    if (processInstance != null && success) {
172:                        jbpmContext.save(processInstance);
173:                    }
174:                    IOTools.safeClose(jbpmContext);
175:                }
176:            }
177:
178:            public String validateEmail(String id, String registrationHash)
179:                    throws CoreIdentityConfigurationException {
180:                String success = IdentityConstants.VALIDATION_FAILED;
181:                if (!this .identityUIConfigurationService.getConfiguration()
182:                        .enableWorkflow()) {
183:                    return success;
184:                }
185:
186:                JbpmContext jbpmContext = null;
187:                try {
188:                    long processId = Long.valueOf(id).longValue();
189:                    jbpmContext = this .getWorkflowService()
190:                            .getJbpmConfiguration().createJbpmContext();
191:                    ProcessInstance processInstance = jbpmContext
192:                            .getProcessInstance(processId);
193:
194:                    if (processInstance != null) {
195:                        Token token = processInstance.getRootToken();
196:                        if (token != null
197:                                && token
198:                                        .getNode()
199:                                        .getName()
200:                                        .equals(
201:                                                IdentityConstants.JBPM_NODE_EMAIL_VALIDATION)) {
202:                            String hash = (String) processInstance
203:                                    .getContextInstance().getVariable(
204:                                            IdentityConstants.VALIDATION_HASH);
205:                            if (registrationHash.equals(hash)
206:                                    && !processInstance.hasEnded()) {
207:                                token
208:                                        .signal(IdentityConstants.JBPM_TRANSITION_VALIDATED);
209:                                success = processInstance
210:                                        .getProcessDefinition().getName();
211:                            }
212:                        }
213:                    }
214:                } finally {
215:                    IOTools.safeClose(jbpmContext);
216:                }
217:                return success;
218:            }
219:        }
www_._j_a___v___a_2_s___._c_o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.