Author: emuckenhuber
Date: 2007-08-27 15:20:51 -0400 (Mon, 27 Aug 2007)
New Revision: 8051
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailServiceImpl.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ApproveRegistration.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/CreateUserAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/SendValidationMailAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailService.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailServiceImpl.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletDelegatingPropertyResolver.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletVariableResolver.java
trunk/core-identity/src/resources/portal-identity-sar/conf/
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validate_email.xml
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_approval_workflow.xml
trunk/core-identity/src/resources/portal-identity-sar/conf/templates/
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/pendingUsers.xhtml
trunk/core-identity/src/resources/resource-bundles/
trunk/core-identity/src/resources/resource-bundles/Identity.properties
trunk/core-identity/src/resources/resource-bundles/Identity_de.properties
Removed:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/IdentityConstants.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/SendMailBean.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/workflow/
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity.properties
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity_de.properties
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/templates/
Modified:
trunk/core-identity/.classpath
trunk/core-identity/build.xml
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityCommandFactoryService.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/ImageCaptchaServlet.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/JCaptchaService.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CaptchaValidator.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/UsernameValidator.java
trunk/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml
trunk/core-identity/src/resources/portal-identity-sar/conf/templates/changeEmail/emailTemplate.tpl
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/faces-config.xml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jboss-portlet.xml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/index.xhtml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/roles/roleMembers.xhtml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/common/register.xhtml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/index.xhtml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/lostPassword/lost.xhtml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml
Log:
- user registration with jBPM
- added portletPreferences variable resolver
Modified: trunk/core-identity/.classpath
===================================================================
--- trunk/core-identity/.classpath 2007-08-27 19:09:00 UTC (rev 8050)
+++ trunk/core-identity/.classpath 2007-08-27 19:20:51 UTC (rev 8051)
@@ -12,17 +12,6 @@
<classpathentry combineaccessrules="false" kind="src"
path="/security"/>
<classpathentry combineaccessrules="false" kind="src"
path="/server"/>
<classpathentry combineaccessrules="false" kind="src"
path="/workflow"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/commons-beanutils.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/commons-digester.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/commons-el.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/el-api.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/el-ri.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/jsf-example.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/jsf-facelets.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/jstl.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/myfaces-api.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/myfaces-impl.jar"/>
- <classpathentry kind="lib"
path="output/resources/portal-identity-war/WEB-INF/lib2/portal-faces-lib.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
<classpathentry combineaccessrules="false" kind="src"
path="/common"/>
<classpathentry kind="lib"
path="/thirdparty/sun-servlet/lib/servlet-api.jar"/>
@@ -39,11 +28,9 @@
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-j2ee.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-jaxrpc.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-jca.jar"/>
- <classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"
sourcepath="/JBoss_AS_4.0.5/jmx/src/main"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-local-jdbc.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-saaj.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jbosssx.jar"/>
- <classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"
sourcepath="/JBoss_AS_4.0.5/system/src/main"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-transaction.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-xml-binding.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jmx-invoker-adaptor-client.jar"/>
@@ -51,5 +38,13 @@
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jnpserver.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/namespace.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jcaptcha/lib/jcaptcha.jar"/>
+ <classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"
sourcepath="/JBoss_AS_4.0.5/system/src/main"/>
+ <classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"
sourcepath="/JBoss_AS_4.0.5/jmx/src/main"/>
+ <classpathentry kind="lib"
path="/thirdparty/jbpm/jaronly/lib/jbpm.jar"/>
+ <classpathentry kind="lib"
path="/thirdparty/jbpm/jaronly/lib/jbpm-identity.jar"/>
+ <classpathentry kind="lib"
path="/thirdparty/facelets/lib/jsf-facelets.jar"/>
+ <classpathentry kind="lib"
path="/thirdparty/apache-myfaces/lib/jstl.jar"/>
+ <classpathentry kind="lib"
path="/thirdparty/apache-myfaces/lib/myfaces-api.jar"/>
+ <classpathentry kind="lib"
path="/thirdparty/apache-myfaces/lib/myfaces-impl.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/core-identity/build.xml
===================================================================
--- trunk/core-identity/build.xml 2007-08-27 19:09:00 UTC (rev 8050)
+++ trunk/core-identity/build.xml 2007-08-27 19:20:51 UTC (rev 8051)
@@ -102,6 +102,7 @@
<path refid="jakarta.cactus.classpath"/>
<path refid="junit.junit.classpath"/>
<pathelement location="${source.etc}/sun-jsf/jsf-example.jar"/>
+ <path refid="jbpm.jaronly.classpath"/>
</path>
<!-- Configure modules -->
@@ -122,6 +123,7 @@
<path refid="jboss.portal-security.classpath"/>
<path refid="jboss.portal-test.classpath"/>
<path refid="jboss.portal-core.classpath"/>
+ <path refid="jboss.portal-workflow.classpath"/>
</path>
<!--+=======================================+-->
@@ -197,6 +199,7 @@
<!-- portal-core-identity-services-lib.jar -->
<jar
jarfile="${build.lib}/portal-core-identity-services-lib.jar">
<fileset dir="${build.classes}"
includes="org/jboss/portal/core/identity/services/**" />
+ <fileset dir="${build.resources}/resource-bundles/" />
</jar>
<!-- portal-identity.war -->
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityCommandFactoryService.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityCommandFactoryService.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityCommandFactoryService.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -22,25 +22,16 @@
******************************************************************************/
package org.jboss.portal.core.identity.services;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.Tools;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
-import org.jboss.portal.core.identity.ui.IdentityConstants;
+import org.jboss.portal.core.identity.services.workflow.RegistrationService;
+import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPath;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
-import org.jboss.portal.core.ui.portlet.user.UserPortletConstants;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.UserModule;
-import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.config.ServerConfig;
@@ -62,10 +53,10 @@
protected ServerConfig serverConfig;
/** . */
- protected UserModule userModule;
-
+ protected RegistrationService registrationService = null;
+
/** . */
- protected UserProfileModule userProfileModule;
+ protected ValidateEmailService validateEmailService = null;
public PortalObjectId getTargetWindowId()
{
@@ -82,26 +73,30 @@
this.serverConfig = serverConfig;
}
- public IdentityCommandFactoryService()
+ public RegistrationService getRegistrationService()
{
- try
- {
- // Do something better ?
- InitialContext ctx = new InitialContext();
- this.userModule = (UserModule) ctx.lookup("java:/portal/UserModule");
- this.userProfileModule = (UserProfileModule)
ctx.lookup("java:/portal/UserProfileModule");
- }
- catch (NamingException e)
- {
- e.printStackTrace();
- }
+ return registrationService;
}
+ public void setRegistrationService(RegistrationService registrationService)
+ {
+ this.registrationService = registrationService;
+ }
+
+ public ValidateEmailService getValidateEmailService()
+ {
+ return validateEmailService;
+ }
+
+ public void setValidateEmailService(ValidateEmailService validateEmailService)
+ {
+ this.validateEmailService = validateEmailService;
+ }
+
public ControllerCommand doMapping(ControllerContext controllerContext,
ServerInvocation invocation, String host,
String contextPath, String requestPath)
{
PortletParametersStateString renderParameters = new
PortletParametersStateString();
- //renderParameters.setValue("action", "editProfile");
if (requestPath != null)
{
@@ -111,64 +106,21 @@
String[] aRequest = rPath.split("/");
int aLength = aRequest.length;
- // Values: action / userId / hash / default / default /
IdentityUserPorletWindow
- if (aLength > 2)
+ if (aLength == 2)
{
// TODO - UTF-8 decode
- String action = aRequest[0];
- String username = aRequest[1];
- String hash = aRequest[2];
+ String bpmId = aRequest[0];
+ String hash = aRequest[1];
+
+ validateEmailService.validateEmail(bpmId, hash);
- // Building path for targetWindow
- StringBuffer buffer = new StringBuffer();
- for (int i = 3; i < aLength; i++)
- {
- buffer.append(aRequest[i]);
- if ((i + 1) != aLength)
- {
- buffer.append(".");
- }
- }
+ // TODO
+ this.targetWindowId =
PortalObjectId.parse("default.default.wizardWindow_10",
PortalObjectPath.LEGACY_FORMAT);
- // TODO - nice failure
- this.targetWindowId = PortalObjectId.parse(buffer.toString(),
PortalObjectPath.LEGACY_FORMAT);
-
- try
- {
- User user = this.userModule.findUserByUserName(username);
- String storedHash = (String) this.userProfileModule.getProperty(user,
IdentityConstants.USER_PROFILE_GENERATED_HASH);
-
- if ( storedHash.equals(hash))
- {
- if (IdentityConstants.VERIFICATION_ACTION_REGISTER.equals(action))
- {
- this.userProfileModule.setProperty(user, User.INFO_USER_ENABLED,
Boolean.TRUE);
- }
- else if
(IdentityConstants.VERIFICATION_ACTION_UPDATE_EMAIL.equals(action))
- {
- String newEmail = (String) this.userProfileModule.getProperty(user,
IdentityConstants.USER_PROFILE_NEW_EMAIL_ADDRESS);
- this.userProfileModule.setProperty(user, User.INFO_USER_EMAIL_REAL,
newEmail);
- }
- }
- }
- catch (IllegalArgumentException e)
- {
- // FIXME
- e.printStackTrace();
- }
- catch (NoSuchUserException e)
- {
- //
- }
- catch (IdentityException e)
- {
- // FIXME
- e.printStackTrace();
- }
}
else
{
- this.targetWindowId =
PortalObjectId.parse("default.default.wizardWindow_33",
+ this.targetWindowId =
PortalObjectId.parse("default.default.wizardWindow_10",
PortalObjectPath.LEGACY_FORMAT);
}
Copied:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java
(from rev 8017,
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/IdentityConstants.java)
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class IdentityConstants
+{
+ public static final String HASH_SALT = "fuDrupRunEP2BRuspADr";
+
+ /*
+ * Available actions
+ */
+ public static final String ACTION = "action";
+ public static final String ACTION_REGISTER_USER = "register";
+ public static final String ACTION_CHANGE_EMAIL = "changeEmail";
+ public static final String ACTION_LOST_PASSWORD = "lostPassword";
+
+ public static final String REGISTRATION_REGISTERED = "REGISTERED";
+ public static final String REGISTRATION_PENDING ="PENDING";
+
+ public static final String VALIDATION_HASH = "validationHash";
+ public static final String VARIABLE_LOCALE = "locale";
+ public static final String VARIABLE_EMAIL = "email";
+ public static final String VARIABLE_USER = "user";
+
+ public static final String DEFAULT_LOCALE = "en";
+
+}
+
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.Map;
+
+import freemarker.template.TemplateException;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface IdentityMailService
+{
+ void sendMail(String templateLocation, Map mailData, Locale locale) throws
IOException, TemplateException;
+}
+
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailServiceImpl.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailServiceImpl.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailServiceImpl.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,213 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.core.modules.MailModule;
+import org.jboss.portal.jems.as.JNDI;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class IdentityMailServiceImpl extends AbstractJBossService implements
IdentityMailService
+{
+
+ /** . */
+ private Map mailData = new HashMap();
+
+ /** . */
+ private Locale locale;
+
+ /** . */
+ private String emailText = null;
+
+ /** . */
+ private String emailDomain = "TODO emailDomain";
+
+ /** . */
+ private String emailFrom = "no-reply(a)todo.com";
+
+ /** . */
+ private String templateLocation;
+
+ /** . */
+ private MailModule mailModule;
+
+ /** . */
+ private static final Logger log = Logger.getLogger(IdentityMailServiceImpl.class);
+
+ /** . */
+ private JNDI.Binding jndiBinding;
+
+ /** . */
+ private String jndiName = null;
+
+ /** . */
+ public void startService() throws Exception
+ {
+ super.startService();
+
+ if (this.jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ this.mailModule = (MailModule) new
InitialContext().lookup("java:/portal/MailModule");
+ if (mailModule == null)
+ throw new Exception("no mail module");
+ }
+
+ public void stopService() throws Exception
+ {
+ super.stopService();
+
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ }
+
+ public String getEmailDomain()
+ {
+ return emailDomain;
+ }
+
+ public void setEmailDomain(String emailDomain)
+ {
+ this.emailDomain = emailDomain;
+ }
+
+ public String getEmailFrom()
+ {
+ return emailFrom;
+ }
+
+ public void setEmailFrom(String emailFrom)
+ {
+ this.emailFrom = emailFrom;
+ }
+
+ public MailModule getMailModule()
+ {
+ return mailModule;
+ }
+
+ public void setMailModule(MailModule mailModule)
+ {
+ this.mailModule = mailModule;
+ }
+
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public void sendMail(String templateLocation, Map mailData, Locale locale) throws
IOException, TemplateException
+ {
+ this.templateLocation = templateLocation;
+ this.mailData = mailData;
+ this.locale = locale;
+ this.mailData.put("emailDomain", emailDomain);
+
+ ResourceBundle bundle = ResourceBundle.getBundle("Identity", locale);
+
+ String subject = null;
+ String to = (String) mailData.get("to");
+
+ if (IdentityConstants.ACTION_REGISTER_USER.equals(templateLocation))
+ {
+ subject = bundle.getString("IDENTITY_MAIL_SUBJECT_REGISTER");
+ }
+ else if (IdentityConstants.ACTION_CHANGE_EMAIL.equals(templateLocation))
+ {
+ subject = bundle.getString("IDENTITY_MAIL_SUBJECT_CHANGE_EMAIL");
+ }
+ else if (IdentityConstants.ACTION_LOST_PASSWORD.equals(templateLocation))
+ {
+ subject = bundle.getString("IDENTITY_MAIL_SUBJECT_LOST_PASSWORD");
+ }
+ else
+ {
+ throw new IllegalArgumentException("unknown template.");
+ }
+
+ // Generating message
+ this.generateEmailText();
+
+ // Sending mail
+ // mailModule.send(emailFrom, to , subject, emailText);
+ log.debug(subject + to + this.emailText);
+ }
+
+ private void generateEmailText() throws IOException, TemplateException
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ URL config = tcl.getResource("conf/templates/" + this.templateLocation +
"/emailTemplate_" + locale.getLanguage() + "_" + locale.getCountry() +
".tpl");
+ if (config == null)
+ {
+ config = tcl.getResource("conf/templates/" + this.templateLocation +
"/emailTemplate_" + locale.getLanguage() + ".tpl");
+ }
+ if (config == null)
+ {
+ config = tcl.getResource("conf/templates/" + this.templateLocation +
"/emailTemplate.tpl");
+ }
+ if (config == null)
+ {
+ throw new FileNotFoundException("Cannot load a suitable emailTemplate.tpl
in templates/"
+ + this.templateLocation);
+ }
+ InputStream in = config.openStream();
+ Template tpl = new Template("emailTemplate", new InputStreamReader(in),
new Configuration());
+ StringWriter out = new StringWriter();
+ tpl.process(this.mailData, out);
+ out.close();
+
+ this.emailText = out.toString();
+ }
+}
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/ImageCaptchaServlet.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/ImageCaptchaServlet.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/ImageCaptchaServlet.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -22,10 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.identity.services.captcha;
-import com.octo.captcha.service.CaptchaServiceException;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
-
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
@@ -33,63 +29,43 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-
-
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
* @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
* @version $Revision$
*/
-public class ImageCaptchaServlet extends HttpServlet {
+public class ImageCaptchaServlet extends HttpServlet
+{
+ public void init(ServletConfig servletConfig) throws ServletException
+ {
+ super.init(servletConfig);
+ }
- public void init(ServletConfig servletConfig) throws ServletException {
+ protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse)
+ throws ServletException, IOException
+ {
- super.init(servletConfig);
+ byte[] captchaChallenge = null;
+ String captchaId = httpServletRequest.getSession().getId();
+ try
+ {
+ captchaChallenge = JCaptchaService.getChallengeImage(captchaId,
httpServletRequest.getLocale());
+ }
+ catch (IllegalArgumentException e)
+ {
+ httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
- }
-
- protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws ServletException, IOException {
-
- byte[] captchaChallengeAsJpeg = null;
- // the output stream to render the captcha image as jpeg into
- ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
- try {
- // get the session id that will identify the generated captcha.
- //the same id must be used to validate the response, the session id is a good
candidate!
- String captchaId = httpServletRequest.getSession().getId();
- // call the ImageCaptchaService getChallenge method
- BufferedImage challenge =
- JCaptchaService.getInstance().getImageChallengeForID(captchaId,
- httpServletRequest.getLocale());
-
- // a jpeg encoder
- JPEGImageEncoder jpegEncoder =
- JPEGCodec.createJPEGEncoder(jpegOutputStream);
- jpegEncoder.encode(challenge);
- } catch (IllegalArgumentException e) {
- httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
- return;
- } catch (CaptchaServiceException e) {
- httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- return;
- }
-
- captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
-
- // flush it in the response
- httpServletResponse.setHeader("Cache-Control", "no-store");
- httpServletResponse.setHeader("Pragma", "no-cache");
- httpServletResponse.setDateHeader("Expires", 0);
- httpServletResponse.setContentType("image/jpeg");
- ServletOutputStream responseOutputStream =
- httpServletResponse.getOutputStream();
- responseOutputStream.write(captchaChallengeAsJpeg);
- responseOutputStream.flush();
- responseOutputStream.close();
- }
+ httpServletResponse.setHeader("Cache-Control", "no-store");
+ httpServletResponse.setHeader("Pragma", "no-cache");
+ httpServletResponse.setDateHeader("Expires", 0);
+ httpServletResponse.setContentType("image/jpeg");
+ ServletOutputStream responseOutputStream = httpServletResponse.getOutputStream();
+ responseOutputStream.write(captchaChallenge);
+ responseOutputStream.flush();
+ responseOutputStream.close();
+ }
}
\ No newline at end of file
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/JCaptchaService.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/JCaptchaService.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/captcha/JCaptchaService.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -23,9 +23,15 @@
package org.jboss.portal.core.identity.services.captcha;
import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Locale;
import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
import com.octo.captcha.service.image.ImageCaptchaService;
+import com.sun.image.codec.jpeg.ImageFormatException;
+import com.sun.image.codec.jpeg.JPEGCodec;
+import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
@@ -33,19 +39,23 @@
*/
public class JCaptchaService
{
-
+ /** . */
private static ImageCaptchaService instance = new
DefaultManageableImageCaptchaService();
- public static ImageCaptchaService getInstance()
+ public static Boolean validateResponseForID(String challengeId, String value)
{
- return instance;
+ return instance.validateResponseForID(challengeId, value);
}
- public BufferedImage challenge(String challengeId)
+ public static byte[] getChallengeImage(String challengeId, Locale locale) throws
ImageFormatException, IOException
{
- return instance.getImageChallengeForID(challengeId);
+ ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
+
+ BufferedImage challenge = instance.getImageChallengeForID(challengeId, locale);
+
+ JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream);
+ jpegEncoder.encode(challenge);
+
+ return jpegOutputStream.toByteArray();
}
-
-
}
-
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ApproveRegistration.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ApproveRegistration.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ApproveRegistration.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,291 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services.workflow;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.core.identity.services.IdentityConstants;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.jems.as.JNDI;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.workflow.service.WorkflowService;
+import org.jbpm.JbpmContext;
+import org.jbpm.db.GraphSession;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ApproveRegistration extends AbstractJBossService implements
RegistrationService
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(ApproveRegistration.class);
+
+ /** . */
+ private WorkflowService workflowService = null;
+
+ /** . */
+ private String processName = "jbp_identity_validation_approval_workflow";
+
+ /** . */
+ private boolean overwrite = false;
+
+ /** . */
+ private String processFile = "conf/processes/" + processName +
".xml";
+
+ /** . */
+ private JNDI.Binding jndiBinding;
+
+ /** . */
+ private String jndiName = null;
+
+ /** . */
+ private ValidateEmailService validateEmailService;
+
+ public void startService() throws Exception
+ {
+ super.startService();
+
+ if (this.jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ InputStream is = null;
+ JbpmContext jbpmContext = null;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ ProcessDefinition processDefinition =
jbpmContext.getGraphSession().findLatestProcessDefinition(
+ this.processName);
+ if (processDefinition == null)
+ {
+ processDefinition = ProcessDefinition.parseXmlResource(processFile);
+ jbpmContext.deployProcessDefinition(processDefinition);
+ }
+ else
+ {
+ // A process definition already exists....should deploy a new version
+ // of the definition if overwrite is true
+ ProcessDefinition fromConfig =
ProcessDefinition.parseXmlResource(processFile);
+ if (this.overwrite)
+ {
+ // If the two of them are not same, create a new version
+ // of this process definition
+ jbpmContext.deployProcessDefinition(fromConfig);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ //
+ this.stopService();
+
+ //
+ throw e;
+ }
+ finally
+ {
+ IOTools.safeClose(is);
+ IOTools.safeClose(jbpmContext);
+ }
+ }
+
+ public void stopService() throws Exception
+ {
+ super.stopService();
+
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ }
+
+ /** @return */
+ public WorkflowService getWorkflowService()
+ {
+ return this.workflowService;
+ }
+
+ /** @param workflowService */
+ public void setWorkflowService(WorkflowService workflowService)
+ {
+ this.workflowService = workflowService;
+ }
+
+ /** @return */
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ /** @param jndiName */
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public ValidateEmailService getValidateEmailService()
+ {
+ return validateEmailService;
+ }
+
+ public void setValidateEmailService(ValidateEmailService validateEmailService)
+ {
+ this.validateEmailService = validateEmailService;
+ }
+
+ public String registerUser(String username, String password, Map profileMap, List
roles, Locale locale)
+ {
+ JbpmContext jbpmContext = null;
+ ProcessInstance processInstance = null;
+ // String registrationHash = this.hashGen(); - done at send email action
+ boolean success = false;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+ processInstance = jbpmContext.newProcessInstance(this.processName);
+ Token token = processInstance.getRootToken();
+
+ // Setting required attributes for the workflow
+ UserContainer user = new UserContainer(username, password, profileMap, roles);
+
processInstance.getContextInstance().setVariable(IdentityConstants.VARIABLE_USER, user);
+
processInstance.getContextInstance().setVariable(IdentityConstants.VARIABLE_EMAIL,
user.getProfileMap().get(User.INFO_USER_EMAIL_REAL));
+
processInstance.getContextInstance().setVariable(IdentityConstants.VARIABLE_LOCALE,
locale);
+ processInstance.getContextInstance().setVariable(IdentityConstants.ACTION,
IdentityConstants.ACTION_REGISTER_USER);
+ token.signal();
+ success = true;
+ }
+ catch (Exception e)
+ {
+ success = false;
+ log.error("Exception in Workflow", e);
+ // throw new WorkflowException(e);
+ }
+ finally
+ {
+ if (processInstance != null && success)
+ {
+ jbpmContext.save(processInstance);
+ }
+ IOTools.safeClose(jbpmContext);
+ }
+ return IdentityConstants.REGISTRATION_PENDING;
+ }
+
+ public String approve(String id, boolean approve)
+ {
+ JbpmContext jbpmContext = null;
+ try
+ {
+ long processId = Long.valueOf(id).longValue();
+ jbpmContext = jbpmContext.getJbpmConfiguration().createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.getProcessInstance(processId);
+
+ if (processInstance != null)
+ {
+ Node n = processInstance.getRootToken().getNode();
+ if (n.getName().equals("adminApproval"))
+ {
+ if (approve)
+ {
+ processInstance.signal("approved");
+ }
+ else
+ {
+ processInstance.signal("rejected");
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("", e);
+ }
+ finally
+ {
+ IOTools.safeClose(jbpmContext);
+ }
+ return IdentityConstants.REGISTRATION_PENDING;
+ }
+
+ public List getPendingUsers()
+ {
+ List queue = new ArrayList();
+ JbpmContext jbpmContext = null;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ GraphSession graphSession = jbpmContext.getGraphSession();
+ ProcessDefinition processDef =
graphSession.findLatestProcessDefinition(this.processName);
+ List processInstances = graphSession.findProcessInstances(processDef.getId());
+
+ if (processInstances != null)
+ {
+ Iterator i = processInstances.iterator();
+ while (i.hasNext())
+ {
+ ProcessInstance instance = (ProcessInstance) i.next();
+ if (!instance.hasEnded())
+ {
+ Object obj =
instance.getContextInstance().getVariable(IdentityConstants.VARIABLE_USER);
+ if (obj instanceof UserContainer)
+ {
+ // Filling pending user List
+ UserContainer user = (UserContainer) obj;
+ user.setProcessId(String.valueOf(instance.getId()));
+ user.setCurrentNode(instance.getRootToken().getNode().getName());
+ queue.add(user);
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("", e);
+ }
+ finally
+ {
+ IOTools.safeClose(jbpmContext);
+ }
+ return queue;
+ }
+
+}
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/CreateUserAction.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/CreateUserAction.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/CreateUserAction.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services.workflow;
+
+import org.jboss.logging.Logger;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class CreateUserAction implements ActionHandler
+{
+ private static Logger log = Logger.getLogger(CreateUserAction.class);
+
+ public void execute(ExecutionContext ectx) throws Exception
+ {
+ UserContainer user = (UserContainer)
ectx.getContextInstance().getVariable("user");
+ // FIXME execute
+ log.debug("creating User: "+ user.getUsername() );
+ }
+
+}
+
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services.workflow;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface RegistrationService
+{
+ /** . */
+ String registerUser(String username, String password, Map profileMap, List roles,
Locale locale);
+
+ /** . */
+ String approve(String id, boolean approve);
+
+ /** . */
+ List getPendingUsers();
+}
+
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/SendValidationMailAction.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/SendValidationMailAction.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/SendValidationMailAction.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,178 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services.workflow;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.HashMap;
+import java.util.Locale;
+
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.core.identity.services.IdentityConstants;
+import org.jboss.portal.core.identity.services.IdentityMailService;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class SendValidationMailAction implements ActionHandler
+{
+ /** . */
+ private UserModule userModule;
+
+ /** . */
+ private UserProfileModule userProfileModule;
+
+ /** . */
+ private IdentityMailService identityMailService;
+
+ /** . */
+ private static Logger log = Logger.getLogger(SendValidationMailAction.class);
+
+ public void execute(ExecutionContext ectx) throws Exception
+ {
+ HashMap emailMap = new HashMap();
+ String hash = this.hashGen();
+
+ String action = (String)
ectx.getContextInstance().getVariable(IdentityConstants.ACTION);
+ String email = (String)
ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_EMAIL);
+ Locale locale = (Locale)
ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_LOCALE);
+
+ if ( locale == null)
+ {
+ locale = new Locale(IdentityConstants.DEFAULT_LOCALE);
+ }
+
+ UserContainer uc = (UserContainer)
ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_USER);
+
+ // Register new user
+ if (IdentityConstants.ACTION_REGISTER_USER.equals(action))
+ {
+ emailMap.put("to", email);
+ emailMap.put("username", uc.getUsername());
+ emailMap.put("password", uc.getPassword());
+ }
+ // Change email
+ else if (IdentityConstants.ACTION_CHANGE_EMAIL.equals(action))
+ {
+ User user = this.getUserModule().findUserByUserName(uc.getUsername());
+ emailMap.put("to", (String)
this.getUserProfileModule().getProperty(user, User.INFO_USER_EMAIL_REAL));
+ }
+ else
+ {
+ throw new RuntimeException("wrong Action");
+ }
+
+ ectx.getContextInstance().setVariable(IdentityConstants.VALIDATION_HASH, hash);
+ // TODO - build url
+ String activationLink = "validateEmail/" +
ectx.getProcessInstance().getId() + "/" + hash;
+ emailMap.put("activationLink", activationLink);
+
+ this.getIdentityMailService().sendMail(action, emailMap, locale);
+ }
+
+ // generating a random hash
+ private String hashGen()
+ {
+ try
+ {
+ SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+
+ byte[] bytes = new byte[512];
+ secureRandom.nextBytes(bytes);
+
+ double rand = secureRandom.nextDouble();
+ long time = System.currentTimeMillis();
+ String salt = IdentityConstants.HASH_SALT;
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(rand);
+ buffer.append(salt);
+ buffer.append(time);
+
+ return Tools.md5AsHexString(buffer.toString());
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ log.error("No Such Algorithm exists " + e);
+ }
+ return null;
+ }
+
+ private IdentityMailService getIdentityMailService()
+ {
+ if (identityMailService == null)
+ {
+ try
+ {
+ this.identityMailService = (IdentityMailService) new
InitialContext().lookup("java:/portal/IdentityMailService");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return identityMailService;
+ }
+
+ private UserModule getUserModule()
+ {
+ if (userModule == null)
+ {
+ try
+ {
+ this.userModule = (UserModule) new
InitialContext().lookup("java:/portal/UserModule");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return userModule;
+ }
+
+ private UserProfileModule getUserProfileModule()
+ {
+ if (userProfileModule == null)
+ {
+ try
+ {
+ this.userProfileModule = (UserProfileModule) new
InitialContext().lookup("java:/portal/UserProfileModule");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return userProfileModule;
+ }
+
+}
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services.workflow;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.jboss.portal.identity.User;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class UserContainer implements Serializable
+{
+
+ private String processId;
+
+ private String username;
+
+ private String password;
+
+ private Map profileMap;
+
+ private List roles;
+
+ private String currentNode;
+
+ public UserContainer(User user)
+ {
+ this.username = user.getUserName();
+ }
+
+ public UserContainer(String username, String password, Map profileMap, List roles)
+ {
+ this.username = username;
+ this.password = password;
+ this.profileMap = profileMap;
+ this.roles = roles;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ public String getProcessId()
+ {
+ return processId;
+ }
+
+ public void setProcessId(String processId)
+ {
+ this.processId = processId;
+ }
+
+ public Map getProfileMap()
+ {
+ return profileMap;
+ }
+
+ public void setProfileMap(Map profileMap)
+ {
+ this.profileMap = profileMap;
+ }
+
+ public List getRoles()
+ {
+ return roles;
+ }
+
+ public void setRoles(List roles)
+ {
+ this.roles = roles;
+ }
+
+ public String getCurrentNode()
+ {
+ return currentNode;
+ }
+
+ public void setCurrentNode(String currentNode)
+ {
+ this.currentNode = currentNode;
+ }
+
+ public String getEmail()
+ {
+ return (String) this.profileMap.get(User.INFO_USER_EMAIL_REAL);
+ }
+
+ public String getRegistrationDate(){
+ return (String) this.profileMap.get(User.INFO_USER_REGISTRATION_DATE);
+ }
+}
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailService.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailService.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailService.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services.workflow;
+
+import java.util.Locale;
+
+import org.jboss.portal.identity.User;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ValidateEmailService
+{
+
+ boolean validateEmail(String processId, String registrationHash);
+
+ String changeEmail(User user, String email, Locale locale);
+}
+
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailServiceImpl.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailServiceImpl.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailServiceImpl.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.services.workflow;
+
+import java.io.InputStream;
+import java.util.Locale;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.core.identity.services.IdentityConstants;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.jems.as.JNDI;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.workflow.service.WorkflowService;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ValidateEmailServiceImpl extends AbstractJBossService implements
ValidateEmailService
+{
+ private static final Logger log = Logger.getLogger(ValidateEmailService.class);
+
+ private WorkflowService workflowService = null;
+
+ private String processName = "jbp_identity_validate_email";
+
+ private String processFile = "conf/processes/" + processName +
".xml";
+
+ private boolean overwrite = false;
+
+ private JNDI.Binding jndiBinding;
+
+ private String jndiName = null;
+
+ public void startService() throws Exception
+ {
+ super.startService();
+
+ if (this.jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ InputStream is = null;
+ JbpmContext jbpmContext = null;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ ProcessDefinition processDefinition =
jbpmContext.getGraphSession().findLatestProcessDefinition(
+ this.processName);
+ if (processDefinition == null)
+ {
+ processDefinition = ProcessDefinition.parseXmlResource(processFile);
+ jbpmContext.deployProcessDefinition(processDefinition);
+ }
+ else
+ {
+ // A process definition already exists....should deploy a new version
+ // of the definition if overwrite is true
+ ProcessDefinition fromConfig =
ProcessDefinition.parseXmlResource(processFile);
+ if (this.overwrite)
+ {
+ // If the two of them are not same, create a new version
+ // of this process definition
+ jbpmContext.deployProcessDefinition(fromConfig);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ //
+ this.stopService();
+
+ //
+ throw e;
+ }
+ finally
+ {
+ IOTools.safeClose(is);
+ IOTools.safeClose(jbpmContext);
+ }
+ }
+
+ public void stopService() throws Exception
+ {
+ super.stopService();
+
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ }
+
+ /** @return */
+ public WorkflowService getWorkflowService()
+ {
+ return this.workflowService;
+ }
+
+ /** @param workflowService */
+ public void setWorkflowService(WorkflowService workflowService)
+ {
+ this.workflowService = workflowService;
+ }
+
+ /** @return */
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ /** @param jndiName */
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ /*
+ * Create new changeEmail request
+ */
+ public String changeEmail(User user, String email, Locale locale)
+ {
+ JbpmContext jbpmContext = null;
+ ProcessInstance processInstance = null;
+ // String registrationHash = this.hashGen(); - generated when sending email
+ boolean success = false;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+ processInstance = jbpmContext.newProcessInstance(this.processName);
+ Token token = processInstance.getRootToken();
+
+
processInstance.getContextInstance().setVariable(IdentityConstants.VARIABLE_USER, new
UserContainer(user));
+
processInstance.getContextInstance().setVariable(IdentityConstants.VARIABLE_EMAIL,
email);
+
processInstance.getContextInstance().setVariable(IdentityConstants.VARIABLE_LOCALE,
locale);
+ processInstance.getContextInstance().setVariable(IdentityConstants.ACTION,
IdentityConstants.ACTION_CHANGE_EMAIL);
+
+ token.signal();
+ success = true;
+ }
+ catch (Exception e)
+ {
+ success = false;
+ log.error("Exception in Workflow", e);
+ // throw new WorkflowException(e);
+ }
+ finally
+ {
+ if (processInstance != null && success)
+ {
+ jbpmContext.save(processInstance);
+ }
+ IOTools.safeClose(jbpmContext);
+ }
+ // TODO
+ return IdentityConstants.REGISTRATION_PENDING;
+ }
+
+ public boolean validateEmail(String id, String registrationHash)
+ {
+ JbpmContext jbpmContext = null;
+ boolean success = false;
+ try
+ {
+ long processId = Long.valueOf(id).longValue();
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.getProcessInstance(processId);
+
+ if (processInstance != null)
+ {
+ Node n = processInstance.getRootToken().getNode();
+ if (n.getName().equals("validate_email"))
+ {
+ String hash = (String)
processInstance.getContextInstance().getVariable(IdentityConstants.VALIDATION_HASH);
+ if (registrationHash.equals(hash) && !processInstance.hasEnded())
+ {
+ Token token = processInstance.getRootToken();
+ String action = (String)
processInstance.getContextInstance().getVariable(IdentityConstants.ACTION);
+ // Processing email change request to transition changeEmail
+ if(IdentityConstants.ACTION_CHANGE_EMAIL.equals(action))
+ {
+ token.signal("changeEmail");
+ }
+ // Processing other requests to end state with ok
+ else
+ {
+ token.signal("ok");
+ }
+ success = true;
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("", e);
+ }
+ finally
+ {
+ IOTools.safeClose(jbpmContext);
+ }
+ return success;
+ }
+}
+
Property changes on: trunk/core-identity/src/main/org/jboss/portal/core/identity/ui
___________________________________________________________________
Name: svn:ignore
- faces
+ faces
register
Deleted:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/IdentityConstants.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/IdentityConstants.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/IdentityConstants.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -1,49 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.identity.ui;
-
-/**
- * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
- * @version $Revision$
- */
-public class IdentityConstants
-{
- public static final String HASH_SALT = "fuDrupRunEP2BRuspADr";
-
- public static final String SUBSCRIPTIONMODE = "subscriptionMode";
- public static final String SUBSCRIPTIONMODE_AUTOMATIC = "automatic";
- public static final String SUBSCRIPTIONMODE_EMAILVERIFICATION =
"emailVerification";
-
- public static final String VERIFICATION_ACTION = "validateEmail";
- public static final String VERIFICATION_ACTION_REGISTER = "register";
- public static final String VERIFICATION_ACTION_UPDATE_EMAIL = "update";
- public static final String VERIFICATION_ACTION_DELETE_USER = "delete";
-
- public static final String TEMPLATE_REGISTER_USER = "register";
- public static final String TEMPLATE_CHANGE_EMAIL = "changeEmail";
- public static final String TEMPLATE_LOST_PASSWORD = "lostPassword";
-
- public static final String USER_PROFILE_GENERATED_HASH =
"org.jboss.portal.core.identity.validation_hash";
- public static final String USER_PROFILE_NEW_EMAIL_ADDRESS =
"org.jboss.portal.core.identity.new_email";
-}
-
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -22,26 +22,20 @@
******************************************************************************/
package org.jboss.portal.core.identity.ui.actions;
-import java.awt.image.BufferedImage;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+
import javax.faces.application.FacesMessage;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.jboss.logging.Logger;
-import org.jboss.portal.core.identity.services.captcha.JCaptchaService;
-import org.jboss.portal.core.identity.ui.IdentityConstants;
+import org.jboss.portal.core.identity.services.workflow.RegistrationService;
import org.jboss.portal.core.identity.ui.IdentityUIUser;
import org.jboss.portal.core.identity.ui.common.IdentityUserBean;
-import org.jboss.portal.core.identity.ui.common.SendMailBean;
import org.jboss.portal.identity.User;
/**
@@ -52,23 +46,17 @@
{
/** . */
- private User user;
-
- /** . */
private List roles = new ArrayList();
/** . */
private IdentityUIUser uiUser = new IdentityUIUser();
/** . */
- private IdentityUserBean identityUserBean;
-
+ private RegistrationService registrationService;
+
/** . */
- private SendMailBean sendMailBean;
+ private IdentityUserBean identityUserBean;
- /** .*/
- private String subscriptionMode;
-
/** . */
private static final Logger log = Logger.getLogger(CreateUserAction.class);
@@ -82,19 +70,19 @@
this.uiUser = uiUser;
}
- public IdentityUserBean getIdentityUserBean()
+ public List getRoles()
{
- return identityUserBean;
+ return roles;
}
- public String getSubscriptionMode()
+ public void setRoles(List roles)
{
- return subscriptionMode;
+ this.roles = roles;
}
- public void setSubscriptionMode(String subscriptionMode)
+ public IdentityUserBean getIdentityUserBean()
{
- this.subscriptionMode = subscriptionMode;
+ return identityUserBean;
}
public void setIdentityUserBean(IdentityUserBean identityUserBean)
@@ -102,26 +90,16 @@
this.identityUserBean = identityUserBean;
}
- public List getRoles()
+ public RegistrationService getRegistrationService()
{
- return roles;
+ return registrationService;
}
- public void setRoles(List roles)
+ public void setRegistrationService(RegistrationService registrationService)
{
- this.roles = roles;
+ this.registrationService = registrationService;
}
- public SendMailBean getSendMailBean()
- {
- return sendMailBean;
- }
-
- public void setSendMailBean(SendMailBean sendMailBean)
- {
- this.sendMailBean = sendMailBean;
- }
-
public String register()
{
if (uiUser.getUsername() != null && uiUser.getPassword() != null)
@@ -131,11 +109,7 @@
try
{
Class registrationDateClass =
uiUser.getAttribute().getType("registrationdate");
-
- // Create user && assign roles
- user = identityUserBean.createUser(uiUser.getUsername(),
uiUser.getPassword(), this.roles);
-
- //
+
if (registrationDateClass.equals(Date.class))
{
uiUser.getAttribute().setValue("registrationdate", new Date());
@@ -149,44 +123,17 @@
log.warn(User.INFO_USER_REGISTRATION_DATE + " property is mapped in
not supported type: "
+ registrationDateClass.toString());
}
+
+ // Variables for RegisterService
+ String wUsername = uiUser.getUsername();
+ String wPassword = uiUser.getPassword();
+ List wRoles = roles;
+ Map wProfileMap =
this.identityUserBean.getProfileMap(uiUser.getAttribute().getProfileAttributes());
+ Locale wLocale =
FacesContext.getCurrentInstance().getViewRoot().getLocale();
+
+ String registrationStatus = this.registrationService.registerUser(wUsername,
wPassword, wProfileMap, wRoles, wLocale);
+ log.debug(registrationStatus);
- if (subscriptionMode != null
- &&
subscriptionMode.equals(IdentityConstants.SUBSCRIPTIONMODE_EMAILVERIFICATION))
- {
- Map mailMap = new HashMap();
- String hash = identityUserBean.hashGen();
-
- // Disable User
- uiUser.getAttribute().setValue("enabled", Boolean.FALSE);
-
- // TODO Store Hash
- // identityUserBean.setPropertyHash(user, hash);
-
- // TODO change IdentityCommandFactory
- String link = "http://localhost:8080/portal/";
- link += IdentityConstants.VERIFICATION_ACTION + "/";
- link += IdentityConstants.VERIFICATION_ACTION_REGISTER + "/";
- link += uiUser.getUsername() + "/";
- link += hash + "/";
- link += "default/default/wizardWindow_33";
-
- mailMap.put("to", (String)
uiUser.getAttribute().getValue("email").getObject());
- mailMap.put("username", uiUser.getUsername());
- mailMap.put("password", uiUser.getPassword());
- mailMap.put("activationLink", link);
-
- // Sending verification mail
- this.sendMailBean.sendMail("register", mailMap);
-
- }
- else
- {
- uiUser.getAttribute().setValue("enabled", Boolean.TRUE);
- }
-
- // Adding dynamically set properties
- identityUserBean.updateProfile(user,
uiUser.getAttribute().getProfileAttributes());
-
}
catch (Exception e)
{
@@ -199,9 +146,9 @@
FacesContext.getCurrentInstance().addMessage(null, new
FacesMessage("Missing required values."));
}
- // Clean up
-
- this.user = null;
+ /*
+ * Cleaning up
+ */
this.uiUser = new IdentityUIUser();
return "success";
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.identity.ui.actions;
-import java.util.HashMap;
import java.util.Map;
import javax.faces.application.FacesMessage;
@@ -30,10 +29,9 @@
import javax.faces.context.FacesContext;
import org.jboss.logging.Logger;
-import org.jboss.portal.core.identity.ui.IdentityConstants;
+import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
import org.jboss.portal.core.identity.ui.IdentityUIUser;
import org.jboss.portal.core.identity.ui.common.IdentityUserBean;
-import org.jboss.portal.core.identity.ui.common.SendMailBean;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.User;
@@ -58,9 +56,10 @@
/** . */
private IdentityUserBean identityUserBean;
- /** . */
- private SendMailBean sendMailBean;
+ /** . */
+ private ValidateEmailService validateEmailService;
+ /** . */
private static final Logger log = Logger.getLogger(EditProfileAction.class);
public EditProfileAction()
@@ -125,14 +124,14 @@
this.email = email;
}
- public SendMailBean getSendMailBean()
+ public ValidateEmailService getValidateEmailService()
{
- return sendMailBean;
+ return validateEmailService;
}
- public void setSendMailBean(SendMailBean sendMailBean)
+ public void setValidateEmailService(ValidateEmailService validateEmailService)
{
- this.sendMailBean = sendMailBean;
+ this.validateEmailService = validateEmailService;
}
public String editProfile()
@@ -205,45 +204,16 @@
public String changeEmail()
{
- String subscriptionMode =
FacesContext.getCurrentInstance().getExternalContext().getInitParameter(
- IdentityConstants.SUBSCRIPTIONMODE);
-
if (this.email != null)
{
try
{
User user = this.identityUserBean.findUserByUserName(this.currentUser);
- if (subscriptionMode != null
- &&
subscriptionMode.equals(IdentityConstants.SUBSCRIPTIONMODE_EMAILVERIFICATION))
- {
- Map mailMap = new HashMap();
- String hash = identityUserBean.hashGen();
- this.identityUserBean.setPropertyHash(user, hash);
- this.identityUserBean.setPropertyNewEmail(user, email);
-
- // Generate URL
- String link = "http://localhost:8080/portal/";
- link += IdentityConstants.VERIFICATION_ACTION + "/";
- link += IdentityConstants.VERIFICATION_ACTION_UPDATE_EMAIL+
"/";
- link += uiUser.getUsername() + "/";
- link += hash + "/";
- link += "default/default/wizardWindow_33";
-
- // TODO - get right Values
- mailMap.put("subject", "Confirm Email Change");
- mailMap.put("to", email); //(String)
uiUser.getAttribute().getValue("email").getObject());
- mailMap.put("from", "emuckenh(a)redhat.com");
- mailMap.put("emailDomain", "JBoss.org");
- mailMap.put("activationLink", link);
-
- this.sendMailBean.sendMail("changeEmail", mailMap);
- }
- else
- {
- HashMap profileMap = new HashMap();
- profileMap.put("email", email);
- this.identityUserBean.updateProfile(user, profileMap);
- }
+
+ // TODO status page
+ // TODO locale
+ String validationStatus = this.validateEmailService.changeEmail(user, email,
null);
+ log.debug(validationStatus);
}
catch (Exception e)
{
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -25,20 +25,17 @@
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
import org.jboss.logging.Logger;
+import org.jboss.portal.core.identity.services.IdentityMailService;
import org.jboss.portal.core.identity.ui.IdentityUIUser;
import org.jboss.portal.core.identity.ui.common.IdentityUserBean;
-import org.jboss.portal.core.identity.ui.common.SendMailBean;
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
@@ -61,22 +58,11 @@
private IdentityUserBean identityUserBean;
/** . */
- private SendMailBean sendMailBean;
+ private IdentityMailService identityMailService;
/** . */
- private Session session;
-
- /** . */
private static final Logger log = Logger.getLogger(LostPasswordAction.class);
- /**
- public LostPasswordAction()
- {
- SessionFactory sessionFactory = (SessionFactory) new InitialContext()
- .lookup("java:/portal/IdentitySessionFactory");
- session = sessionFactory.getCurrentSession();
- } */
-
public String getUsername()
{
return username;
@@ -107,14 +93,14 @@
this.identityUserBean = identityUserBean;
}
- public SendMailBean getSendMailBean()
+ public IdentityMailService getIdentityMailService()
{
- return sendMailBean;
+ return identityMailService;
}
- public void setSendMailBean(SendMailBean sendMailBean)
+ public void setIdentityMailService(IdentityMailService identityMailService)
{
- this.sendMailBean = sendMailBean;
+ this.identityMailService = identityMailService;
}
public String getPasswordCharacters()
@@ -184,7 +170,8 @@
{
// TODO enable update Password
// identityUserBean.updatePassword(user.getUserName(), newPassword);
- sendMailBean.sendMail("lostPassword", mailMap);
+ // TODO set Locale
+ identityMailService.sendMail("lostPassword", mailMap, new
Locale("en"));
}
catch (Exception e)
{
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -168,7 +168,8 @@
try
{
int offset = page > 0 ? ((page -1 ) * limit) : 0;
- members =
identityRoleBean.getMembershipModule().findRoleMembers(this.currentRole, offset, limit,
userNameFilter);
+ int limit1 = limit + 1;
+ members =
identityRoleBean.getMembershipModule().findRoleMembers(this.currentRole, offset, limit1,
userNameFilter);
}
catch (Exception e)
{
@@ -228,4 +229,16 @@
}
return "roleAdmin";
}
+
+ public String nextPage()
+ {
+ this.page++;
+ return "viewMembers";
+ }
+
+ public String prevPage()
+ {
+ this.page--;
+ return "viewMembers";
+ }
}
\ No newline at end of file
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -34,6 +34,7 @@
import javax.faces.model.ListDataModel;
import org.jboss.logging.Logger;
+import org.jboss.portal.core.identity.services.workflow.RegistrationService;
import org.jboss.portal.core.identity.ui.IdentityUIUser;
import org.jboss.portal.core.identity.ui.common.IdentityRoleBean;
import org.jboss.portal.core.identity.ui.common.IdentityUserBean;
@@ -77,6 +78,9 @@
/** . */
private IdentityRoleBean identityRoleBean;
+
+ /** . */
+ private RegistrationService registrationService;
/** . */
private static final Logger log = Logger.getLogger(UserAdministrationBean.class);
@@ -161,6 +165,16 @@
this.identityRoleBean = identityRoleBean;
}
+ public RegistrationService getRegistrationService()
+ {
+ return registrationService;
+ }
+
+ public void setRegistrationService(RegistrationService registrationService)
+ {
+ this.registrationService = registrationService;
+ }
+
public String searchUsers()
{
if (this.searchString != null)
@@ -168,7 +182,8 @@
try
{
int offset = page > 0 ? ((page - 1) * limit) : 0;
- this.userList = new
ListDataModel(identityUserBean.findUsersFilteredByUserName(searchString, offset, limit));
+ int limit1 = limit + 1;
+ this.userList = new
ListDataModel(identityUserBean.findUsersFilteredByUserName(searchString, offset,
limit1));
}
catch (IllegalArgumentException e)
{
@@ -228,6 +243,14 @@
}
return "userAdmin";
}
+
+ public List getPendingUsers()
+ {
+ List list = new ArrayList();
+ if ( this.registrationService != null)
+ list = this.registrationService.getPendingUsers();
+ return list;
+ }
public String deleteUser()
{
@@ -249,6 +272,7 @@
{
User user = identityUserBean.findUserByUserName(this.uiUser.getUsername());
identityUserBean.getUserModule().removeUser(user.getId());
+ return this.searchUsers();
}
catch (Exception e)
{
@@ -256,5 +280,39 @@
}
return "userAdmin";
}
+
+ public String nextPage()
+ {
+ this.page++;
+ this.searchUsers();
+ return "userAdmin";
+ }
+
+ public String prevPage()
+ {
+ this.page--;
+ this.searchUsers();
+ return "userAdmin";
+ }
+
+ public String approveRegistration()
+ {
+ ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
+ Map params = ectx.getRequestParameterMap();
+ String processId = (String) params.get("processId");
+ String action = (String) params.get("action");
+ if (processId != null && action != null)
+ {
+ if (action.equals("approve"))
+ {
+ this.registrationService.approve(processId, true);
+ }
+ else if (action.equals("reject"))
+ {
+ this.registrationService.approve(processId, false);
+ }
+ }
+ return "pendingUsers";
+ }
}
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -22,26 +22,19 @@
******************************************************************************/
package org.jboss.portal.core.identity.ui.common;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.jboss.logging.Logger;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.core.identity.ui.IdentityConstants;
import org.jboss.portal.core.identity.ui.IdentityUIUser;
import org.jboss.portal.core.identity.ui.UIAttribute;
-import org.jboss.portal.core.identity.ui.UIRole;
import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.MembershipModule;
import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
import org.jboss.portal.identity.UserProfileModule;
@@ -60,9 +53,6 @@
private UserProfileModule userProfileModule;
/** . */
- private IdentityRoleBean identityRoleBean;
-
- /** . */
private MetaDataServiceBean metaDataService;
/** . */
@@ -98,46 +88,45 @@
this.metaDataService = metaDataService;
}
- public IdentityRoleBean getIdentityRoleBean()
+ /*
+ * converts the dynamic attribute Map to a map concerning the identity service -
UserProfileModule
+ */
+ public Map getProfileMap(Map attributeMap)
{
- return identityRoleBean;
+ Map profileMap = new HashMap();
+ Set attributeSet = attributeMap.keySet();
+ Iterator i = attributeSet.iterator();
+
+ while(i.hasNext())
+ {
+ String key = (String) i.next();
+ Object value = attributeMap.get(key);
+ UIAttribute uiAttribute = (UIAttribute)
this.metaDataService.getValue(key).getObject();
+ if ( uiAttribute != null)
+ {
+ profileMap.put(uiAttribute.getIdentifier(), value);
+ }
+ }
+ return profileMap;
}
-
- public void setIdentityRoleBean(IdentityRoleBean identityRoleBean)
+
+ public void updateProfile(User user, Map attributeMap)
{
- this.identityRoleBean = identityRoleBean;
- }
-
- public User createUser(String username, String password, List roles) throws
RuntimeException, IdentityException
- {
- // Create user
- User user = userModule.createUser(username, password);
- // Set membership
- identityRoleBean.assignRoles(user, roles);
- return user;
- }
-
- public void updateProfile(User user, HashMap profileMap)
- {
- Set profileSet = profileMap.keySet();
- Iterator i = profileSet.iterator();
-
- while (i.hasNext())
+ Map profileMap = this.getProfileMap(attributeMap);
+ Iterator i = profileMap.keySet().iterator();
+
+ while(i.hasNext())
{
String key = (String) i.next();
Object value = profileMap.get(key);
- UIAttribute uiAttribute = (UIAttribute)
this.metaDataService.getValue(key).getObject();
- if (uiAttribute != null)
+ try
{
- try
- {
- userProfileModule.setProperty(user, uiAttribute.getIdentifier(), value);
- }
- catch (IdentityException e)
- {
- e.printStackTrace();
- }
+ this.userProfileModule.setProperty(user, key, value);
}
+ catch (Exception e)
+ {
+ log.error("updateProfile failed", e);
+ }
}
}
@@ -184,43 +173,4 @@
UIAttribute uiAttribute = (UIAttribute)
this.metaDataService.getValue(propertyName).getObject();
return this.userProfileModule.getProperty(user, uiAttribute.getIdentifier());
}
-
-
- // Used to save the hash into the properties of the user
- public void setPropertyHash(User user, String hash) throws IllegalArgumentException,
IdentityException
- {
- this.userProfileModule.setProperty(user,
IdentityConstants.USER_PROFILE_GENERATED_HASH, hash);
- }
-
- // Stores the new email address until it is validated
- public void setPropertyNewEmail(User user, String email) throws
IllegalArgumentException, IdentityException
- {
- this.userProfileModule.setProperty(user,
IdentityConstants.USER_PROFILE_NEW_EMAIL_ADDRESS, email);
- }
-
- // generating a random hash
- public String hashGen() {
- try {
- SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
-
- byte[] bytes = new byte[512];
- secureRandom.nextBytes(bytes);
-
- double rand = secureRandom.nextDouble();
- long time = System.currentTimeMillis();
- String salt = IdentityConstants.HASH_SALT;
-
- StringBuffer buffer = new StringBuffer();
- buffer.append(rand);
- buffer.append(salt);
- buffer.append(time);
-
-
- return Tools.md5AsHexString(buffer.toString());
- } catch (NoSuchAlgorithmException e)
- {
- log.error("No Such Algorithm exists " + e);
- }
- return null;
- }
}
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -23,10 +23,8 @@
package org.jboss.portal.core.identity.ui.common;
import java.util.HashMap;
-import java.util.Set;
import org.jboss.portal.common.p3p.P3PConstants;
-import org.jboss.portal.core.identity.ui.IdentityConstants;
import org.jboss.portal.core.identity.ui.UIAttribute;
import org.jboss.portal.faces.el.PropertyValue;
import org.jboss.portal.faces.el.dynamic.DynamicBean;
@@ -48,10 +46,6 @@
uiEmail.setValidator("EmailValidator");
uiEmail.setRequired(true);
- // Required
- UIAttribute uiHash = new UIAttribute(IdentityConstants.USER_PROFILE_GENERATED_HASH,
"org_jboss_identity_hash");
- UIAttribute uiNewEmail = new
UIAttribute(IdentityConstants.USER_PROFILE_NEW_EMAIL_ADDRESS,
"org_jboss_identity_new_email");
-
UIAttribute uiGivenName = new UIAttribute(P3PConstants.INFO_USER_NAME_GIVEN,
"givenname");
UIAttribute uiFamilyName = new UIAttribute(P3PConstants.INFO_USER_NAME_FAMILY,
"familyname");
UIAttribute uiSkype = new UIAttribute(User.INFO_USER_IM_SKYPE, "skype");
@@ -76,8 +70,6 @@
UIAttribute uiEnabled = new UIAttribute(User.INFO_USER_ENABLED,
"enabled");
this.addToMap(uiEmail);
- this.addToMap(uiHash);
- this.addToMap(uiNewEmail);
this.addToMap(uiGivenName);
this.addToMap(uiFamilyName);
Deleted:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/SendMailBean.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/SendMailBean.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/SendMailBean.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -1,166 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.identity.ui.common;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import javax.faces.context.FacesContext;
-
-import org.jboss.logging.Logger;
-import org.jboss.portal.core.identity.ui.IdentityConstants;
-import org.jboss.portal.core.modules.MailModule;
-
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-
-/**
- * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
- * @version $Revision$
- */
-public class SendMailBean
-{
-
- /** . */
- private Map mailData = new HashMap();
-
- /** . */
- private Locale locale;
-
- /** . */
- private String emailText = null;
-
- /** . */
- private String emailDomain;
-
- /** . */
- private String emailFrom;
-
- /** . */
- private String templateLocation;
-
- /** . */
- private MailModule mailModule;
-
- /** . */
- private static final Logger log = Logger.getLogger(SendMailBean.class);
-
- public String getEmailDomain()
- {
- return emailDomain;
- }
-
- public void setEmailDomain(String emailDomain)
- {
- this.emailDomain = emailDomain;
- }
-
- public String getEmailFrom()
- {
- return emailFrom;
- }
-
- public void setEmailFrom(String emailFrom)
- {
- this.emailFrom = emailFrom;
- }
-
- public MailModule getMailModule()
- {
- return mailModule;
- }
-
- public void setMailModule(MailModule mailModule)
- {
- this.mailModule = mailModule;
- }
-
- public void sendMail(String templateLocation, Map mailData) throws IOException,
TemplateException
- {
- this.templateLocation = templateLocation;
- this.mailData = mailData;
- this.locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
- this.mailData.put("emailDomain", emailDomain);
-
- ResourceBundle bundle = ResourceBundle.getBundle("Identity", locale);
-
- String subject = null;
- String to = (String) mailData.get("to");
-
- if (IdentityConstants.TEMPLATE_REGISTER_USER.equals(templateLocation))
- {
- subject = bundle.getString("IDENTITY_MAIL_SUBJECT_REGISTER");
- } else if (IdentityConstants.TEMPLATE_CHANGE_EMAIL.equals(templateLocation))
- {
- subject = bundle.getString("IDENTITY_MAIL_SUBJECT_CHANGE_EMAIL");
- } else if (IdentityConstants.TEMPLATE_LOST_PASSWORD.equals(templateLocation))
- {
- subject = bundle.getString("IDENTITY_MAIL_SUBJECT_LOST_PASSWORD");
- } else
- {
- throw new IllegalArgumentException("unknown template.");
- }
-
- // Generating message
- this.generateEmailText();
-
- // Sending mail
- // mailModule.send(emailFrom, to , subject, emailText);
- log.debug(this.emailText);
- }
-
- private void generateEmailText() throws IOException, TemplateException
- {
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- URL config = tcl.getResource("templates/" + this.templateLocation +
"/emailTemplate_" + locale.getLanguage() + "_" + locale.getCountry() +
".tpl");
- if (config == null)
- {
- config = tcl.getResource("templates/" + this.templateLocation +
"/emailTemplate_" + locale.getLanguage() + ".tpl");
- }
- if (config == null)
- {
- config = tcl.getResource("templates/" + this.templateLocation +
"/emailTemplate.tpl");
- }
- if (config == null)
- {
- throw new FileNotFoundException("Cannot load a suitable emailTemplate.tpl
in templates/"
- + this.templateLocation);
- }
- InputStream in = config.openStream();
- Template tpl = new Template("emailTemplate", new InputStreamReader(in),
new Configuration());
- StringWriter out = new StringWriter();
- tpl.process(this.mailData, out);
- out.close();
-
- this.emailText = out.toString();
- }
-}
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletDelegatingPropertyResolver.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletDelegatingPropertyResolver.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletDelegatingPropertyResolver.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,431 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.ui.faces;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.PropertyResolver;
+import javax.portlet.PortletPreferences;
+import javax.portlet.ReadOnlyException;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.reflect.Modifier;
+import org.jboss.portal.faces.el.PropertyValue;
+import org.jboss.portal.faces.el.decorator.BeanDecorator;
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PortletDelegatingPropertyResolver extends PropertyResolver
+{
+
+ /** . */
+ private PropertyResolver delegate;
+
+ /** . */
+ private volatile Map decoratorMap = new HashMap();
+
+ /** .*/
+ private static final Logger log =
Logger.getLogger(PortletDelegatingPropertyResolver.class);
+
+ public PortletDelegatingPropertyResolver(PropertyResolver delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public Class getType(Object base, int index) throws EvaluationException,
PropertyNotFoundException
+ {
+ if ( base instanceof PortletPreferences)
+ {
+ throw new PropertyNotFoundException("PortletPreferences can not be accessed
via an index");
+ } else {
+ return delegate.getType(base, index);
+ }
+ }
+
+ public Class getType(Object base, Object property) throws EvaluationException,
PropertyNotFoundException
+ {
+ if (base instanceof PortletPreferences)
+ {
+ return String.class;
+ }
+ else
+ // See if the object can handle itself the property
+ if (base instanceof DynamicBean)
+ {
+ DynamicBean dynamicBean = (DynamicBean)base;
+ Class type = dynamicBean.getType(property);
+ if (type != null)
+ {
+ return type;
+ }
+ }
+
+ //
+ GetTypeBeanAction beanAction = new GetTypeBeanAction(base, property);
+ if (resolveAction(base.getClass(), beanAction))
+ {
+ return beanAction.type;
+ }
+
+ //
+ if (property instanceof String)
+ {
+ try
+ {
+ Field f = base.getClass().getField((String)property);
+ if (Modifier.isReadableProperty(f))
+ {
+ return f.getType();
+ }
+ }
+ catch (NoSuchFieldException ignore)
+ {
+ }
+ }
+
+ //
+ if (delegate != null)
+ {
+ return delegate.getType(base, property);
+ }
+
+ //
+ throw createPNFE(base, property);
+ }
+
+ public Object getValue(Object base, int index) throws EvaluationException,
PropertyNotFoundException
+ {
+ if (base instanceof PortletPreferences)
+ {
+ throw new PropertyNotFoundException("PortletPreferences can not be accessed
via an index");
+ }
+ else
+ {
+ return delegate.getValue(base, index);
+ }
+ }
+
+ public Object getValue(Object base, Object property) throws EvaluationException,
PropertyNotFoundException
+ {
+ if ( base instanceof PortletPreferences)
+ {
+ PortletPreferences preferences = (PortletPreferences) base;
+ return (preferences.getValue((String) property, null));
+ }
+ // See if the object can handle itself the property
+ if (base instanceof DynamicBean)
+ {
+ DynamicBean dynamicBean = (DynamicBean)base;
+ PropertyValue value = dynamicBean.getValue(property);
+ if (value != null)
+ {
+ return value.getObject();
+ }
+ }
+
+ //
+ GetValueBeanAction beanAction = new GetValueBeanAction(base, property);
+ if (resolveAction(base.getClass(), beanAction))
+ {
+ return beanAction.value.getObject();
+ }
+
+
+ //
+ if (property instanceof String)
+ {
+ try
+ {
+ String test = null;
+ if ( base instanceof HashSet)
+ {
+ test = "ok";
+ }
+ Field f = base.getClass().getField((String)property);
+ if (Modifier.isReadableProperty(f))
+ {
+ return f.get(base);
+ }
+ }
+ catch (NoSuchFieldException ignore)
+ {
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("Was not able to read the field " + property + " of
object " + base + " with class " + base.getClass().getName());
+ }
+ }
+
+ //
+ if (delegate != null)
+ {
+ return delegate.getValue(base, property);
+ }
+
+ //
+ throw createPNFE(base, property);
+ }
+
+ public boolean isReadOnly(Object base, int index) throws EvaluationException,
PropertyNotFoundException
+ {
+ if( base instanceof PortletPreferences)
+ {
+ throw new PropertyNotFoundException("PortletPreferences can not be accessed
via an index");
+ }
+ else
+ {
+ return delegate.isReadOnly(base, index);
+ }
+ }
+
+ public boolean isReadOnly(Object base, Object property) throws EvaluationException,
PropertyNotFoundException
+ {
+ if ( base instanceof PortletPreferences)
+ {
+ PortletPreferences preferences = (PortletPreferences) base;
+ return preferences.isReadOnly((String) property);
+ }
+ else
+ {
+ return delegate.isReadOnly(base, property);
+ }
+ }
+
+ public void setValue(Object base, int index, Object value) throws EvaluationException,
PropertyNotFoundException
+ {
+ if (base instanceof PortletPreferences)
+ {
+ throw new PropertyNotFoundException("PortletPreferces can not be accessed
via an index");
+ }
+ else
+ {
+ delegate.setValue(base, index, value);
+ }
+
+ }
+
+ public void setValue(Object base, Object property, Object value) throws
EvaluationException, PropertyNotFoundException
+ {
+ if (base instanceof PortletPreferences)
+ {
+ // TODO handle string array
+ PortletPreferences preferences = (PortletPreferences) base;
+ try
+ {
+ preferences.setValue((String) property, (String) value);
+ }
+ catch (ReadOnlyException e)
+ {
+ log.error("PortletPreference "+ (String) property +" read
only", e);
+ }
+ }
+ // See if the object can handle itself the property
+ if (base instanceof DynamicBean)
+ {
+ DynamicBean dynamic = (DynamicBean)base;
+ if (dynamic.setValue(property, value))
+ {
+ return;
+ }
+ }
+
+ //
+ SetValueBeanAction beanAction = new SetValueBeanAction(base, property, value);
+ if (resolveAction(base.getClass(), beanAction))
+ {
+ return;
+ }
+
+ //
+ if (property instanceof String)
+ {
+ try
+ {
+ Field f = base.getClass().getField((String)property);
+ if (Modifier.isWritableProperty(f))
+ {
+ f.set(base, value);
+ return;
+ }
+ }
+ catch (NoSuchFieldException ignore)
+ {
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("Was not able to write the field " + property + " of
object " + base + " with class " + base.getClass().getName());
+ }
+ }
+
+ //
+ if (delegate != null)
+ {
+ delegate.setValue(base, property, value);
+ return;
+ }
+
+ //
+ throw createPNFE(base, property);
+
+ }
+
+ public final synchronized void registerDecorator(Class clazz, BeanDecorator
decorator)
+ {
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (decorator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Map copy = new HashMap(decoratorMap);
+ copy.put(clazz.getName(), decorator);
+ decoratorMap = copy;
+ log.debug("Added bean decorator " + clazz.getName() + " in resolver
map");
+ }
+
+ private static interface BeanAction
+ {
+ boolean execute(BeanDecorator decorator);
+ }
+
+ private abstract static class AbstractBeanAction implements BeanAction
+ {
+
+ /** . */
+ protected final Object base;
+
+ /** . */
+ protected final Object property;
+
+ public AbstractBeanAction(Object base, Object property)
+ {
+ this.base = base;
+ this.property = property;
+ }
+ }
+
+ private static class GetTypeBeanAction extends AbstractBeanAction
+ {
+
+ /** . */
+ private Class type;
+
+ public GetTypeBeanAction(Object base, Object property)
+ {
+ super(base, property);
+ }
+
+ public boolean execute(BeanDecorator decorator)
+ {
+ type = decorator.getType(base, property);
+ return type != null;
+ }
+ }
+
+ private static class GetValueBeanAction extends AbstractBeanAction
+ {
+
+ /** . */
+ private PropertyValue value;
+
+ public GetValueBeanAction(Object base, Object property)
+ {
+ super(base, property);
+ }
+
+ public boolean execute(BeanDecorator decorator)
+ {
+ value = decorator.getValue(base, property);
+ return value != null;
+ }
+ }
+
+ private static class SetValueBeanAction extends AbstractBeanAction
+ {
+
+ /** . */
+ private Object value;
+
+ public SetValueBeanAction(Object base, Object property, Object value)
+ {
+ super(base, property);
+ this.value = value;
+ }
+
+ public boolean execute(BeanDecorator decorator)
+ {
+ return decorator.setValue(base, property, value);
+ }
+ }
+
+ private boolean resolveAction(Class clazz, BeanAction action)
+ {
+ BeanDecorator decorator = (BeanDecorator)decoratorMap.get(clazz.getName());
+ if (decorator != null)
+ {
+ if (action.execute(decorator))
+ {
+ return true;
+ }
+ }
+ Class[] itfs = clazz.getInterfaces();
+ for (int i = 0; i < itfs.length; i++)
+ {
+ Class itf = clazz.getInterfaces()[i];
+ if (resolveAction(itf, action))
+ {
+ return true;
+ }
+ }
+ Class superClass = clazz.getSuperclass();
+ if (superClass != null)
+ {
+ if (resolveAction(superClass, action))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private PropertyNotFoundException createPNFE(Object base, int index)
+ {
+ return createPNFE(base, "[" + index + "]");
+ }
+
+ private PropertyNotFoundException createPNFE(Object base, Object propertyName)
+ {
+ return new PropertyNotFoundException("Property " + propertyName + "
on object " + base + " was not found");
+ }
+}
\ No newline at end of file
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletVariableResolver.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletVariableResolver.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/PortletVariableResolver.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,117 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.identity.ui.faces;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.VariableResolver;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+
+
+import org.jboss.logging.Logger;
+
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PortletVariableResolver extends VariableResolver
+{
+ /** . */
+ private VariableResolver delegate;
+
+ /** . */
+ private final static String PORTLET_CONFIG = "portletConfig";
+
+ /** . */
+ private final static String PORTLET_SESSION_SCOPE = "sessionPortletScope";
+
+ /** . */
+ private final static String PORTLET_APPLICATION_SCOPE =
"portletApplicationScope";
+
+ /** . */
+ private final static String PORTLET_PREFERENCE_VALUE =
"portletPreferenceValue";
+
+ /** . */
+ private final static String PORTLET_PREFERENCE_VALUES =
"portletPreferenceValues";
+
+ /** .*/
+ private static final Logger log = Logger.getLogger(PortletVariableResolver.class);
+
+ public PortletVariableResolver(VariableResolver delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public Object resolveVariable(FacesContext facesContext, String variable) throws
EvaluationException
+ {
+ ExternalContext ectx = facesContext.getExternalContext();
+ /**
+ * TODO
+ * portletConfig and test if portletApplicationScope is resolved correctly
+ */
+ if (PORTLET_SESSION_SCOPE.equals(variable))
+ {
+ return ectx.getSessionMap();
+ }
+ else if (PORTLET_APPLICATION_SCOPE.equals(variable))
+ {
+ return ectx.getApplicationMap();
+ }
+ else if (PORTLET_PREFERENCE_VALUE.equals(variable))
+ {
+ return getValueMap(ectx);
+ }
+ else if (PORTLET_PREFERENCE_VALUES.equals(variable))
+ {
+ PortletRequest request = (PortletRequest) ectx.getRequest();
+ return request.getPreferences().getMap();
+ }
+ return delegate.resolveVariable(facesContext, variable);
+ }
+
+ private Map getValueMap(ExternalContext ectx)
+ {
+ Map map = new HashMap();
+ PortletRequest request = (PortletRequest) ectx.getRequest();
+ Enumeration en = request.getPreferences().getNames();
+
+ while (en.hasMoreElements())
+ {
+ String key = (String) en.nextElement();
+ String value = request.getPreferences().getValue(key, null);
+ if (value != null)
+ {
+ map.put(key, value);
+ }
+ }
+ return map;
+ }
+
+}
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CaptchaValidator.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CaptchaValidator.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CaptchaValidator.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -42,14 +42,9 @@
Boolean tester = Boolean.FALSE;
PortletRequest portletRequest = (PortletRequest)
context.getExternalContext().getRequest();
String captchaId = portletRequest.getRequestedSessionId();
- try
- {
- tester = JCaptchaService.getInstance().validateResponseForID(captchaId, (String)
value);
- }
- catch (Exception e)
- {
- throw new ValidatorException(new FacesMessage("Error while
validating."));
- }
+
+ tester = JCaptchaService.validateResponseForID(captchaId, (String) value);
+
if ( tester.equals(Boolean.FALSE))
{
throw new ValidatorException(new FacesMessage("captcha incorrect."));
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -29,7 +29,6 @@
import javax.faces.validator.ValidatorException;
import javax.portlet.PortletContext;
-import org.jboss.logging.Logger;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
@@ -49,9 +48,6 @@
/** . */
private User user;
- /** . */
- private static final Logger log = Logger.getLogger(CurrentPasswordValidator.class);
-
public void validate(FacesContext context, UIComponent component, Object value) throws
ValidatorException
{
PortletContext portletContext = (PortletContext)
context.getExternalContext().getContext();
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -47,7 +47,7 @@
throw new IllegalArgumentException("The value must be a String");
}
- if (!Pattern.matches(this.EMAIL_VALIDATION, (String) value))
+ if (!Pattern.matches(EMAIL_VALIDATION, (String) value))
{
throw new ValidatorException(new FacesMessage("Invalid EMail
Address"));
}
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/UsernameValidator.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/UsernameValidator.java 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/UsernameValidator.java 2007-08-27
19:20:51 UTC (rev 8051)
@@ -30,7 +30,6 @@
import javax.faces.validator.ValidatorException;
import javax.portlet.PortletContext;
-import org.jboss.logging.Logger;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
@@ -49,12 +48,8 @@
/** . */
private UserModule userModule;
- /** . */
- private static final Logger log = Logger.getLogger(UsernameValidator.class);
-
public void validate(FacesContext context, UIComponent component, Object value) throws
ValidatorException
{
- User u = null;
String username = (String) value;
PortletContext portletContext = (PortletContext)
context.getExternalContext().getContext();
userModule = (UserModule) portletContext.getAttribute("UserModule");
@@ -63,8 +58,8 @@
{
try
{
- u = userModule.findUserByUserName(username);
- throw new ValidatorException(new FacesMessage("This username is already
in use."));
+ User u = userModule.findUserByUserName(username);
+ throw new ValidatorException(new FacesMessage("This username is already
in use:"+ u.getUserName()));
}
catch (NoSuchUserException e)
{
Modified:
trunk/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -31,8 +31,23 @@
<depends
optional-attribute-name="ServerConfig"
proxy-type="attribute">portal:service=ServerConfig</depends>
+ <depends
+ optional-attribute-name="RegistrationService"
+
proxy-type="attribute">portal:service=RegistrationService,type=Workflow</depends>
+ <depends
+ optional-attribute-name="ValidateEmailService"
+
proxy-type="attribute">portal:service=ValidateEmailService,type=Workflow</depends>
</mbean>
+ <mbean
+ code="org.jboss.portal.core.identity.services.IdentityMailServiceImpl"
+ name="portal:service=IdentityMailService,type=Mail"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute
name="JNDIName">java:portal/IdentityMailService</attribute>
+ </mbean>
+
<mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
name="portal:commandFactory=Delegate,path=validateEmail"
@@ -47,6 +62,33 @@
optional-attribute-name="DelegateFactory"
proxy-type="attribute">portal:commandFactory=IdentityUI</depends>
</mbean>
+
+ <mbean
+
code="org.jboss.portal.core.identity.services.workflow.ApproveRegistration"
+ name="portal:service=RegistrationService,type=Workflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="WorkflowService"
proxy-type="attribute">
+ portal:service=Workflow,type=WorkflowService
+ </depends>
+ <depends optional-attribute-name="ValidateEmailService"
+
proxy-type="attribute">portal:service=ValidateEmailService,type=Workflow</depends>
+ <attribute
name="JNDIName">java:portal/RegistrationService</attribute>
+ </mbean>
+
+ <mbean
+
code="org.jboss.portal.core.identity.services.workflow.ValidateEmailServiceImpl"
+ name="portal:service=ValidateEmailService,type=Workflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="WorkflowService"
proxy-type="attribute">
+ portal:service=Workflow,type=WorkflowService
+ </depends>
+ <attribute
name="JNDIName">java:portal/ValidateEmailService</attribute>
+ </mbean>
+
<!--
<mbean
code="org.jboss.portal.core.identity.services.IdentityURLFactory"
Added:
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validate_email.xml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validate_email.xml
(rev 0)
+++
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validate_email.xml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE process-definition PUBLIC
+ "-//jBpm/jBpm Mapping DTD 2.0//EN"
+ "http://jbpm.org/dtd/processdefinition-2.0.dtd">
+
+<process-definition name="jbp_identity_validate_email">
+ <start-state>
+ <transition to="validate_email">
+ <action
class="org.jboss.portal.core.identity.services.workflow.SendValidationMailAction"/>
+ </transition>
+ </start-state>
+ <state name="validate_email">
+ <create-timer name="time_to_expire" duedate="24 hours"
transition="timedOut" />
+ <transition name="ok" to="validated"/>
+ <transition name="timedOut" to="expired"/>
+ <transition name="changeEmail" to="validated">
+ <!-- call action and update email -->
+ </transition>
+ </state>
+ <end-state name="validated"/>
+ <end-state name="expired"/>
+</process-definition>
\ No newline at end of file
Added:
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_approval_workflow.xml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_approval_workflow.xml
(rev 0)
+++
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_approval_workflow.xml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE process-definition PUBLIC
+ "-//jBpm/jBpm Mapping DTD 2.0//EN"
+ "http://jbpm.org/dtd/processdefinition-2.0.dtd">
+
+<process-definition name="jbp_identity_validation_approval_workflow">
+ <start-state>
+ <transition to="emailValidation"/>
+ </start-state>
+ <process-state name="emailValidation">
+ <sub-process name="jbp_identity_validate_email"/>
+ <variable name="user" access="read"
mapped-name="user"/>
+ <variable name="email" access="read"
mapped-name="email"/>
+ <variable name="locale" access="read"
mapped-name="locale"/>
+ <variable name="action" access="read"
mapped-name="action"/>
+ <transition name="validated" to="adminApproval"/>
+ <transition name="expired" to="end"/>
+ </process-state>
+ <state name="adminApproval">
+ <transition name="validated" to="end">
+ <action
class="org.jboss.portal.core.identity.services.workflow.CreateUserAction"/>
+ </transition>
+ <transition name="rejected" to="end"/>
+ </state>
+ <end-state name="end"/>
+</process-definition>
\ No newline at end of file
Copied: trunk/core-identity/src/resources/portal-identity-sar/conf/templates (from rev
8017, trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/templates)
Modified:
trunk/core-identity/src/resources/portal-identity-sar/conf/templates/changeEmail/emailTemplate.tpl
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/templates/changeEmail/emailTemplate.tpl 2007-08-21
16:55:37 UTC (rev 8017)
+++
trunk/core-identity/src/resources/portal-identity-sar/conf/templates/changeEmail/emailTemplate.tpl 2007-08-27
19:20:51 UTC (rev 8051)
@@ -1,4 +1,4 @@
-hello
+Hello,
you tried to change your email address on ${emailDomain}
Deleted:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity.properties
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity.properties 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity.properties 2007-08-27
19:20:51 UTC (rev 8051)
@@ -1,105 +0,0 @@
-################################################################################
-# JBoss, a division of Red Hat #
-# Copyright 2006, Red Hat Middleware, LLC, and individual #
-# contributors as indicated by the @authors tag. See the #
-# copyright.txt in the distribution for a full listing of #
-# individual contributors. #
-# #
-# This is free software; you can redistribute it and/or modify it #
-# under the terms of the GNU Lesser General Public License as #
-# published by the Free Software Foundation; either version 2.1 of #
-# the License, or (at your option) any later version. #
-# #
-# This software is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
-# Lesser General Public License for more details. #
-# #
-# You should have received a copy of the GNU Lesser General Public #
-# License along with this software; if not, write to the Free #
-# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #
-# 02110-1301 USA, or see the FSF site:
http://www.fsf.org. #
-################################################################################
-
-IDENTITY_WELCOME=Welcome
-IDENTITY_REGISTER=Register
-IDENTITY_LOST_PASSWORD=Lost Password
-IDENTITY_NOT_LOGGED_IN=You are currently not logged in.
-IDENTITY_CREATE_ACCOUNT=You can create an account.
-IDENTITY_BUTTON_SUBMIT=Submit
-IDENTITY_BUTTON_EDIT=Edit
-IDENTITY_BUTTON_CANCEL=Cancel
-
-IDENTITY_REGISTER_TITLE=Basic user information
-IDENTITY_REGISTER_TITLE_CONFIRM=Confirmation
-IDENTITY_REGISTER_PASSWORD_CONFIRM=Confirm Password
-IDENTITY_REGISTER_SUCCESS_TITLE=Your account has been sucessfully created.
-
-IDENTITY_LOST_PASSWORD_TITLE=Forgot your login data?
-IDENTITY_LOST_PASSWORD_DESCRIPTION=Please enter your username to reset your password
-
-IDENTITY_EDIT_PASSWORD_TITLE=Change your password
-IDENTITY_EDIT_PASSWORD_CURRENT=Current password
-IDENTITY_EDIT_CHANGE_PASSWORD=Change password
-
-IDENTITY_EDIT_EMAIL_TITLE=Change your email address
-IDENTITY_EDIT_EMAIL_NEW=New email address
-IDENTITY_EDIT_CHANGE_EMAIL=Change email
-
-IDENTITY_EDIT_PROFILE_TITLE=Edit profile
-IDENTITY_VIEW_PROFILE_TITLE=View profile
-
-IDENTITY_USERNAME=Username
-IDENTITY_PASSWORD=Password
-IDENTITY_EMAIL=E-Mail
-IDENTITY_GIVENNAME=Firstname
-IDENTITY_FAMILYNAME=Lastname
-IDENTITY_SKYPE=Skype ID
-IDENTITY_LOCATION=Location
-IDENTITY_OCCUPATION=Occupation
-IDENTITY_EXTRA=Extra
-IDENTITY_SIGNATURE=Signature
-IDENTITY_INTERESTS=Interests
-IDENTITY_LOCALE=Locale
-IDENTITY_ICQ=Icq ID
-IDENTITY_AIM=Aim ID
-IDENTITY_MSNM= MSN messenger ID
-IDENTITY_YIM=Yahoo ID
-IDENTITY_XMMP=Xmmp ID
-IDENTITY_HOMEPAGE=Homepage
-IDENTITY_TIMEZONE=Time zone offset
-IDENTITY_THEME=Theme
-IDENTITY_SECURITY_QUESTION=Security Question
-IDENTITY_SECURITY_ANSWER=Security Answer
-IDENTITY_LAST_LOGIN=Last login
-IDENTITY_REIGSTRATION_DATE=Registration Date
-IDENTITY_ENABLED=Enabled
-
-IDENTITY_MANAGEMENT_ACTION=Actions
-IDENTITY_MANAGEMENT_ACTION_EDIT_PROFILE=Edit user
-IDENTITY_MANAGEMENT_ACTION_ROLES=Roles
-IDENTITY_MANAGEMENT_ACTION_DELETE=Delete
-IDENTITY_MANAGEMENT_USER_MANAGEMENT=User Management
-IDENTITY_MANAGEMENT_ROLE_MANAGEMENT=Role Management
-IDENTITY_MANAGEMENT_SEARCH_USER=Search users
-IDENTITY_MANAGEMENT_CREATE_USER=Create new user account
-IDENTITY_MANAGEMENT_ROLE=Role
-IDENTITY_MANAGEMENT_ROLE_DISPLAY=Display name
-IDENTITY_MANAGEMENT_ROLE_MEMBERS=Members
-IDENTITY_MANAGEMENT_ROLE_ASSIGNED=Assigned roles
-IDENTITY_MANAGEMENT_CREATE_ROLE=Create new role
-IDENTITY_MANAGEMENT_EDIT_ROLE=Edit role
-IDENTITY_MANAGEMENT_CREATE_ROLE=Create role
-IDENTITY_MANAGEMENT_DISABLE=Disable
-IDENTITY_MANAGEMENT_ENABLE=Enable
-IDENTITY_MANAGEMENT_RESET_PASSWORD=Reset password
-IDENTITY_MANAGEMENT_RESET_PASSWORD_DESCRIPTION=The user will get a random password sent
by email.
-IDENTITY_REGISTER_VERIFY_CAPTCHA=Verify captcha
-
-IDENTITY_REGISTER_TITLE_CONFIRM_DELETE=Confirmation: Delete Object
-IDENTITY_REGISTER_CONFIRMATIONEMAIL=Confirm your subscription
-
-
-IDENTITY_MAIL_SUBJECT_LOST_PASSWORD=Reset your password
-IDENTITY_MAIL_SUBJECT_REGISTER=Confirm registration
-IDENTITY_MAIL_SUBJECT_CHANGE_EMAIL=Confirm email address
\ No newline at end of file
Deleted:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity_de.properties
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity_de.properties 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity_de.properties 2007-08-27
19:20:51 UTC (rev 8051)
@@ -1,25 +0,0 @@
-################################################################################
-# JBoss, a division of Red Hat #
-# Copyright 2006, Red Hat Middleware, LLC, and individual #
-# contributors as indicated by the @authors tag. See the #
-# copyright.txt in the distribution for a full listing of #
-# individual contributors. #
-# #
-# This is free software; you can redistribute it and/or modify it #
-# under the terms of the GNU Lesser General Public License as #
-# published by the Free Software Foundation; either version 2.1 of #
-# the License, or (at your option) any later version. #
-# #
-# This software is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
-# Lesser General Public License for more details. #
-# #
-# You should have received a copy of the GNU Lesser General Public #
-# License along with this software; if not, write to the Free #
-# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #
-# 02110-1301 USA, or see the FSF site:
http://www.fsf.org. #
-################################################################################
-
-IDENTITY_WELCOME=Willkommen
-IDENTITY_VIEW_PROFILE_TITLE=Profilansicht
\ No newline at end of file
Modified: trunk/core-identity/src/resources/portal-identity-war/WEB-INF/faces-config.xml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/faces-config.xml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/faces-config.xml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -28,10 +28,9 @@
<faces-config>
<application>
-
<variable-resolver>org.jboss.portal.core.identity.ui.faces.JBossPortletVariableResolver</variable-resolver>
- <property-resolver>org.jboss.portal.core.identity.ui.faces.JBossPortletPropertyResolver</property-resolver>
-<!--
<property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver>
- -->
+
<variable-resolver>org.jboss.portal.core.identity.ui.faces.PortletVariableResolver</variable-resolver>
+ <property-resolver>org.jboss.portal.core.identity.ui.faces.PortletDelegatingPropertyResolver</property-resolver>
+<!--
<property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver>
-->
<view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
</application>
@@ -41,23 +40,6 @@
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
- <managed-bean-name>sendmailmgr</managed-bean-name>
-
<managed-bean-class>org.jboss.portal.core.identity.ui.common.SendMailBean</managed-bean-class>
- <managed-bean-scope>application</managed-bean-scope>
- <!--
- Mail Preferences
- -->
- <managed-property>
- <property-name>emailDomain</property-name>
- <value>Portal.com</value>
- </managed-property>
- <managed-property>
- <property-name>emailFrom</property-name>
- <value>no-reply(a)portal.com</value>
- </managed-property>
- <!-- -->
- </managed-bean>
- <managed-bean>
<managed-bean-name>identityrolemgr</managed-bean-name>
<managed-bean-class>org.jboss.portal.core.identity.ui.common.IdentityRoleBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
@@ -94,13 +76,8 @@
<property-name>metaDataService</property-name>
<value>#{metadataservice}</value>
</managed-property>
- <managed-property>
- <property-name>identityRoleBean</property-name>
- <value>#{identityrolemgr}</value>
- </managed-property>
</managed-bean>
-
<managed-bean>
<managed-bean-name>editprofilemgr</managed-bean-name>
<managed-bean-class>org.jboss.portal.core.identity.ui.actions.EditProfileAction</managed-bean-class>
@@ -110,29 +87,21 @@
<value>#{identityusermgr}</value>
</managed-property>
<managed-property>
- <property-name>sendMailBean</property-name>
- <value>#{sendmailmgr}</value>
+ <property-name>validateEmailService</property-name>
+ <value>#{applicationScope.ValidateEmailService}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>userregistermgr</managed-bean-name>
<managed-bean-class>org.jboss.portal.core.identity.ui.actions.CreateUserAction</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
- <!--
- subscriptionMode
- -->
<managed-property>
- <property-name>subscriptionMode</property-name>
- <value>emailVerification</value>
- </managed-property>
- <!-- -->
- <managed-property>
<property-name>identityUserBean</property-name>
<value>#{identityusermgr}</value>
</managed-property>
<managed-property>
- <property-name>sendMailBean</property-name>
- <value>#{sendmailmgr}</value>
+ <property-name>registrationService</property-name>
+ <value>#{applicationScope.RegistrationService}</value>
</managed-property>
</managed-bean>
<managed-bean>
@@ -160,6 +129,10 @@
<property-name>identityRoleBean</property-name>
<value>#{identityrolemgr}</value>
</managed-property>
+ <managed-property>
+ <property-name>registrationService</property-name>
+ <value>#{applicationScope.RegistrationService}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>rolemanagementbean</managed-bean-name>
@@ -190,13 +163,14 @@
<property-name>passwordCharacters</property-name>
<value>0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWyYzZ*#!+-/"</value>
</managed-property>
+ <!-- -->
<managed-property>
<property-name>identityUserBean</property-name>
<value>#{identityusermgr}</value>
</managed-property>
<managed-property>
- <property-name>sendMailBean</property-name>
- <value>#{sendmailmgr}</value>
+ <property-name>identityMailService</property-name>
+ <value>#{applicationScope.IdentityMailService}</value>
</managed-property>
</managed-bean>
<managed-bean>
@@ -328,6 +302,13 @@
<navigation-rule>
<from-view-id>/WEB-INF/jsf/admin/index.xhtml</from-view-id>
<navigation-case>
+ <from-outcome>showPendingUsers</from-outcome>
+ <to-view-id>/WEB-INF/jsf/admin/user/pendingUsers.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ <navigation-rule>
+ <from-view-id>/WEB-INF/jsf/admin/index.xhtml</from-view-id>
+ <navigation-case>
<from-outcome>deleteUser</from-outcome>
<to-view-id>/WEB-INF/jsf/admin/user/deleteUser.xhtml</to-view-id>
</navigation-case>
Modified: trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jboss-portlet.xml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jboss-portlet.xml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jboss-portlet.xml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -73,8 +73,18 @@
<service-ref>:service=Module,type=Membership</service-ref>
</service>
<service>
- <service-name>MailModule</service-name>
-
<service-class>org.jboss.portal.core.modules.MailModule</service-class>
- <service-ref>:service=Module,type=Mail</service-ref>
+ <service-name>IdentityMailService</service-name>
+
<service-class>org.jboss.portal.core.identity.services.IdentityMailService</service-class>
+ <service-ref>:service=IdentityMailService,type=Mail</service-ref>
</service>
+ <service>
+ <service-name>RegistrationService</service-name>
+
<service-class>org.jboss.portal.core.identity.services.workflow.RegistrationService</service-class>
+ <service-ref>:service=RegistrationService,type=Workflow</service-ref>
+ </service>
+ <service>
+ <service-name>ValidateEmailService</service-name>
+
<service-class>org.jboss.portal.core.identity.services.workflow.ValidateEmailService</service-class>
+ <service-ref>:service=ValidateEmailService,type=Workflow</service-ref>
+ </service>
</portlet-app>
\ No newline at end of file
Modified:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/index.xhtml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/index.xhtml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/index.xhtml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -10,6 +10,8 @@
<ui:define name="title"><h:outputText
value="#{bundle.IDENTITY_MANAGEMENT_SEARCH_USER}"/></ui:define>
<ui:define name="content">
+<h:commandLink value="show pending users"
action="showPendingUsers"/>
+
<h:form>
<h:panelGrid columns="3">
<h:inputText id="searchString"
value="#{useradministrationbean.searchString}" />
@@ -24,7 +26,7 @@
</h:form>
<hr/>
- <h:dataTable id="userlist"
value="#{useradministrationbean.userList}" var="uiUser"
rendered="#{useradministrationbean.userList.rowCount > 0}"
rowClasses="portlet-section-body,portlet-section-alternate"
headerClass="portlet-section-header" width="100%">
+ <h:dataTable id="userlist"
value="#{useradministrationbean.userList}" var="uiUser"
rendered="#{useradministrationbean.userList.rowCount > 0}"
rows="#{useradministrationbean.limit}"
rowClasses="portlet-section-body,portlet-section-alternate"
headerClass="portlet-section-header" width="100%">
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.IDENTITY_USERNAME}"/>
@@ -72,7 +74,12 @@
</h:commandLink>
</h:column>
</h:dataTable>
-
+
+
+ <h:commandLink value=" < "
action="#{useradministrationbean.prevPage}"
rendered="#{useradministrationbean.page > 1}"
styleClass="portlet-form-button"/>
+ <h:commandLink value=" > "
action="#{useradministrationbean.nextPage}"
rendered="#{useradministrationbean.userList.rowCount >
useradministrationbean.limit}" styleClass="portlet-form-button"/>
+
+
<p style="text-align: right"><h:commandLink
value="#{bundle.IDENTITY_MANAGEMENT_CREATE_USER}"
action="createUser"/></p>
</ui:define>
Modified:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/roles/roleMembers.xhtml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/roles/roleMembers.xhtml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/roles/roleMembers.xhtml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -15,7 +15,7 @@
<ui:define name="content">
<hr/>
<h:form>
- <h:dataTable value="#{rolemanagementbean.roleMembers}"
var="uiUser"
rowClasses="portlet-section-body,portlet-section-alternate"
headerClass="portlet-section-header" width="100%">
+ <h:dataTable value="#{rolemanagementbean.roleMembers}"
var="uiUser" rows="#{rolemanagementbean.limit}"
rendered="#{rolemanagementbean.roleMembers.rowCount > 0}"
rowClasses="portlet-section-body,portlet-section-alternate"
headerClass="portlet-section-header" width="100%">
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.IDENTITY_USERNAME}"/>
@@ -55,6 +55,8 @@
</h:column>
</h:dataTable>
</h:form>
+<h:commandLink value=" < "
action="#{rolemanagementbean.prevPage}" rendered="#{rolemanagementbean.page
> 1}" styleClass="portlet-form-button"/>
+<h:commandLink value=" > "
action="#{rolemanagementbean.nextPage}"
rendered="#{rolemanagementbean.roleMembers.rowCount >
rolemanagementbean.limit}" styleClass="portlet-form-button"/>
<br/>
<h:form>
<h4><h:outputText
value="#{bundle.IDENTITY_MANAGEMENT_SEARCH_USER}"/></h4>
Added:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/pendingUsers.xhtml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/pendingUsers.xhtml
(rev 0)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/pendingUsers.xhtml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,60 @@
+<div
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:c="http://java.sun.com/jstl/core"
+ class="identity-ui">
+
+<ui:composition template="/WEB-INF/jsf/admin/user/userTemplate.xhtml">
+
+<ui:define name="title">title TODO pending users</ui:define>
+<ui:define name="content">
+<h:dataTable value="#{useradministrationbean.pendingUsers}"
var="user">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="processId"/>
+ </f:facet>
+ <h:outputText value="#{user.processId}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="username"/>
+ </f:facet>
+ <h:outputText value="#{user.username}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="email"/>
+ </f:facet>
+ <h:outputText value="#{user.email}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="registration date"/>
+ </f:facet>
+ <h:outputText value="#{user.registrationDate}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="status"/>
+ </f:facet>
+ <h:outputText value="Pending" rendered="#{user.currentNode ==
'emailValidation'}"/>
+ <c:if test="#{user.currentNode == 'adminApproval'}">
+ <h:commandLink
action="#{useradministrationbean.approveRegistration}">
+ <h:outputText value="approve"/>
+ <f:param name="processId" value="#{user.processId}" />
+ <f:param name="action" value="approve" />
+ </h:commandLink> |
+ <h:commandLink
action="#{useradministrationbean.approveRegistration}">
+ <h:outputText value="reject"/>
+ <f:param name="processId" value="#{user.processId}" />
+ <f:param name="action" value="reject" />
+ </h:commandLink>
+ </c:if>
+ </h:column>
+</h:dataTable>
+
+</ui:define>
+</ui:composition>
+</div>
\ No newline at end of file
Modified:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/common/register.xhtml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/common/register.xhtml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/common/register.xhtml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -32,7 +32,8 @@
</h:inputSecret>
<h:message for="passwordCheck"/>
</h:panelGrid>
- <c:if test="#{showCaptcha == true}">
+ <c:if test="#{portletPreferenceValue.captcha == true}">
+ <hr/>
<h:graphicImage id="captchaimage" url="/jcaptcha" />
<h:panelGrid columns="3">
<h:outputText value="#{bundle.IDENTITY_REGISTER_VERIFY_CAPTCHA}" />
Modified: trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/index.xhtml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/index.xhtml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/index.xhtml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -5,8 +5,6 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core">
-
-#{portletPreferenceValues}
<c:choose>
<c:when test="#{facesContext.externalContext.remoteUser != null}">
<ui:include src="/WEB-INF/jsf/profile/viewProfile.xhtml"/>
Modified:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/lostPassword/lost.xhtml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/lostPassword/lost.xhtml 2007-08-27
19:09:00 UTC (rev 8050)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/lostPassword/lost.xhtml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -19,6 +19,8 @@
<h:inputText id="username" value="#{lostpasswordmgr.username}"
/>
<h:message for="username" />
</h:panelGrid>
+ <c:if test="#{portletPreferenceValue.captcha == true}">
+ <hr/>
<h:graphicImage id="captchaimage" url="/jcaptcha" />
<h:panelGrid columns="3">
<h:outputText value="#{bundle.IDENTITY_REGISTER_VERIFY_CAPTCHA}" />
@@ -27,6 +29,7 @@
</h:inputText>
<h:message for="validateCaptcha" />
</h:panelGrid>
+ </c:if>
<hr/>
<h:commandButton value="#{bundle.IDENTITY_BUTTON_SUBMIT}"
action="#{lostpasswordmgr.doomed}"
styleClass="portlet-form-button"/>
</h:form>
Modified: trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml 2007-08-27
19:09:00 UTC (rev 8050)
+++ trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml 2007-08-27
19:20:51 UTC (rev 8051)
@@ -59,6 +59,13 @@
<title>User portlet</title>
<keywords>management,user</keywords>
</portlet-info>
+ <portlet-preferences>
+ <preference>
+ <!-- Use captcha verification -->
+ <name>captcha</name>
+ <value>false</value>
+ </preference>
+ </portlet-preferences>
</portlet>
<portlet>
Copied: trunk/core-identity/src/resources/resource-bundles/Identity.properties (from rev
8017,
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity.properties)
===================================================================
--- trunk/core-identity/src/resources/resource-bundles/Identity.properties
(rev 0)
+++ trunk/core-identity/src/resources/resource-bundles/Identity.properties 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,105 @@
+################################################################################
+# JBoss, a division of Red Hat #
+# Copyright 2006, Red Hat Middleware, LLC, and individual #
+# contributors as indicated by the @authors tag. See the #
+# copyright.txt in the distribution for a full listing of #
+# individual contributors. #
+# #
+# This is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU Lesser General Public License as #
+# published by the Free Software Foundation; either version 2.1 of #
+# the License, or (at your option) any later version. #
+# #
+# This software is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# Lesser General Public License for more details. #
+# #
+# You should have received a copy of the GNU Lesser General Public #
+# License along with this software; if not, write to the Free #
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #
+# 02110-1301 USA, or see the FSF site:
http://www.fsf.org. #
+################################################################################
+
+IDENTITY_WELCOME=Welcome
+IDENTITY_REGISTER=Register
+IDENTITY_LOST_PASSWORD=Lost Password
+IDENTITY_NOT_LOGGED_IN=You are currently not logged in.
+IDENTITY_CREATE_ACCOUNT=You can create an account.
+IDENTITY_BUTTON_SUBMIT=Submit
+IDENTITY_BUTTON_EDIT=Edit
+IDENTITY_BUTTON_CANCEL=Cancel
+
+IDENTITY_REGISTER_TITLE=Basic user information
+IDENTITY_REGISTER_TITLE_CONFIRM=Confirmation
+IDENTITY_REGISTER_PASSWORD_CONFIRM=Confirm Password
+IDENTITY_REGISTER_SUCCESS_TITLE=Your account has been sucessfully created.
+
+IDENTITY_LOST_PASSWORD_TITLE=Forgot your login data?
+IDENTITY_LOST_PASSWORD_DESCRIPTION=Please enter your username to reset your password
+
+IDENTITY_EDIT_PASSWORD_TITLE=Change your password
+IDENTITY_EDIT_PASSWORD_CURRENT=Current password
+IDENTITY_EDIT_CHANGE_PASSWORD=Change password
+
+IDENTITY_EDIT_EMAIL_TITLE=Change your email address
+IDENTITY_EDIT_EMAIL_NEW=New email address
+IDENTITY_EDIT_CHANGE_EMAIL=Change email
+
+IDENTITY_EDIT_PROFILE_TITLE=Edit profile
+IDENTITY_VIEW_PROFILE_TITLE=View profile
+
+IDENTITY_USERNAME=Username
+IDENTITY_PASSWORD=Password
+IDENTITY_EMAIL=E-Mail
+IDENTITY_GIVENNAME=Firstname
+IDENTITY_FAMILYNAME=Lastname
+IDENTITY_SKYPE=Skype ID
+IDENTITY_LOCATION=Location
+IDENTITY_OCCUPATION=Occupation
+IDENTITY_EXTRA=Extra
+IDENTITY_SIGNATURE=Signature
+IDENTITY_INTERESTS=Interests
+IDENTITY_LOCALE=Locale
+IDENTITY_ICQ=Icq ID
+IDENTITY_AIM=Aim ID
+IDENTITY_MSNM= MSN messenger ID
+IDENTITY_YIM=Yahoo ID
+IDENTITY_XMMP=Xmmp ID
+IDENTITY_HOMEPAGE=Homepage
+IDENTITY_TIMEZONE=Time zone offset
+IDENTITY_THEME=Theme
+IDENTITY_SECURITY_QUESTION=Security Question
+IDENTITY_SECURITY_ANSWER=Security Answer
+IDENTITY_LAST_LOGIN=Last login
+IDENTITY_REIGSTRATION_DATE=Registration Date
+IDENTITY_ENABLED=Enabled
+
+IDENTITY_MANAGEMENT_ACTION=Actions
+IDENTITY_MANAGEMENT_ACTION_EDIT_PROFILE=Edit user
+IDENTITY_MANAGEMENT_ACTION_ROLES=Roles
+IDENTITY_MANAGEMENT_ACTION_DELETE=Delete
+IDENTITY_MANAGEMENT_USER_MANAGEMENT=User Management
+IDENTITY_MANAGEMENT_ROLE_MANAGEMENT=Role Management
+IDENTITY_MANAGEMENT_SEARCH_USER=Search users
+IDENTITY_MANAGEMENT_CREATE_USER=Create new user account
+IDENTITY_MANAGEMENT_ROLE=Role
+IDENTITY_MANAGEMENT_ROLE_DISPLAY=Display name
+IDENTITY_MANAGEMENT_ROLE_MEMBERS=Members
+IDENTITY_MANAGEMENT_ROLE_ASSIGNED=Assigned roles
+IDENTITY_MANAGEMENT_CREATE_ROLE=Create new role
+IDENTITY_MANAGEMENT_EDIT_ROLE=Edit role
+IDENTITY_MANAGEMENT_CREATE_ROLE=Create role
+IDENTITY_MANAGEMENT_DISABLE=Disable
+IDENTITY_MANAGEMENT_ENABLE=Enable
+IDENTITY_MANAGEMENT_RESET_PASSWORD=Reset password
+IDENTITY_MANAGEMENT_RESET_PASSWORD_DESCRIPTION=The user will get a random password sent
by email.
+IDENTITY_REGISTER_VERIFY_CAPTCHA=Verify captcha
+
+IDENTITY_REGISTER_TITLE_CONFIRM_DELETE=Confirmation: Delete Object
+IDENTITY_REGISTER_CONFIRMATIONEMAIL=Confirm your subscription
+
+
+IDENTITY_MAIL_SUBJECT_LOST_PASSWORD=Reset your password
+IDENTITY_MAIL_SUBJECT_REGISTER=Confirm registration
+IDENTITY_MAIL_SUBJECT_CHANGE_EMAIL=Confirm email address
\ No newline at end of file
Copied: trunk/core-identity/src/resources/resource-bundles/Identity_de.properties (from
rev 8017,
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/classes/Identity_de.properties)
===================================================================
--- trunk/core-identity/src/resources/resource-bundles/Identity_de.properties
(rev 0)
+++ trunk/core-identity/src/resources/resource-bundles/Identity_de.properties 2007-08-27
19:20:51 UTC (rev 8051)
@@ -0,0 +1,25 @@
+################################################################################
+# JBoss, a division of Red Hat #
+# Copyright 2006, Red Hat Middleware, LLC, and individual #
+# contributors as indicated by the @authors tag. See the #
+# copyright.txt in the distribution for a full listing of #
+# individual contributors. #
+# #
+# This is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU Lesser General Public License as #
+# published by the Free Software Foundation; either version 2.1 of #
+# the License, or (at your option) any later version. #
+# #
+# This software is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# Lesser General Public License for more details. #
+# #
+# You should have received a copy of the GNU Lesser General Public #
+# License along with this software; if not, write to the Free #
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #
+# 02110-1301 USA, or see the FSF site:
http://www.fsf.org. #
+################################################################################
+
+IDENTITY_WELCOME=Willkommen
+IDENTITY_VIEW_PROFILE_TITLE=Profilansicht
\ No newline at end of file