1 19 20 package com.sslexplorer.security; 21 22 import javax.servlet.http.HttpServletRequest ; 23 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 import com.sslexplorer.core.CoreUtil; 28 import com.sslexplorer.policyframework.PolicyUtil; 29 import com.sslexplorer.table.TableItem; 30 31 37 public class UserItem implements TableItem { 38 39 final static Log log = LogFactory.getLog(UserItem.class); 40 41 private User user; 43 private int numberRoles; 44 45 50 public UserItem(User user) { 51 this.user = user; 52 this.numberRoles = this.user.getRoles().length; 53 } 54 55 61 public int getStatus() { 62 try { 63 return LogonControllerFactory.getInstance().getUserStatus(user); 64 } 65 catch(Exception e) { 66 log.error("Failed to determine user status.", e); 67 return LogonController.ACCOUNT_UNKNOWN; 68 } 69 } 70 71 76 public boolean getAdministrator() { 77 return LogonControllerFactory.getInstance().isAdministrator(user); 78 } 79 80 85 public User getUser() { 86 return user; 87 } 88 89 95 public boolean getEnabled() throws Exception { 96 return PolicyUtil.isEnabled(user); 97 } 98 99 104 public Object getColumnValue(int col) { 105 if(col == 0) { 106 return getUser().getPrincipalName(); 107 } 108 return ""; 109 } 110 111 114 public String getLink() { 115 return "#"; 116 } 117 118 121 public String getOnClick() { 122 return ""; 123 } 124 125 128 public int getNumberRoles() { 129 return numberRoles; 130 } 131 132 135 public void setNumberRoles(int numberRoles) { 136 this.numberRoles = numberRoles; 137 } 138 139 143 public String getSmallIconPath(HttpServletRequest request) { 144 switch (getStatus()) { 145 case LogonController.ACCOUNT_GRANTED: 146 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/userActive.gif"; 147 case LogonController.ACCOUNT_DISABLED: 148 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/userDisabled.gif"; 149 case LogonController.ACCOUNT_LOCKED: 150 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/userLocked.gif"; 151 case LogonController.ACCOUNT_REVOKED: 152 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/userInactive.gif"; 153 case LogonController.ACCOUNT_ACTIVE: 154 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/userOnLine.gif"; 155 default: 156 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/userError.gif"; 157 } 158 } 159 } | Popular Tags |