Author: emuckenhuber
Date: 2007-08-28 13:50:11 -0400 (Tue, 28 Aug 2007)
New Revision: 8071
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/IdentityManagementService.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/CreateUserAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/IdentityManagementServiceImpl.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/SendValidationMailAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/ValidateEmailServiceImpl.java
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_workflow.xml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/searchUsers.xhtml
Removed:
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/SendValidationMailAction.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailServiceImpl.java
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/IdentityMailServiceImpl.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/UserContainer.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/IdentityRoleBean.java
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java
trunk/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml
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-war/WEB-INF/
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/faces-config.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/user/pendingUsers.xhtml
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet-instances.xml
Log:
- some changes at registration process with jBPM
- changeEmail request is now also validated over jBPM
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-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityCommandFactoryService.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -27,14 +27,12 @@
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.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.portlet.PortletParametersStateString;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.config.ServerConfig;
/**
* @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
@@ -50,12 +48,6 @@
protected PortalObjectId targetWindowId;
/** . */
- protected ServerConfig serverConfig;
-
- /** . */
- protected RegistrationService registrationService = null;
-
- /** . */
protected ValidateEmailService validateEmailService = null;
public PortalObjectId getTargetWindowId()
@@ -63,26 +55,6 @@
return targetWindowId;
}
- public ServerConfig getServerConfig()
- {
- return serverConfig;
- }
-
- public void setServerConfig(ServerConfig serverConfig)
- {
- this.serverConfig = serverConfig;
- }
-
- public RegistrationService getRegistrationService()
- {
- return registrationService;
- }
-
- public void setRegistrationService(RegistrationService registrationService)
- {
- this.registrationService = registrationService;
- }
-
public ValidateEmailService getValidateEmailService()
{
return validateEmailService;
@@ -115,12 +87,12 @@
validateEmailService.validateEmail(bpmId, hash);
// TODO
- this.targetWindowId =
PortalObjectId.parse("default.default.wizardWindow_10",
PortalObjectPath.LEGACY_FORMAT);
+ this.targetWindowId =
PortalObjectId.parse("default.default.CoreIdentityUserPortletWindow",
PortalObjectPath.LEGACY_FORMAT);
}
else
{
- this.targetWindowId =
PortalObjectId.parse("default.default.wizardWindow_10",
+ this.targetWindowId =
PortalObjectId.parse("default.default.CoreIdentityUserPortletWindow",
PortalObjectPath.LEGACY_FORMAT);
}
Modified:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailServiceImpl.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -91,10 +91,6 @@
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
@@ -130,6 +126,17 @@
public MailModule getMailModule()
{
+ if (this.mailModule == null)
+ {
+ try
+ {
+ this.mailModule = (MailModule) new
InitialContext().lookup("java:/portal/MailModule");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
return mailModule;
}
@@ -181,7 +188,7 @@
this.generateEmailText();
// Sending mail
- // mailModule.send(emailFrom, to , subject, emailText);
+ // this.getMailModule.send(emailFrom, to , subject, emailText);
log.debug(subject + to + this.emailText);
}
@@ -199,7 +206,7 @@
}
if (config == null)
{
- throw new FileNotFoundException("Cannot load a suitable emailTemplate.tpl
in templates/"
+ throw new FileNotFoundException("Cannot load a suitable emailTemplate.tpl
in conf/templates/"
+ this.templateLocation);
}
InputStream in = config.openStream();
Deleted:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ApproveRegistration.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -1,291 +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.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;
- }
-
-}
Deleted:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/CreateUserAction.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -1,45 +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.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/IdentityManagementService.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/IdentityManagementService.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/IdentityManagementService.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * 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.Map;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface IdentityManagementService
+{
+ boolean createUser(String username, String password, Map profileMap, List roles);
+
+ public String getCurrentEmail(String username);
+
+ public boolean updateEmail(String username, String email);
+
+}
+
Modified:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -40,5 +40,7 @@
/** . */
List getPendingUsers();
+
+ int getPendingCount();
}
Deleted:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/SendValidationMailAction.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -1,178 +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.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;
- }
-
-}
Modified:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import org.jboss.portal.identity.User;
@@ -35,17 +34,22 @@
*/
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)
@@ -127,6 +131,7 @@
}
public String getRegistrationDate(){
- return (String) this.profileMap.get(User.INFO_USER_REGISTRATION_DATE);
+ Object obj = this.profileMap.get(User.INFO_USER_REGISTRATION_DATE);
+ return obj != null ? obj.toString() : null;
}
}
Deleted:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/ValidateEmailServiceImpl.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -1,234 +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.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;
- }
-}
-
Copied:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/CreateUserAction.java
(from rev 8051,
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/impl/CreateUserAction.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/CreateUserAction.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.impl;
+
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.core.identity.services.workflow.IdentityManagementService;
+import org.jboss.portal.core.identity.services.workflow.UserContainer;
+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 IdentityManagementService identityManagementService;
+
+ /** . */
+ private static Logger log = Logger.getLogger(CreateUserAction.class);
+
+ public void execute(ExecutionContext ectx) throws Exception
+ {
+ UserContainer uc = (UserContainer)
ectx.getContextInstance().getVariable("user");
+
+ this.getIdentityManagementService().createUser(uc.getUsername(), uc.getPassword(),
uc.getProfileMap(), uc.getRoles());
+
+ log.debug("creating User: "+ uc.getUsername() );
+ }
+
+ private IdentityManagementService getIdentityManagementService()
+ {
+ if (this.identityManagementService == null)
+ {
+ try
+ {
+ this.identityManagementService = (IdentityManagementService) new
InitialContext().lookup("java:/portal/IdentityManagementService");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return this.identityManagementService;
+ }
+
+}
\ No newline at end of file
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/IdentityManagementServiceImpl.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/IdentityManagementServiceImpl.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/IdentityManagementServiceImpl.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,288 @@
+/******************************************************************************
+ * 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.impl;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.InitialContext;
+
+import org.jboss.portal.core.identity.services.workflow.IdentityManagementService;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.MembershipModule;
+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;
+import org.jboss.portal.jems.as.JNDI;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class IdentityManagementServiceImpl extends AbstractJBossService implements
IdentityManagementService
+{
+ /** . */
+ private UserModule userModule;
+
+ /** . */
+ private RoleModule roleModule;
+
+ /** . */
+ private UserProfileModule userProfileModule;
+
+ /** . */
+ private MembershipModule membershipModule;
+
+ /** . */
+ private JNDI.Binding jndiBinding;
+
+ /** . */
+ private String jndiName = null;
+
+ /** . */
+ private InitialContext initialContext;
+
+ public void startService() throws Exception
+ {
+ super.startService();
+
+ this.initialContext = new InitialContext();
+
+ if (this.jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+ }
+
+ public void stopService() throws Exception
+ {
+ super.stopService();
+
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ }
+
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public UserModule getUserModule()
+ {
+ if (userModule == null)
+ {
+ try
+ {
+ userModule = (UserModule)
initialContext.lookup("java:/portal/UserModule");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return userModule;
+ }
+
+ public void setUserModule(UserModule userModule)
+ {
+ this.userModule = userModule;
+ }
+
+ public RoleModule getRoleModule()
+ {
+ if (roleModule == null)
+ {
+ try
+ {
+ roleModule = (RoleModule)
initialContext.lookup("java:/portal/RoleModule");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return roleModule;
+ }
+
+ public void setRoleModule(RoleModule roleModule)
+ {
+ this.roleModule = roleModule;
+ }
+
+ public UserProfileModule getUserProfileModule()
+ {
+ if (userProfileModule == null)
+ {
+ try
+ {
+ userProfileModule = (UserProfileModule)
initialContext.lookup("java:/portal/UserProfileModule");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return userProfileModule;
+ }
+
+ public void setUserProfileModule(UserProfileModule userProfileModule)
+ {
+ this.userProfileModule = userProfileModule;
+ }
+
+ public MembershipModule getMembershipModule()
+ {
+ if (membershipModule == null)
+ {
+ try
+ {
+ membershipModule = (MembershipModule)
initialContext.lookup("java:/portal/MembershipModule");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return membershipModule;
+ }
+
+ public void setMembershipModule(MembershipModule membershipModule)
+ {
+ this.membershipModule = membershipModule;
+ }
+
+ public boolean createUser(String username, String password, Map profileMap, List
roles)
+ {
+ try
+ {
+ User user = this.getUserModule().createUser(username, password);
+ Set roleSet = this.checkRoles(roles);
+
+ // Enable the user
+ profileMap.put(User.INFO_USER_ENABLED, Boolean.TRUE);
+
+ Iterator i = profileMap.keySet().iterator();
+ while (i.hasNext())
+ {
+ String key = (String) i.next();
+ Object value = profileMap.get(key);
+ this.getUserProfileModule().setProperty(user, key, value);
+ }
+
+ this.getMembershipModule().assignRoles(user, roleSet);
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.error("Error when creating user", e);
+ }
+
+ return false;
+ }
+
+ public String getCurrentEmail(String username)
+ {
+ try
+ {
+ User user = this.getUserModule().findUserByUserName(username);
+ return (String) this.getUserProfileModule().getProperty(user,
User.INFO_USER_EMAIL_REAL);
+ }
+ catch (Exception e)
+ {
+ log.error("failed to retrieve current email address", e);
+ }
+ return null;
+ }
+
+ public boolean updateEmail(String username, String email)
+ {
+ try
+ {
+ User user = this.getUserModule().findUserByUserName(username);
+ this.getUserProfileModule().setProperty(user, User.INFO_USER_EMAIL_REAL,
email);
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.error("failed to update email", e);
+ }
+ return false;
+ }
+
+ private Set checkRoles(List roles) throws IllegalArgumentException, IdentityException
+ {
+ Set roleSet = new HashSet();
+ if (roles != null && roles.size() > 0)
+ { // Checking existing roles
+ Iterator i = roles.iterator();
+
+ while (i.hasNext())
+ {
+ String roleName = (String) i.next();
+ Role role = this.getRoleModule().findRoleByName(roleName);
+
+ if (role == null)
+ {
+ // Create new role ?
+ }
+ else
+ {
+ roleSet.add(role);
+ }
+ }
+ return roleSet;
+ }
+ else
+ {
+ // TODO default Role
+ Role role = this.getRoleModule().findRoleByName("User");
+
+ if (role != null)
+ {
+ roleSet.add(role);
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+
+ return roleSet;
+ }
+ }
+
+}
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,324 @@
+/******************************************************************************
+ * 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.impl;
+
+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.core.identity.services.workflow.RegistrationService;
+import org.jboss.portal.core.identity.services.workflow.UserContainer;
+import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
+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.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 RegistrationServiceImpl extends AbstractJBossService implements
RegistrationService
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(RegistrationServiceImpl.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
+ {
+ ProcessDefinition fromConfig =
ProcessDefinition.parseXmlResource(processFile);
+ if (this.overwrite)
+ {
+ 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 = this.workflowService.getJbpmConfiguration().createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.getProcessInstance(processId);
+
+ if (processInstance != null)
+ {
+ Token token = processInstance.getRootToken();
+ if (token.getNode().getName().equals("adminApproval"))
+ {
+ if (approve)
+ {
+ token.signal("approved");
+ }
+ else
+ {
+ token.signal("rejected");
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("", e);
+ }
+ finally
+ {
+ IOTools.safeClose(jbpmContext);
+ }
+ return IdentityConstants.REGISTRATION_PENDING;
+ }
+
+ public int getPendingCount()
+ {
+ int count = 0;
+ 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();
+ count = !instance.hasEnded() ? count + 1 : count;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("", e);
+ }
+ finally
+ {
+ IOTools.safeClose(jbpmContext);
+ }
+ return count;
+ }
+
+ 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;
+ }
+
+}
Copied:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/SendValidationMailAction.java
(from rev 8051,
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/impl/SendValidationMailAction.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/SendValidationMailAction.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,158 @@
+/******************************************************************************
+ * 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.impl;
+
+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.core.identity.services.workflow.IdentityManagementService;
+import org.jboss.portal.core.identity.services.workflow.UserContainer;
+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 IdentityManagementService identityManagementService;
+
+ /** . */
+ 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))
+ {
+ String emailTo =
this.getIdentityManagementService().getCurrentEmail(uc.getUsername());
+ emailMap.put("to", emailTo);
+ }
+ 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 IdentityManagementService getIdentityManagementService()
+ {
+ if (identityManagementService == null)
+ {
+ try
+ {
+ this.identityManagementService = (IdentityManagementService) new
InitialContext().lookup("java:/portal/IdentityManagementService");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return identityManagementService;
+ }
+
+}
Added:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.impl;
+
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.core.identity.services.IdentityConstants;
+import org.jboss.portal.core.identity.services.workflow.IdentityManagementService;
+import org.jboss.portal.core.identity.services.workflow.UserContainer;
+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 UpdateEmailAction implements ActionHandler
+{
+
+ /** . */
+ private IdentityManagementService identityManagementService;
+
+ /** . */
+ private static Logger log = Logger.getLogger(CreateUserAction.class);
+
+ public void execute(ExecutionContext ectx) throws Exception
+ {
+ UserContainer uc = (UserContainer)
ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_USER);
+ String email = (String)
ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_EMAIL);
+
+ this.getIdentityManagementService().updateEmail(uc.getUsername(), email);
+ }
+
+ private IdentityManagementService getIdentityManagementService()
+ {
+ if (identityManagementService == null)
+ {
+ try
+ {
+ identityManagementService = (IdentityManagementService) new
InitialContext().lookup("java:/portal/IdentityManagementService");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return identityManagementService;
+ }
+}
+
Copied:
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/ValidateEmailServiceImpl.java
(from rev 8051,
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/impl/ValidateEmailServiceImpl.java
(rev 0)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/ValidateEmailServiceImpl.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,237 @@
+/******************************************************************************
+ * 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.impl;
+
+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.core.identity.services.workflow.UserContainer;
+import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
+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.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
+ {
+ ProcessDefinition fromConfig =
ProcessDefinition.parseXmlResource(processFile);
+ if (this.overwrite)
+ {
+ 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)
+ {
+ Token token = processInstance.getRootToken();
+ if (token != null &&
token.getNode().getName().equals("validate_email"))
+ {
+ String hash = (String)
processInstance.getContextInstance().getVariable(IdentityConstants.VALIDATION_HASH);
+ if (registrationHash.equals(hash) && !
processInstance.hasEnded())
+ {
+ 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;
+ }
+}
+
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-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -32,12 +32,10 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.model.ListDataModel;
-import javax.faces.model.SelectItem;
import org.jboss.portal.core.identity.ui.IdentityUIUser;
import org.jboss.portal.core.identity.ui.UIRole;
import org.jboss.portal.core.identity.ui.common.IdentityRoleBean;
-import org.jboss.portal.core.identity.ui.common.IdentityUserBean;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.Role;
import org.jboss.portal.identity.User;
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-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -27,7 +27,6 @@
import java.util.List;
import java.util.Map;
-import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
@@ -62,7 +61,7 @@
private int limit = 10;
/** . */
- private int userCount;
+ private int userCount = 0;
/** . */
private List roles = new ArrayList();
@@ -201,7 +200,7 @@
e.printStackTrace();
}
}
- return "userAdmin";
+ return "searchUsers";
}
public String enableUser()
@@ -241,9 +240,30 @@
// Updating search
return this.searchUsers();
}
- return "userAdmin";
+ return "searchUsers";
}
+ public int getPendingCount()
+ {
+ return this.registrationService.getPendingCount();
+ }
+
+ public int getUserCount()
+ {
+ if (userCount == 0)
+ {
+ try
+ {
+ userCount = this.identityUserBean.getUserModule().getUserCount();
+ }
+ catch (Exception e)
+ {
+ log.error("", e);
+ }
+ }
+ return userCount;
+ }
+
public List getPendingUsers()
{
List list = new ArrayList();
@@ -285,14 +305,14 @@
{
this.page++;
this.searchUsers();
- return "userAdmin";
+ return "searchUsers";
}
public String prevPage()
{
this.page--;
this.searchUsers();
- return "userAdmin";
+ return "searchUsers";
}
public String approveRegistration()
Modified:
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityRoleBean.java
===================================================================
---
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityRoleBean.java 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityRoleBean.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -88,7 +88,7 @@
Set roleSet = this.checkRoles(roles);
this.membershipModule.assignRoles(user, roleSet);
}
-
+
private Set checkRoles(List roles) throws IllegalArgumentException, IdentityException
{
Set roleSet = new HashSet();
@@ -110,23 +110,8 @@
roleSet.add(role);
}
}
- return roleSet;
}
- else
- {
- Role role = roleModule.findRoleByName(defaultRole);
-
- if (role != null)
- {
- roleSet.add(role);
- }
- else
- {
- throw new IllegalArgumentException();
- }
-
- return roleSet;
- }
+ return roleSet;
}
public void updateRoleDisplayName(String roleName, String roleDisplayName) throws
IllegalArgumentException,
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-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java 2007-08-28
17:50:11 UTC (rev 8071)
@@ -164,7 +164,15 @@
public Class getPropertyType(String propertyName) throws IdentityException
{
UIAttribute uiAttribute = (UIAttribute)
this.metaDataService.getValue(propertyName).getObject();
- return
userProfileModule.getProfileInfo().getPropertyInfo(uiAttribute.getIdentifier()).getClass();
+ String type =
userProfileModule.getProfileInfo().getPropertyInfo(uiAttribute.getIdentifier()).getType();
+ try
+ {
+ return ClassLoader.getSystemClassLoader().loadClass(type);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
public Object getUserProperty(String username, String propertyName) throws
IllegalArgumentException, NoSuchUserException, IdentityException
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-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -29,12 +29,6 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<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>
@@ -45,6 +39,7 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <!-- depends on MailModule -->
<attribute
name="JNDIName">java:portal/IdentityMailService</attribute>
</mbean>
@@ -64,7 +59,17 @@
</mbean>
<mbean
-
code="org.jboss.portal.core.identity.services.workflow.ApproveRegistration"
+
code="org.jboss.portal.core.identity.services.workflow.impl.IdentityManagementServiceImpl"
+ name="portal:service=IdentityManagementService,type=IdentityUI"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <!-- depends on UserModule, RoleModule, UserProfileModule, MemberShipModule
-->
+ <attribute
name="JNDIName">java:portal/IdentityManagementService</attribute>
+ </mbean>
+
+ <mbean
+
code="org.jboss.portal.core.identity.services.workflow.impl.RegistrationServiceImpl"
name="portal:service=RegistrationService,type=Workflow"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
@@ -72,13 +77,14 @@
<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>
+ <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"
+
code="org.jboss.portal.core.identity.services.workflow.impl.ValidateEmailServiceImpl"
name="portal:service=ValidateEmailService,type=Workflow"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
Modified:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validate_email.xml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -6,15 +6,15 @@
<process-definition name="jbp_identity_validate_email">
<start-state>
<transition to="validate_email">
- <action
class="org.jboss.portal.core.identity.services.workflow.SendValidationMailAction"/>
+ <action
class="org.jboss.portal.core.identity.services.workflow.impl.SendValidationMailAction"/>
</transition>
</start-state>
<state name="validate_email">
- <create-timer name="time_to_expire" duedate="24 hours"
transition="timedOut" />
+ <create-timer name="time_to_expire" duedate="5 minutes"
transition="timedOut" />
<transition name="ok" to="validated"/>
<transition name="timedOut" to="expired"/>
<transition name="changeEmail" to="validated">
- <!-- call action and update email -->
+ <action
class="org.jboss.portal.core.identity.services.workflow.impl.UpdateEmailAction"/>
</transition>
</state>
<end-state name="validated"/>
Modified:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_approval_workflow.xml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -17,8 +17,8 @@
<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 name="approved" to="end">
+ <action
class="org.jboss.portal.core.identity.services.workflow.impl.CreateUserAction"/>
</transition>
<transition name="rejected" to="end"/>
</state>
Added:
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_workflow.xml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_workflow.xml
(rev 0)
+++
trunk/core-identity/src/resources/portal-identity-sar/conf/processes/jbp_identity_validation_workflow.xml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -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_validation_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="end">
+ <action
class="org.jboss.portal.core.identity.services.workflow.impl.CreateUserAction"/>
+ </transition>
+ <transition name="expired" to="end"/>
+ </process-state>
+ <end-state name="end"/>
+</process-definition>
\ No newline at end of file
Property changes on: trunk/core-identity/src/resources/portal-identity-war/WEB-INF
___________________________________________________________________
Name: svn:ignore
+ portal-identity-objects.xml
portal-identity-object.xml
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-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/faces-config.xml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -302,6 +302,13 @@
<navigation-rule>
<from-view-id>/WEB-INF/jsf/admin/index.xhtml</from-view-id>
<navigation-case>
+ <from-outcome>searchUsers</from-outcome>
+ <to-view-id>/WEB-INF/jsf/admin/user/searchUsers.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>showPendingUsers</from-outcome>
<to-view-id>/WEB-INF/jsf/admin/user/pendingUsers.xhtml</to-view-id>
</navigation-case>
@@ -323,7 +330,7 @@
<navigation-case>
<from-action>#{editprofilemgr.updateProfile}</from-action>
<from-outcome>editProfile</from-outcome>
- <to-view-id>/WEB-INF/jsf/admin/index.xhtml</to-view-id>
+ <to-view-id>/WEB-INF/jsf/admin/user/searchUsers.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
@@ -395,7 +402,7 @@
<navigation-case>
<from-action>#{lostpasswordmgr.doomed}</from-action>
<from-outcome>status</from-outcome>
- <to-view-id>/WEB-INF/jsf/admin/index.xhtml</to-view-id>
+ <to-view-id>/WEB-INF/jsf/admin/user/searchUsers.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{lostpasswordmgr.doomed}</from-action>
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-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/index.xhtml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -7,80 +7,22 @@
class="identity-ui">
<ui:composition template="/WEB-INF/jsf/admin/user/userTemplate.xhtml">
-<ui:define name="title"><h:outputText
value="#{bundle.IDENTITY_MANAGEMENT_SEARCH_USER}"/></ui:define>
+<ui:define name="title"/>
<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}" />
- <h:commandButton value="Search"
action="#{useradministrationbean.searchUsers}"
styleClass="portlet-form-button"/>
- <h:selectOneMenu id="limit"
value="#{useradministrationbean.limit}">
- <f:selectItem id="limit1" itemValue="10"/>
- <f:selectItem id="limit2" itemValue="20"/>
- <f:selectItem id="limit5" itemValue="50"/>
- <f:selectItem id="limit10" itemValue="100"/>
- </h:selectOneMenu>
+ <ul>
+ <li><h:commandLink value="#{bundle.IDENTITY_MANAGEMENT_SEARCH_USER}"
action="searchUsers"/></li>
+ <li><h:commandLink value="Show pending registrations"
action="showPendingUsers"/></li>
+ <li><h:commandLink value="#{bundle.IDENTITY_MANAGEMENT_CREATE_USER}"
action="createUser"/></li>
+ </ul>
+ <hr/>
+ <h:panelGrid columns="2">
+ <h:outputText value="Registered Users"/>
+ <h:outputText value="#{useradministrationbean.userCount}" />
+ <h:outputText value="Pending Registrations" />
+ <h:outputText value="#{useradministrationbean.pendingCount}" />
</h:panelGrid>
- </h:form>
-<hr/>
-
- <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}"/>
- </f:facet>
- <h:outputText value="#{uiUser.username}"/>
- </h:column>
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{bundle.IDENTITY_GIVENNAME}"/>
- </f:facet>
- <h:outputText value="#{uiUser.attribute.givenname}"/>
- </h:column>
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{bundle.IDENTITY_FAMILYNAME}"/>
- </f:facet>
- <h:outputText value="#{uiUser.attribute.familyname}"/>
- </h:column>
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{bundle.IDENTITY_ENABLED}"/>
- </f:facet>
- <h:selectBooleanCheckbox id="enabled"
value="#{uiUser.attribute.enabled}" disabled="true" />
- </h:column>
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{bundle.IDENTITY_MANAGEMENT_ACTION}"/>
- </f:facet>
- <h:commandLink action="#{editprofilemgr.editProfile}">
- <h:outputText
value="#{bundle.IDENTITY_MANAGEMENT_ACTION_EDIT_PROFILE}"/>
- <f:param name="currentUser" value="#{uiUser.username}"/>
- </h:commandLink> |
- <h:commandLink action="#{assignrolemgr.assignRoles}">
- <h:outputText value="#{bundle.IDENTITY_MANAGEMENT_ACTION_ROLES}"/>
- <f:param name="currentUser" value="#{uiUser.username}"/>
- </h:commandLink> |
- <h:commandLink action="#{useradministrationbean.enableUser}">
- <h:outputText value="#{uiUser.attribute.enabled == true ?
bundle.IDENTITY_MANAGEMENT_DISABLE : bundle.IDENTITY_MANAGEMENT_ENABLE}" />
- <f:param name="currentUser" value="#{uiUser.username}"/>
- <f:param name="enableAction" value="#{uiUser.attribute.enabled ==
true ? 'disable' : 'enable'}" />
- </h:commandLink> |
- <h:commandLink action="#{useradministrationbean.deleteUser}">
- <h:outputText
value="#{bundle.IDENTITY_MANAGEMENT_ACTION_DELETE}"/>
- <f:param name="currentUser" value="#{uiUser.username}"/>
- </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>
</ui:composition>
Modified:
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 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/pendingUsers.xhtml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -8,12 +8,12 @@
<ui:composition template="/WEB-INF/jsf/admin/user/userTemplate.xhtml">
-<ui:define name="title">title TODO pending users</ui:define>
+<ui:define name="title">Pending registrations</ui:define>
<ui:define name="content">
-<h:dataTable value="#{useradministrationbean.pendingUsers}"
var="user">
+<h:dataTable value="#{useradministrationbean.pendingUsers}"
var="user" rowClasses="portlet-section-body,portlet-section-alternate"
headerClass="portlet-section-header" width="100%">
<h:column>
<f:facet name="header">
- <h:outputText value="processId"/>
+ <h:outputText value="id"/>
</f:facet>
<h:outputText value="#{user.processId}"/>
</h:column>
@@ -40,18 +40,18 @@
<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}">
+ <!-- #{user.currentNode == 'adminApproval'} -->
+ <h:commandLink action="#{useradministrationbean.approveRegistration}"
rendered="#{user.currentNode == 'adminApproval'}">
<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:commandLink>
+ <h:outputText value=" | " rendered="#{user.currentNode ==
'adminApproval'}" />
+ <h:commandLink action="#{useradministrationbean.approveRegistration}"
rendered="#{user.currentNode == 'adminApproval'}">
<h:outputText value="reject"/>
<f:param name="processId" value="#{user.processId}" />
<f:param name="action" value="reject" />
- </h:commandLink>
- </c:if>
+ </h:commandLink>
</h:column>
</h:dataTable>
Added:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/searchUsers.xhtml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/searchUsers.xhtml
(rev 0)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/jsf/admin/user/searchUsers.xhtml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -0,0 +1,84 @@
+<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">
+ <h:outputText value="#{bundle.IDENTITY_MANAGEMENT_SEARCH_USER}"/>
+</ui:define>
+<ui:define name="content">
+ <h:form>
+ <h:panelGrid columns="3">
+ <h:inputText id="searchString"
value="#{useradministrationbean.searchString}" />
+ <h:commandButton value="Search"
action="#{useradministrationbean.searchUsers}"
styleClass="portlet-form-button"/>
+ <h:selectOneMenu id="limit"
value="#{useradministrationbean.limit}">
+ <f:selectItem id="limit1" itemValue="10"/>
+ <f:selectItem id="limit2" itemValue="20"/>
+ <f:selectItem id="limit5" itemValue="50"/>
+ <f:selectItem id="limit10" itemValue="100"/>
+ </h:selectOneMenu>
+ </h:panelGrid>
+ </h:form>
+ <hr/>
+
+ <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}"/>
+ </f:facet>
+ <h:outputText value="#{uiUser.username}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{bundle.IDENTITY_GIVENNAME}"/>
+ </f:facet>
+ <h:outputText value="#{uiUser.attribute.givenname}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{bundle.IDENTITY_FAMILYNAME}"/>
+ </f:facet>
+ <h:outputText value="#{uiUser.attribute.familyname}"/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{bundle.IDENTITY_ENABLED}"/>
+ </f:facet>
+ <h:selectBooleanCheckbox id="enabled"
value="#{uiUser.attribute.enabled}" disabled="true" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{bundle.IDENTITY_MANAGEMENT_ACTION}"/>
+ </f:facet>
+ <h:commandLink action="#{editprofilemgr.editProfile}">
+ <h:outputText
value="#{bundle.IDENTITY_MANAGEMENT_ACTION_EDIT_PROFILE}"/>
+ <f:param name="currentUser" value="#{uiUser.username}"/>
+ </h:commandLink> |
+ <h:commandLink action="#{assignrolemgr.assignRoles}">
+ <h:outputText value="#{bundle.IDENTITY_MANAGEMENT_ACTION_ROLES}"/>
+ <f:param name="currentUser" value="#{uiUser.username}"/>
+ </h:commandLink> |
+ <h:commandLink action="#{useradministrationbean.enableUser}">
+ <h:outputText value="#{uiUser.attribute.enabled == true ?
bundle.IDENTITY_MANAGEMENT_DISABLE : bundle.IDENTITY_MANAGEMENT_ENABLE}" />
+ <f:param name="currentUser" value="#{uiUser.username}"/>
+ <f:param name="enableAction" value="#{uiUser.attribute.enabled ==
true ? 'disable' : 'enable'}" />
+ </h:commandLink> |
+ <h:commandLink action="#{useradministrationbean.deleteUser}">
+ <h:outputText
value="#{bundle.IDENTITY_MANAGEMENT_ACTION_DELETE}"/>
+ <f:param name="currentUser" value="#{uiUser.username}"/>
+ </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"/>
+ <br/>
+</ui:define>
+</ui:composition>
+</div>
\ No newline at end of file
Modified:
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet-instances.xml
===================================================================
---
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet-instances.xml 2007-08-28
16:08:00 UTC (rev 8070)
+++
trunk/core-identity/src/resources/portal-identity-war/WEB-INF/portlet-instances.xml 2007-08-28
17:50:11 UTC (rev 8071)
@@ -37,12 +37,14 @@
<instance>
<instance-id>CoreIdentityAdminPortletInstance</instance-id>
<portlet-ref>CoreIdentityAdminPortlet</portlet-ref>
+<!--
<security-constraint>
<policy-permission>
<role-name>Admin</role-name>
<action-name>view</action-name>
</policy-permission>
</security-constraint>
+ -->
</instance>
</deployment>
</deployments>
\ No newline at end of file