1 package org.jbpm.webapp.bean; 2 3 import java.util.ArrayList ; 4 import java.util.Iterator ; 5 import java.util.List ; 6 7 import javax.faces.model.SelectItem; 8 9 import org.jbpm.identity.User; 10 import org.jbpm.identity.hibernate.IdentitySession; 11 import org.jbpm.security.Authentication; 12 import org.jbpm.webapp.context.Context; 13 14 public class UserBean { 15 16 String userName; 17 18 public String getUserName() { 19 return userName; 20 } 21 22 public void setUserName(String name) { 23 this.userName = name; 24 } 25 26 public String login() { 27 Authentication.popAuthenticatedActorId(); 29 Authentication.pushAuthenticatedActorId(userName); 30 return "home"; 31 } 32 33 public List getUsers() { 34 IdentitySession identitySession = Context.getPersistenceContext().getIdentitySession(); 35 return identitySession.getUsers(); 36 } 37 38 public List getUserSelectItems() { 39 List userSelectItems = new ArrayList (); 40 41 IdentitySession identitySession = Context.getPersistenceContext().getIdentitySession(); 42 Iterator iter = identitySession.getUsers().iterator(); 43 while (iter.hasNext()) { 44 User user = (User) iter.next(); 45 userSelectItems.add(new UserSelectItem(user)); 46 } 47 48 return userSelectItems; 49 } 50 51 public String getLabel() { 52 return userName; 53 } 54 55 public String getValue() { 56 return userName; 57 } 58 59 public static class UserSelectItem extends SelectItem { 60 private static final long serialVersionUID = 1L; 61 public UserSelectItem(User user) { 62 setValue(user.getName()); 63 setLabel(user.getName()); 64 } 65 } 66 } 67 | Popular Tags |