View Javadoc
1   /**
2    * Copyright By Grandsoft Company Limited.  
3    * 2012-2-28 上午10:19:19
4    */
5   package gboat2.base.bridge.model;
6   
7   import java.io.Serializable;
8   import java.util.HashMap;
9   import java.util.Map;
10  
11  /**
12   * 保存在 Session 中的用户信息对象
13   * 
14   * @date 2012-2-28
15   * @author lysming
16   * @since 1.0
17   */
18  public class UserSession implements Serializable {
19  
20      private static final long serialVersionUID = 1L;
21  
22      /** 在 Session 中保存用户信息的 key:{@value} */
23      public static final String USER_SESSION_KEY = "COM.GLODON.SSO.SESSION.KEY";
24  
25      /** 在 Session 中保存单点登录信息的 key:{@value} */
26      public static final String SSO_SESSION_ID = "sso_session_id";
27  
28      /** 在 Session 中保存权限信息的 key:{@value} */
29      public static final String PRIORITY_KEY = "COM.GLODON.SSO.PRIORITY.KEY";
30  
31      /** 超级管理员的密码:{@value} */
32      public static final String SUPER_PASSWORD = "super";
33  
34      /** 超级管理员的用户名:{@value} */
35      public static final String SUPER_ID = "COM.GLODON.SSO.SUPER";
36      
37      public static final String NAVIGATION_MENU="COM.GLODON.NAVIGATION";
38  
39      /** 用户系统编号 */
40      private String userId;
41  
42      /** 登录账号 */
43      private String loginId;
44  
45      /** 中文名称 */
46      private String userNameZh;
47  
48      /** 英文名称 */
49      private String userNameEn;
50  
51      /** 所属组织编号 */
52      private String organId;
53  
54      /** 所属组织类型 */
55      private String organType;
56  
57      /** 登录 IP */
58      private String loginedIp;
59  
60      /** 用户所属用户组 Code */
61      private String groupCode;
62  
63      /** 用户所属角色 Code */
64      private String roleCode;
65  
66      /** 用户单点登录的 Seesion ID */
67      private String ssoSessionID;
68  
69      /** 系统Id */
70      private String systemId;
71  
72      /** 保存用户扩展信息的 Map*/
73      private Map<String, Object> attributes = new HashMap<String, Object>(1);
74  
75      /** 权限 */
76      private Priority priority;
77  
78      /**
79       * 判断是否具有Operation的权限
80       * 
81       * @param res 访问的操作
82       * @return boolean
83       */
84      public boolean havePriority(Resource res) {
85          if (null == priority) {
86              return false;
87          }
88          return priority.havePriority(res);
89      }
90  
91      /**
92       * @param resourceCode the actionClass name
93       * @return
94       */
95      public String getDataLevelCode(String resourceCode) {
96          return priority.getDataLevelCode(resourceCode);
97      }
98  
99      public String getUserId() {
100         return userId;
101     }
102 
103     public void setUserId(String userId) {
104         this.userId = userId;
105     }
106 
107     public String getLoginId() {
108         return loginId;
109     }
110 
111     public void setLoginId(String loginId) {
112         this.loginId = loginId;
113     }
114 
115     public String getUserNameZh() {
116         return userNameZh;
117     }
118 
119     public void setUserNameZh(String userNameZh) {
120         this.userNameZh = userNameZh;
121     }
122 
123     public String getUserNameEn() {
124         return userNameEn;
125     }
126 
127     public void setUserNameEn(String userNameEn) {
128         this.userNameEn = userNameEn;
129     }
130 
131     public String getOrganId() {
132         return organId;
133     }
134 
135     public void setOrganId(String organId) {
136         this.organId = organId;
137     }
138 
139     public String getOrganType() {
140         return organType;
141     }
142 
143     public void setOrganType(String organType) {
144         this.organType = organType;
145     }
146 
147     public String getLoginedIp() {
148         return loginedIp;
149     }
150 
151     public void setLoginedIp(String loginedIp) {
152         this.loginedIp = loginedIp;
153     }
154 
155     public String getGroupCode() {
156         return groupCode;
157     }
158 
159     public void setGroupCode(String groupCode) {
160         this.groupCode = groupCode;
161     }
162 
163     public String getRoleCode() {
164         return roleCode;
165     }
166 
167     public void setRoleCode(String roleCode) {
168         this.roleCode = roleCode;
169     }
170 
171     public String getSsoSessionID() {
172         return ssoSessionID;
173     }
174 
175     public void setSsoSessionID(String ssoSessionID) {
176         this.ssoSessionID = ssoSessionID;
177     }
178 
179     @SuppressWarnings("unchecked")
180     public <T> T getAttribute(String name) {
181         return (T) attributes.get(name);
182     }
183 
184     public void setAttribute(String name, Object value) {
185         attributes.put(name, value);
186     }
187 
188     public Priority getPriority() {
189         return priority;
190     }
191 
192     public void setPriority(Priority priority) {
193         this.priority = priority;
194     }
195 
196     public String getSystemId() {
197         return systemId;
198     }
199 
200     public void setSystemId(String systemId) {
201         this.systemId = systemId;
202     }
203 
204 }