package com.vci.client.framework.delegate;
|
|
import java.text.Collator;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.Collections;
|
import java.util.Comparator;
|
import java.util.LinkedList;
|
import java.util.List;
|
import java.util.Locale;
|
import org.apache.commons.lang3.StringUtils;
|
|
import com.vci.mw.ClientContextVariable;
|
import com.vci.mw.InvocationUtility;
|
import com.vci.client.ClientSession;
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.objects.ClientInfo;
|
import com.vci.client.common.objects.DeptObject;
|
import com.vci.client.common.objects.RoleObject;
|
import com.vci.client.common.objects.UserEntityObject;
|
import com.vci.client.common.objects.UserLogonObject;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.client.framework.appConfig.object.AppConfigDetailObject;
|
import com.vci.client.framework.systemConfig.object.CombinationObject;
|
import com.vci.client.framework.systemConfig.object.CombinationValueObject;
|
import com.vci.client.framework.systemConfig.object.PasswordStrategyObject;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.common.data.VCIInvocationInfo;
|
import com.vci.corba.framework.data.CombinationInfo;
|
import com.vci.corba.framework.data.CombinationValueInfo;
|
import com.vci.corba.framework.data.DeptInfo;
|
import com.vci.corba.framework.data.PasswordStrategyInfo;
|
import com.vci.corba.framework.data.RoleInfo;
|
import com.vci.corba.framework.data.UserInfo;
|
import com.vci.corba.framework.data.UserLogonInfo;
|
import com.vci.corba.omd.etm.EnumChild;
|
import com.vci.corba.omd.etm.EnumItem;
|
import com.vci.corba.log.data.LogType;
|
|
public class RightManagementClientDelegate extends ClientBaseDelegate {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 2416956441616227002L;
|
|
public RightManagementClientDelegate(UserEntityObject userEntityObject) {
|
super(userEntityObject);
|
}
|
|
public RightManagementClientDelegate() {
|
|
}
|
|
/**
|
* <p>Description:获取所有部门 </p>
|
*
|
* @author wangxl
|
* @time 2012-5-10
|
* @return
|
* @throws VCIError
|
*/
|
public DeptObject[] fetchDepartmentInfo() throws VCIException {
|
|
DeptObject[] deptObj = null ;
|
try {
|
DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfo();
|
if (departmentInfo != null && departmentInfo.length > 0) {
|
deptObj = changeDepartmentInfoToDeptObjects(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
}
|
|
public UserObject[] getUserByDeptId(String deptId) throws VCIException {
|
UserObject[] objs = null;
|
try{
|
UserInfo[] infos = ClientSession.getFrameworkService().getUserByDeptId(deptId);
|
objs = new UserObject[infos.length];
|
for(int i=0;i<infos.length;i++) {
|
objs[i] = changeUserInfoToUserObject(infos[i]);
|
}
|
return objs;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/**
|
* 根据id得到部门
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public DeptObject fetchDepartmentInfoById(String id) throws VCIException {
|
DeptObject deptObj = null;
|
try {
|
DeptInfo departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfoById(id);
|
if (departmentInfo != null) {
|
deptObj = changeDepartmentInfoToDeptObject(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
public DeptObject fetchDeptByUserId(String userId) throws VCIException {
|
DeptObject deptObj = null;
|
try {
|
DeptInfo departmentInfo = ClientSession.getFrameworkService().fetchDeptByUserId(userId);
|
if (!"".equals(departmentInfo.id)){
|
deptObj = changeDepartmentInfoToDeptObject(departmentInfo);
|
}
|
|
return deptObj;
|
}catch (VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
public DeptObject fetchDeptByDeptName(String deptName) throws VCIException {
|
DeptObject deptObj = null;
|
try {
|
DeptInfo departmentInfo = ClientSession.getFrameworkService().fetchDeptByDeptName(deptName);
|
if (!"".equals(departmentInfo.id)){
|
deptObj = changeDepartmentInfoToDeptObject(departmentInfo);
|
}
|
|
return deptObj;
|
}catch (VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**
|
* 返回顶级部门
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public DeptObject[] fetchDepartmentInfoRoot() throws VCIException {
|
DeptObject[] deptObj = null ;
|
try {
|
DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfoRoot();
|
if (departmentInfo != null && departmentInfo.length > 0) {
|
deptObj = changeDepartmentInfoToDeptObjects(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
/**
|
* 返回部门下的子部门
|
*
|
* @param prtoid
|
* @return
|
* @throws VCIError
|
*/
|
public DeptObject[] fetchDepartmentInfoByParentId(String prtoid) throws VCIException {
|
DeptObject[] deptObj = null ;
|
try {
|
DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfoByParentId(prtoid);
|
if (departmentInfo != null && departmentInfo.length > 0) {
|
deptObj = changeDepartmentInfoToDeptObjects(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
/**
|
* 返回部门及其子部门
|
*
|
* @param id
|
* @return
|
* @throws VCIError
|
*/
|
public DeptObject[] fetchDepartmentInfosById(String id) throws VCIException {
|
DeptObject[] deptObj = null ;
|
try {
|
DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfosById(id);
|
if (departmentInfo != null && departmentInfo.length > 0) {
|
deptObj = changeDepartmentInfoToDeptObjects(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
public DeptObject[] fetchDepartmentInfosBySonId(String id) throws VCIException {
|
DeptObject[] deptObj = null ;
|
try {
|
DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfosBySonId(id);
|
if (departmentInfo != null && departmentInfo.length > 0) {
|
deptObj = changeDepartmentInfoToDeptObjects(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
public DeptObject[] fetchDeptByUserNames(String[] userNames) throws VCIException {
|
DeptInfo[] departmentInfo = null;
|
try{
|
departmentInfo = ClientSession.getFrameworkService().fetchDeptByUserNames(userNames);
|
return changeDepartmentInfoToDeptObjects(departmentInfo);
|
}catch(VCIError e) {
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public RoleObject fetchRoleInfoById(String roleId) throws VCIException {
|
try{
|
RoleInfo roleInfo = ClientSession.getFrameworkService().fetchRoleInfoById(roleId);
|
return changeRoleInfoToRoleObject(roleInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
|
}
|
public RoleObject fetchRoleByName(String name) throws VCIException {
|
try{
|
RoleInfo roleInfo = ClientSession.getFrameworkService().fetchRoleByName(name);
|
return changeRoleInfoToRoleObject(roleInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
|
}
|
/***
|
* 得到所有角色
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public RoleObject[] fetchRoleInfo() throws VCIException {
|
try{
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfo();
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
return roleObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public RoleObject[] fetchRoleInfoByUserName (String userName) throws VCIException {
|
try{
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfoByUserName(userName);
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
return roleObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public RoleObject[] fetchRoleInfoByUserType (String userName) throws VCIException {
|
try{
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfoByUserType(userName);
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
return roleObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**根据用户名和指定的页数获取用户角色**/
|
public RoleObject[] fetchRoleInfoByUserName (int pageNo,int pageSize,String userName) throws VCIException {
|
try{
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfoByUserNameAndPage(pageNo, pageSize, userName);
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
List<RoleObject> roleList=Arrays.asList(roleObject);
|
Collections.sort(roleList, new NameComparator());
|
//Collections.sort(roleList, Collator.getInstance(Locale.CHINA));
|
RoleObject[] roleObject1=(RoleObject[]) roleList.toArray();
|
return roleObject1;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**根据用户名获取用户角色总数**/
|
public int getRoleTotalByUserName(String userName) throws VCIException {
|
int total = 0;
|
try {
|
total = (int)ClientSession.getFrameworkService().getRoleTotalByUserName(userName);
|
}catch (VCIError e) {
|
this.convertVCIErrorToVCIException(e);
|
}
|
return total;
|
}
|
|
/**
|
* <p>Description:用于验证角色是否被引用 </p>
|
*
|
* @author wangxl
|
* @time 2012-5-10
|
* @param id
|
* @return
|
* @throws VCIError
|
*/
|
public int checkRoleIsquotedCount(String id) throws VCIException{
|
try{
|
return (int)ClientSession.getFrameworkService().checkRoleIsquotedCount(id);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
|
/***
|
* 获取普通用户所属的角色
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public RoleObject[] fetchNormalRoles() throws VCIException {
|
try {
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfo();
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
List<RoleObject> roleList = new LinkedList<RoleObject>();
|
for(RoleObject role : roleObject) {
|
if(role.getType() == 2) {
|
roleList.add(role);
|
}
|
}
|
return roleList.toArray(new RoleObject[0]);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/***
|
* 根据用户类型获取角色
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public RoleObject[] fetchRoleInfoByType(int type) throws VCIException {
|
try {
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfoByType((short)type);
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
return roleObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/***
|
* 根据角色类型获取角色
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public RoleObject[] fetchRoleInfoByRoleType(int type) throws VCIException {
|
try {
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfoByRoleType((short)type);
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
return roleObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/**
|
* 检测设备角色
|
* @param type
|
* @return
|
* @throws VCIError
|
*/
|
public RoleObject[] getRoleListByTypeForMeasure(int type) throws VCIException {
|
try {
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().getRoleListByTypeForMeasure((short)type);
|
int length = roleInfo.length;
|
RoleObject[] roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
return roleObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public RoleObject[] fetchRoleInfoByUserId(String userId) throws VCIException {
|
RoleObject[] roleObject = null;
|
try{
|
RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfoByUserId(userId);
|
int length = roleInfo.length;
|
roleObject = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]);
|
}
|
return roleObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
/**
|
*
|
* <p>获取该型号下的型号总师: </p>
|
*
|
* @time 2013-3-28
|
* @param modelId 型号ID
|
* @return
|
* @throws VCIException
|
*/
|
public UserObject[] fetchUserInfoByModelId(String modelId) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByModelId(modelId);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/**
|
* 通过型号获取型号总师
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-3-30
|
* @param model
|
* @return
|
* @throws VCIException
|
*/
|
public UserObject[] fetchUserInfoByModel(String model) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByModel(model);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/***
|
* 得到所有成员
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject[] fetchUserInfo() throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfo();
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/***
|
* 得到除 三员,admin,developer外的所有成员
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject[] fetchUserInfoWithOutSanYuan() throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoWithOutSanYuan();
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public UserObject[] fetchUserInfoByCondition(String searchName , String searchUserName , String deptId, String roleId,String userName,int pageNo,int pageSize) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByCondition(searchName ,searchUserName , deptId, roleId ,userName,pageNo,pageSize);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
List<UserObject> userList=Arrays.asList(userObject);
|
Collections.sort(userList, new UserNameComparator());
|
UserObject[] userObject1=(UserObject[]) userList.toArray();
|
return userObject1;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public UserObject[] fetchNormalUserInfoByCondition(String searchName,
|
String searchUserName, String deptId, String roleId,
|
String userName, int pageNo, int pageSize) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchNormalUserInfoByCondition(searchName ,searchUserName , deptId, roleId ,userName,pageNo,pageSize);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
List<UserObject> userList=Arrays.asList(userObject);
|
Collections.sort(userList, new UserNameComparator());
|
UserObject[] userObject1=(UserObject[]) userList.toArray();
|
return userObject1;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
//add by caill start 2016.9.26
|
public UserObject[] fetchUserInfoByConditionUnited(String searchName , String searchUserName , String deptId, String roleId,String userName,int pageNo,int pageSize) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByConditionUnited(searchName ,searchUserName , deptId, roleId ,userName,pageNo,pageSize);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
List<UserObject> userList=Arrays.asList(userObject);
|
Collections.sort(userList, new UserNameComparator());
|
UserObject[] userObject1=(UserObject[]) userList.toArray();
|
return userObject1;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
//add by caill end
|
public int getUserTotalByCondition(String searchName,String searchUserName, String deptId, String roleId, String userName) throws VCIException {
|
int total = 0;
|
try {
|
total = (int)ClientSession.getFrameworkService().getUserTotalByCondition(searchName, searchUserName, deptId, roleId, userName);
|
}catch(VCIError e) {
|
this.convertVCIErrorToVCIException(e);
|
}
|
return total;
|
|
}
|
|
//add by weidy start 2021-05-13
|
public UserObject[] fetchNormalUserInfoByConditionUnited(String searchName , String searchUserName , String deptId, String roleId,String userName,int pageNo,int pageSize) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchNoramlUserInfoByConditionUnited(searchName ,searchUserName , deptId, roleId ,userName,pageNo,pageSize);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
List<UserObject> userList=Arrays.asList(userObject);
|
Collections.sort(userList, new UserNameComparator());
|
UserObject[] userObject1=(UserObject[]) userList.toArray();
|
return userObject1;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
public int getNormalUserTotalByCondition(String searchName,String searchUserName, String deptId, String roleId, String userName) throws VCIException {
|
int total = 0;
|
try {
|
total = (int)ClientSession.getFrameworkService().getNormalUserTotalByCondition(searchName, searchUserName, deptId, roleId, userName);
|
}catch(VCIError e) {
|
this.convertVCIErrorToVCIException(e);
|
}
|
return total;
|
|
}
|
//end
|
/***
|
* 得到所有成员
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject[] fetchUserInfoByType(int type) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByType((short)type);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
public UserObject[] fetchUsersByRoleId(String roleId) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUsersByRoleId(roleId);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/**
|
* <p>Description: 根据用户名获取将要被锁定的用户</p>
|
*
|
* @author wangxl
|
* @time 2012-5-24
|
* @param userName
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject getUserObjToLock(String userName) throws VCIException {
|
return this.fetchUserInfoByName(userName);
|
}
|
/***
|
* 根据用户名获取成员
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject fetchUserInfoByName(String userName) throws VCIException {
|
try{
|
UserInfo userInfo = ClientSession.getFrameworkService().fetchUserInfoByName(userName);
|
UserObject userObject = new UserObject();
|
userObject = changeUserInfoToUserObject(userInfo);
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
|
public UserLogonObject getUserLogonObj(String userId) throws VCIException {
|
try{
|
UserLogonInfo info = ClientSession.getFrameworkService().fetchUserLogonObj(userId);
|
return transferCorbaObjToUserLogonObj(info);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/**
|
* 根据角色id和用户类型获取成员
|
* @param roleId
|
* @param type
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject[] fetchUserInfoByRoleId(String roleId , int type ) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByRoleId( roleId ,(short)type);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
public UserObject[] fetchUserInfoByDeptAndRole(String[] deptIds , String[] roleIds ) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByDeptAndRole( deptIds ,roleIds);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/**
|
* 创建角色和用户的关系
|
* @param roleId
|
* @param userIds
|
* @return
|
* @throws VCIError
|
*/
|
public boolean saveRight(String roleId ,String[] userIds) throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().saveRight(roleId , userIds , userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* 保存三员的成员
|
* @param roleId
|
* @param userIds
|
* @return
|
* @throws VCIException
|
*/
|
public boolean saveSpecialRole(String roleId ,String[] userIds) throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().saveSpecialRole(roleId , userIds , userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public boolean saveRighForDept(String deptId ,String[] userIds) throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().saveRighForDept(deptId , userIds , userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**
|
* 创建角色和用户的关系
|
* @param roleId
|
* @param userIds
|
* @return
|
* @throws VCIError
|
*/
|
public boolean saveRights(String[] roleIds ,String[] userIds) throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().saveRights(roleIds , userIds , userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public boolean saveUserDept(String[] userIds ,String deptId) throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().saveUserDept(userIds , deptId , userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/***
|
* 增加部门
|
*
|
* @param
|
* @return
|
* @throws VCIError
|
*/
|
public String saveDepartment(DeptObject DeptObject) throws VCIException {
|
try{
|
DeptInfo departmentInfo = changeDeptObjectToDepartmentInfo(DeptObject);
|
String id = ClientSession.getFrameworkService().saveDepartment(departmentInfo,userEntityInfo);
|
return id;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/**
|
* 批量保存部门
|
* @param deptObjects
|
* @return
|
* @throws VCIException
|
*/
|
public boolean batchsaveDepartment(DeptObject[] deptObjects) throws VCIException {
|
boolean rs = false;
|
try{
|
DeptInfo[] depts = new DeptInfo[deptObjects.length];
|
for (int i = 0; i < depts.length; i++) {
|
depts[i] = changeDeptObjectToDepartmentInfo(deptObjects[i]);
|
}
|
rs = ClientSession.getFrameworkService().batchSaveDepart(depts, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
return rs;
|
}
|
|
//add by caill start 2016.1.20
|
/***
|
* 增加角色
|
*
|
* @param
|
* @return
|
* @throws VCIError
|
*/
|
public boolean batchSaveRoles(RoleObject[] roleObjects) throws VCIError {
|
try{
|
int len = roleObjects.length;
|
RoleInfo[] roleInfos = new RoleInfo[len];
|
for(int i = 0 ; i<len ; i++){
|
RoleObject obj = roleObjects[i];
|
RoleInfo roleInfo = changeRoleObjectToRoleInfo(obj);
|
roleInfos[i] = roleInfo;
|
}
|
boolean b = ClientSession.getFrameworkService().batchSaveRoles(roleInfos,userEntityInfo);
|
return b;
|
}catch(VCIError e){
|
throw new VCIError(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
//add by caill end
|
/***
|
* 增加角色
|
*
|
* @param
|
* @return
|
* @throws VCIError
|
*/
|
public String saveRole(RoleObject roleObject) throws VCIException {
|
try{
|
RoleInfo roleInfo = changeRoleObjectToRoleInfo(roleObject);
|
String id = ClientSession.getFrameworkService().saveRole(roleInfo,userEntityInfo);
|
return id;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public UserObject[] selectUserByRoleId(String id) throws VCIException {
|
try{
|
UserInfo[] user = ClientSession.getFrameworkService().selectUserByRoleId(id);
|
return changeRoleInfoToRoleObject(user);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public UserObject[] selectRole(String id) throws VCIException {
|
try{
|
UserInfo[] user = ClientSession.getFrameworkService().selectUserByRoleId(id);
|
return changeRoleInfoToRoleObject(user);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
private UserObject[] changeRoleInfoToRoleObject(UserInfo[] user) {
|
int length = user.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(user[i]);
|
}
|
return userObject;
|
}
|
|
|
/***
|
* 增加成员
|
*
|
* @param
|
* @return
|
* @throws VCIError
|
*/
|
public String saveUser(UserObject userObject) throws VCIException {
|
try{
|
UserInfo userInfo = changeUserObjectToUserInfo(userObject);
|
String id = ClientSession.getFrameworkService().saveUser(userInfo,userEntityInfo);
|
return id;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/***
|
* 增加成员
|
*
|
* @param
|
* @return
|
* @throws VCIError
|
*/
|
public boolean batchSaveUsers(UserObject[] userObjects,String[][] deptAndUserRelation) throws VCIError {
|
try{
|
int len = userObjects.length;
|
UserInfo[] userInfos = new UserInfo[len];
|
for(int i = 0 ; i<len ; i++){
|
UserObject obj = userObjects[i];
|
UserInfo userInfo = changeUserObjectToUserInfo(obj);
|
userInfos[i] = userInfo;
|
}
|
boolean b = ClientSession.getFrameworkService().batchSaveUsers(userInfos,deptAndUserRelation,userEntityInfo);
|
return b;
|
}catch(VCIError e){
|
throw new VCIError(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/**
|
* 修改部门
|
*
|
* @param DeptObject
|
* @param userEntityObject
|
* @return
|
* @throws VCIError
|
*/
|
public boolean updateDepartment(DeptObject DeptObject) throws VCIException {
|
try{
|
DeptInfo departmentInfo = changeDeptObjectToDepartmentInfo(DeptObject);
|
return ClientSession.getFrameworkService().updateDepartment(departmentInfo, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**
|
* 更改部门对象的父ID
|
* @param id
|
* @param parentId
|
* @return
|
* @throws VCIException
|
*/
|
public boolean updateDepartmentParentId(String id, String parentId) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().updateDeptParentId(id, parentId, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**
|
* 修改角色
|
*
|
* @param roleObject
|
* @return
|
* @throws VCIError
|
*/
|
public boolean updateRole(RoleObject roleObject) throws VCIException {
|
try{
|
RoleInfo roleInfo = changeRoleObjectToRoleInfo(roleObject);
|
return ClientSession.getFrameworkService().updateRole(roleInfo, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/**
|
* 添加、修改成员
|
*
|
* @param userObject
|
* @return
|
* @throws VCIError
|
*/
|
public boolean saveOrUpdateUser(UserObject userObject) throws VCIException {
|
try{
|
UserInfo userInfo = changeUserObjectToUserInfo(userObject);
|
return ClientSession.getFrameworkService().saveOrUpdateUser(userInfo, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/**
|
* 修改成员
|
*
|
* @param userObject
|
* @return
|
* @throws VCIError
|
*/
|
public boolean updateUser(UserObject userObject) throws VCIException {
|
try{
|
UserInfo userInfo = changeUserObjectToUserInfo(userObject);
|
return ClientSession.getFrameworkService().updateUser(userInfo, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/***
|
* 删除部门
|
*
|
* @param id
|
* @return
|
* @throws VCIError
|
*/
|
public boolean deleteDepartment(String[] id) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().deleteDepartment(id, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/***
|
* 删除角色
|
*
|
* @param id
|
* @return
|
* @throws VCIError
|
*/
|
public boolean deleteRole(String[] id) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().deleteRole(id, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
/***
|
* 删除成员
|
*
|
* @param id
|
* @return
|
* @throws VCIError
|
*/
|
public boolean deleteUser(String[] id) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().deleteUser(id, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* <p>Description:停用 </p>
|
*
|
* @author wangxl
|
* @time 2012-5-14
|
* @param id
|
* @return
|
* @throws VCIError
|
*/
|
public boolean stopUsers(String[] id , boolean flag) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().stopUsers(id, flag, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/**
|
* <p>Description:获取所有密级策略 </p>
|
*
|
* @author wangxl
|
* @time 2012-5-21
|
* @return
|
* @throws VCIError
|
*/
|
public PasswordStrategyObject[] fetchAllPasswordStrategy() throws VCIException {
|
try{
|
PasswordStrategyInfo[] psdStgIndo = ClientSession.getFrameworkService().fetchAllPasswordStrategy();
|
return this.changePasswordStrategyInfoToObjs(psdStgIndo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public PasswordStrategyObject[] fetchAllPasswordStrategy(int pageNo,int pageSize) throws VCIException {
|
try{
|
PasswordStrategyInfo[] psdStgIndo = ClientSession.getFrameworkService().fetchAllPasswordStrategyByPage(pageNo, pageSize);
|
return this.changePasswordStrategyInfoToObjs(psdStgIndo);
|
}catch(VCIError e){
|
this.convertVCIErrorToVCIException(e);
|
}
|
return null;
|
|
}
|
|
public int getPasswordStrategyTotal() throws VCIException {
|
int total = 0;
|
try {
|
total = (int)ClientSession.getFrameworkService().getPasswordStrategyTotal();
|
}catch(VCIError e){
|
this.convertVCIErrorToVCIException(e);
|
}
|
return total;
|
}
|
|
public boolean savePasswordStrategy(PasswordStrategyObject obj) throws VCIException {
|
try{
|
PasswordStrategyInfo info = new PasswordStrategyInfo();
|
info = this.changePasswordStrategyObjToInfo(obj);
|
return ClientSession.getFrameworkService().savePasswordStrategy(info, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public boolean editPasswordStrategy(PasswordStrategyObject obj) throws VCIException {
|
try{
|
PasswordStrategyInfo info = new PasswordStrategyInfo();
|
info = this.changePasswordStrategyObjToInfo(obj);
|
return ClientSession.getFrameworkService().editPasswordStrategy(info, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
public boolean deletePasswordStrategy(String ids[]) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().deletePasswordStrategy(ids, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public int checkPasswordStrategyIsquotedCount(String id )throws VCIException {
|
try{
|
return (int)ClientSession.getFrameworkService().checkPasswordStrategyIsquotedCount(id);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
public PasswordStrategyObject fetchPasswordStrategyByUserId(String userId) throws VCIException {
|
try{
|
return this.changePasswordStrategyInfoToObj(ClientSession.getFrameworkService().fetchPasswordStrategyByUserId(userId));
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
}
|
|
public boolean saveUserPasswordStrateg(String[] userIds ,String passwordStrategId) throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().saveUserPasswordStrateg(userIds , passwordStrategId , userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
public String checkPasswordStrategyByUserId(String userId, String password) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().checkPasswordStrategyByUserId(userId, password, userEntityInfo);
|
} catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
public void updateLogonInfo(String userId,boolean flag) throws VCIException{
|
try{
|
ClientSession.getFrameworkService().updateLogonInfo(userId,flag);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
public UserObject getUserObjectByUserName(String userName) throws VCIException{
|
UserObject userObj = null;
|
try{
|
UserInfo info = ClientSession.getFrameworkService().getUserObjectByUserName(userName);
|
if (!"".equals(info.id)){
|
userObj = changeUserInfoToUserObject(info);
|
}
|
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
if (userObj != null && !checkAdminLogin(userObj))
|
throw new VCIException("120414");
|
|
return userObj;
|
}
|
|
public UserObject checkLogin(String userName ,String password, ClientInfo clientInfo)throws VCIException{
|
UserObject userObj = null;
|
try{
|
UserInfo info = ClientSession.getFrameworkService().checkLogin(userName , password);
|
if (!"".equals(info.id)){
|
userObj = changeUserInfoToUserObject(info);
|
String ip = clientInfo.getIp();
|
UserEntityObject entityObj = new UserEntityObject(userName, ip);
|
LogonApplication.userEntityObject = entityObj;
|
initContextInfo(info, clientInfo, false);
|
}
|
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
if (userObj != null && !checkAdminLogin(userObj))
|
throw new VCIException("120414");
|
|
return userObj;
|
}
|
|
/**
|
* 获取已登录用户的VCIInvocation对象实例
|
* <p>每次调用都将返回一个新实例</p>
|
* @param userObj
|
* @param clientInfo
|
* @return
|
* @throws VCIException
|
* @author xiongchao
|
* @since 2017.12.13
|
*/
|
@Deprecated
|
public VCIInvocationInfo getLogonedUserInvocationInfo(UserObject userObj, ClientInfo clientInfo) throws VCIException {
|
return getLogonedUserInvocationInfo(userObj, clientInfo, false);
|
}
|
/**
|
* 获取已登录用户的VCIInvocation对象实例
|
* <p>每次调用都将返回一个新实例</p>
|
* @param userObj
|
* @param clientInfo
|
* @param forBS 是否是来自Web端中执行登录后,返回已登录用户的VCIInvocationInfo,
|
* <p>当是来自于Web端时,每次返回的 VCIInvocationInfo 都是全新的实例</p>
|
* <p>当是来自富客户端时,每个富客户端应用都是在单独的进程中,所以classpath都是单独的JVM中,</p>
|
* <p>因此此时返回的VCIInvocationInfo是InvocationUtility.initInvocationInfo()</p>
|
*
|
* @return
|
* @throws VCIException
|
* @author xiongchao
|
* @since 2017.12.13
|
* @last_update_date 2018.01.23
|
*/
|
public VCIInvocationInfo getLogonedUserInvocationInfo(UserObject userObj, ClientInfo clientInfo, boolean forBS) throws VCIException {
|
UserInfo user = changeUserObjectToUserInfo(userObj);
|
//登陆用户角色信息
|
RoleObject[] roles = new RightManagementClientDelegate().fetchRoleInfoByUserId(user.id);
|
//登陆用户组信息
|
DeptObject groupInfo = new RightManagementClientDelegate().fetchDeptByUserId(user.id);
|
|
List<String> roleList = new ArrayList<String>();
|
String[] roleIds = new String[roles.length];
|
String[] roleNames = new String[roles.length];
|
int i = 0;
|
for (RoleObject role : roles) {
|
String s = role.getName() + ":" + role.getId();
|
roleList.add(s);
|
roleIds[i] = role.getId();
|
roleNames[i] = role.getName();
|
i++;
|
}
|
|
VCIInvocationInfo vcii = null;
|
if(forBS){
|
vcii = new VCIInvocationInfo();
|
vcii.extAttribs = new String[0];
|
vcii.groupIDs = new String[0];
|
vcii.groupNames = new String[0];
|
vcii.roleIDs = new String[0];
|
vcii.roleNames = new String[0];
|
} else {
|
vcii = InvocationUtility.initInvocationInfo();
|
}
|
vcii.userID = user.id;
|
vcii.userName = user.userName;
|
vcii.trueName = user.trueName;
|
vcii.roleIDs = roleIds;
|
vcii.roleNames = roleNames;
|
vcii.secretGrade = user.secretGrade == null ? "" : user.secretGrade;
|
vcii.email = user.email == null ? "" : user.email;
|
String language = Locale.getDefault().getLanguage();
|
if (language == null) {
|
language = "";
|
}
|
vcii.language = language;
|
|
String country = Locale.getDefault().getCountry();
|
if (country == null) {
|
country = "";
|
}
|
vcii.country = country;
|
String groupNum = "";
|
String groupName = "";
|
if (groupInfo == null) {
|
vcii.groupIDs = new String[0];
|
vcii.groupNames = new String[0];
|
} else {
|
vcii.groupIDs = new String[]{groupInfo.getId()};
|
vcii.groupNames = new String[]{groupInfo.getName()};
|
groupNum = groupInfo.getNum();
|
groupName = groupInfo.getName();
|
}
|
|
vcii.clientIPInfo = clientInfo.getIp() == null ? "" : clientInfo.getIp();
|
vcii.clientMachine = clientInfo.getMachine() == null ? "" : clientInfo.getMachine();
|
vcii.clientOS = clientInfo.getOs() == null ? "" : clientInfo.getOs();
|
vcii.clientOSUser = clientInfo.getOsUser() == null ? "" : clientInfo.getOsUser();
|
|
String ipDefSrcet = getIPSecurityEnumMinValue();
|
UserEntityObject userEntityObject = new UserEntityObject();
|
userEntityObject.setIp(clientInfo.getIp());
|
userEntityObject.setUserName(user.userName);
|
userEntityObject.setModules("登录");
|
AppConfigDetailClientDelegate accd = new AppConfigDetailClientDelegate(userEntityObject);
|
AppConfigDetailObject ipSecSwitch = accd.getAppConfigDetailByKey("ipSecuritySwitch");
|
AppConfigDetailObject userSecSwitch = accd.getAppConfigDetailByKey("userSecuritySwith");
|
String ipSecSwitchVal = ("".equals(ipSecSwitch.getId()) ? "off":ipSecSwitch.getValue());
|
String userSecSwitchVal = ("".equals(userSecSwitch.getId()) ? "off":userSecSwitch.getValue());
|
String[] currentUserInfos = new String[10];
|
currentUserInfos[0] = "CURRENTUSER.ID=" + user.id;
|
currentUserInfos[1] = "CURRENTUSER.NAME=" + user.userName;
|
currentUserInfos[2] = "CURRENTUSER.SECRETGRADE=" + user.secretGrade;
|
currentUserInfos[3] = "CURRENTUSER.EMAIL=" + user.email;
|
currentUserInfos[4] = "CURRENTUSER.GROUPNUM=" + groupNum;
|
currentUserInfos[5] = "CURRENTMACHINE.SECRET=" + ipDefSrcet;
|
currentUserInfos[6] = "IPSECRETSWITCH=" + ipSecSwitchVal;
|
currentUserInfos[7] = "CURRENTUSER.GROUPNAME=" + groupName;
|
currentUserInfos[8] = "USERSECRETSWITCH=" + userSecSwitchVal;
|
currentUserInfos[9] = String.valueOf(System.currentTimeMillis());
|
|
if("on".equalsIgnoreCase(ipSecSwitchVal)){
|
String ipSecret = getIpSecret(vcii.clientIPInfo, ipDefSrcet);
|
currentUserInfos[5] = "CURRENTMACHINE.SECRET=" + ipSecret;
|
}
|
vcii.extAttribs = currentUserInfos;
|
return vcii;
|
}
|
@Deprecated
|
public void initContextInfo(UserInfo user, ClientInfo clientInfo) throws VCIException {
|
initContextInfo(user, clientInfo, false);
|
}
|
public void initContextInfo(UserInfo user, ClientInfo clientInfo, boolean forBS) throws VCIException {
|
VCIInvocationInfo vcii = getLogonedUserInvocationInfo(changeUserInfoToUserObject(user), clientInfo, forBS);
|
ClientContextVariable.setInvocationInfo(vcii);
|
// 将用户登录信息存储到缓存结构
|
ClientContextVariable.setUserMap(user.userName, vcii);
|
ClientContextVariable.setFrame(LogonApplication.frame);
|
}
|
|
/**
|
* 检查是否是管理员登录
|
* @param user
|
* @return
|
*/
|
private boolean checkAdminLogin(UserObject user){
|
try {
|
boolean bAdminLogon = new SystemCfgClientDelegate(new UserEntityObject("", "")).getConfigValue("logon.Admin").equalsIgnoreCase("true");
|
|
if (!bAdminLogon)
|
return true;
|
|
// 用户等级<2为管理员帐号
|
if (user.getUserType() < 2)
|
return true;
|
|
} catch (Exception e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
|
return true;
|
}
|
return false;
|
}
|
|
/**
|
* 获取IP密级的最小值
|
* @return
|
*/
|
private String getIPSecurityEnumMinValue(){
|
// 使用IP密级枚举的最小值
|
EnumItem enumItem;
|
try {
|
enumItem = ServiceProvider.getOMDService().getEnumService().getEmItemByName("ipsecurityenum");
|
List<EnumChild> childs = new LinkedList<EnumChild>();
|
if(enumItem == null || enumItem.children.length == 0) return "10";
|
for(EnumChild child : enumItem.children){
|
childs.add(child);
|
}
|
Collections.sort(childs, new Comparator<EnumChild>() {
|
@Override
|
public int compare(EnumChild o1, EnumChild o2) {
|
return Integer.valueOf(o1.value).compareTo(Integer.valueOf(o2.value));
|
}
|
});
|
return childs.get(0).value;
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
return "10";
|
}
|
|
/*
|
* 默认返回密级"10"
|
* */
|
private String getIpSecret(String ip, String ipDefSrcet) {
|
if (ip == null || ip.equals("")) {
|
return ipDefSrcet;
|
}
|
try {
|
int srcet = (int)ClientSession.getFrameworkService().getMachSecurity(ip, (short)0, userEntityInfo);
|
|
if (srcet == 0)
|
return ipDefSrcet;
|
else
|
return String.format("%d", srcet);
|
|
// QueryTemplate qt = new QueryTemplate();
|
// qt.setId("queryBtm");
|
// qt.setType(QTConstants.TYPE_BTM);
|
// qt.setBtmType("ipsecurity");
|
// List<String> clauseList = new ArrayList<String>();
|
// clauseList.add("*");
|
// // 对于IP密级查询忽略数据授权
|
// qt.setRightFlag(false);
|
// qt.setClauseList(clauseList);
|
//
|
// Map<String, String> map = new HashMap<String, String>();
|
// map.put("startip", ip);
|
// Condition condition = plm.oq.objectQuery.common.Tool.getCondition(map);
|
// qt.setCondition(condition);
|
// BusinessObject[] bos = QTClient.getService().findBTMObjects(qt.getId(), plm.oq.objectQuery.common.Tool.qtTOXMl(qt).asXML());
|
// if (bos.length == 0) {
|
// return ipDefSrcet;
|
// }
|
// String value = ObjectTool.getBOAttributeValue(bos[0], "ipsecret");
|
// if (value == null || value.trim().equals("")) {
|
// return ipDefSrcet;
|
// } else {
|
// return value;
|
// }
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return ipDefSrcet;
|
}
|
|
// private String getIpVerifySwitch() {
|
// try {
|
// QueryTemplate qt = new QueryTemplate();
|
// qt.setId("queryBtm");
|
// qt.setType(QTConstants.TYPE_BTM);
|
// qt.setBtmType("ipstopmanager");
|
// List<String> clauseList = new ArrayList<String>();
|
// clauseList.add("*");
|
// qt.setClauseList(clauseList);
|
//
|
// BusinessObject[] bos = QTClient.getService().findBTMObjects(qt.getId(), plm.oq.objectQuery.common.Tool.qtTOXMl(qt).asXML());
|
// if (bos.length == 0) {
|
// return "";
|
// }
|
// return ObjectTool.getBOAttributeValue(bos[0], "enable");
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
// return "";
|
// }
|
|
public UserObject checkLoginForBS(String userName ,String password, ClientInfo clientInfo)throws VCIException{
|
UserObject userObj = null;
|
try{
|
UserInfo info = ClientSession.getFrameworkService().checkLoginForBS(userName , password);
|
if (!"".equals(info.id)){
|
userObj = changeUserInfoToUserObject(info);
|
initContextInfo(info, clientInfo, true);
|
}
|
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
return userObj;
|
}
|
|
public void deblock(String[] ids)throws VCIException{
|
try{
|
ClientSession.getFrameworkService().deblock(ids,userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
}
|
|
/**
|
* <p>Description:获取服务器端状态 </p>
|
*
|
* @author wangxl
|
* @time 2012-5-24
|
* @return
|
* @throws VCIError
|
*/
|
public long getSystemTime() throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().getSystemTime();
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
}
|
/**
|
* 简单记录系统登入、登出日志
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2012-12-27
|
* @param message
|
* @throws VCIError
|
*/
|
public void savelog(String content) throws VCIException{
|
try{
|
ServiceProvider.getLogService().saveLoginLog(true, content, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
|
public void saveLogV2(String result, String content, String type, int logTypeIntVal, String dataObjOid) throws VCIException{
|
try{
|
ServiceProvider.getLogService().saveLog(result, content, type, LogType.valueOf(logTypeIntVal), dataObjOid, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
//add by caill start 2016.9.13用户被锁定的日志
|
/**
|
*
|
* <p>记录身份验证过程中登陆失败的日志信息</p>
|
*
|
* @author caill
|
* @time 2016-9-13
|
* @param message
|
* @throws VCIException
|
*/
|
public void blocklog(String userId) throws VCIException{
|
try{
|
ServiceProvider.getLogService().saveLockLog(userId, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
}
|
/**
|
*
|
* <p>记录身份验证过程中登陆失败的日志信息</p>
|
*
|
* @author llb
|
* @time 2013-2-18
|
* @param message
|
* @throws VCIException
|
*/
|
public void savelogFail(String message) throws VCIException{
|
try{
|
ServiceProvider.getLogService().saveLoginLog(false, message, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
/**
|
* 分页查询密码组合方式
|
* <p>Description: </p>
|
*
|
* @author llb
|
* @time 2013-1-4
|
* @param id
|
* @return
|
* @throws VCIException
|
*/
|
public CombinationObject[] fetchCombinationsToPage (int pageIndex, int pageSize) throws VCIException {
|
try{
|
CombinationInfo[] info = ClientSession.getFrameworkService().fetchCombinationsToPage( (long)pageIndex, (long)pageSize);
|
int length = info.length;
|
CombinationObject[] combinationObject = new CombinationObject[length];
|
for (int i = 0; i < length; i++) {
|
combinationObject[i] = changeCombinationInfoToObject(info[i]);
|
}
|
return combinationObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
|
public CombinationObject[] fetchAllCombinations () throws VCIException {
|
try{
|
CombinationInfo[] info = ClientSession.getFrameworkService().fetchAllCombinations();
|
int length = info.length;
|
CombinationObject[] combinationObject = new CombinationObject[length];
|
for (int i = 0; i < length; i++) {
|
combinationObject[i] = changeCombinationInfoToObject(info[i]);
|
}
|
return combinationObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* 添加密码组合方式
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @param obj
|
* @return
|
* @throws VCIException
|
*/
|
public String saveCombination(CombinationObject obj)throws VCIException {
|
try{
|
CombinationInfo info = changeCombinationObjectToInfo(obj);
|
String id = ClientSession.getFrameworkService().saveCombination(info,userEntityInfo);
|
return id;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* 修改密码组合方式
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @param obj
|
* @return
|
* @throws VCIException
|
*/
|
public boolean updateCombination(CombinationObject obj)throws VCIException {
|
try{
|
CombinationInfo info = changeCombinationObjectToInfo(obj);
|
return ClientSession.getFrameworkService().updateCombination(info,userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* 删除密码组合方式
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @param id
|
* @return
|
* @throws VCIException
|
*/
|
public boolean deleteCombination(String[] id) throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().deleteCombination(id, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/**
|
* 根据密码组合方式id获取组合方式取值范围
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @param parentId
|
* @return
|
* @throws VCIException
|
*/
|
public CombinationValueObject[] fetchCombinationValuesByParentId(String parentId) throws VCIException {
|
try{
|
CombinationValueInfo[] info = ClientSession.getFrameworkService().fetchCombinationValuesByParentId(parentId);
|
int length = info.length;
|
CombinationValueObject[] combValObject = new CombinationValueObject[length];
|
for (int i = 0; i < length; i++) {
|
combValObject[i] = changeCombinationValueInfoToObject(info[i]);
|
}
|
return combValObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* 添加密码组合方式取值范围
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @param valueObj
|
* @return
|
* @throws VCIException
|
*/
|
public String saveCombinationValue(CombinationValueObject[] valueObj)throws VCIException {
|
try{
|
int length = valueObj.length;
|
CombinationValueInfo[] infos = new CombinationValueInfo[length];
|
for (int i = 0; i < length; i++) {
|
infos[i] = changeCombinationValueObjectToInfo(valueObj[i]);
|
}
|
return ClientSession.getFrameworkService().saveCombinationValue(infos,userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* 修改密码组合方式取值范围
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @param valueObj
|
* @return
|
* @throws VCIException
|
*/
|
public boolean updateCombinationValue(CombinationValueObject valueObj)throws VCIException {
|
try{
|
CombinationValueInfo info = changeCombinationValueObjectToInfo(valueObj);
|
return ClientSession.getFrameworkService().updateCombinationValue(info,userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public boolean deletCombinationValues(String[] puids)throws VCIException {
|
try{
|
return ClientSession.getFrameworkService().deletCombinationValues(puids, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
* 根据密码策略id 获取关联的密码组合方式
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-4
|
* @param pstId
|
* @return
|
* @throws VCIException
|
*/
|
public CombinationObject[] fetchCombinationsByPstId(String pstId)throws VCIException{
|
try{
|
CombinationInfo[] info = ClientSession.getFrameworkService().fetchCombinationsByPstId(pstId);
|
int length = info.length;
|
CombinationObject[] combinationObject = new CombinationObject[length];
|
for (int i = 0; i < length; i++) {
|
combinationObject[i] = changeCombinationInfoToObject(info[i]);
|
}
|
return combinationObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**
|
* 检验密码组合方式是否被密码策略引用
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-4
|
* @param id
|
* @return
|
* @throws VCIException
|
*/
|
public int checkCombinationIsquotedCount(String combinationd) throws VCIException{
|
try{
|
return (int)ClientSession.getFrameworkService().checkCombinationIsquotedCount(combinationd);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/**
|
* 根据部门角色串获取用户名
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-3-27
|
* @param deptRole
|
* @return
|
* @throws VCIException
|
*/
|
public String[] getUsersByDetpAndRole(String deptRole)throws VCIException {
|
String[] userNames = null;
|
if ("".equals(deptRole)){
|
return userNames;
|
}
|
String deptNames = deptRole.substring(deptRole.indexOf("'")+1, deptRole.indexOf("&")-1);
|
String roleName = deptRole.substring(deptRole.lastIndexOf("=")+2, deptRole.length()-1);
|
String[] depts = deptNames.split("\\.");
|
String deptId = "";
|
|
DeptObject toopObj = null;
|
DeptObject deptObj = null;
|
for (int i = 0 ; i < depts.length ; i ++){
|
if (i == 0){
|
toopObj =this.fetchDeptByParentIdAndName("", depts[i]);
|
if (depts.length == 1){
|
deptObj = toopObj;
|
}
|
}else if(i ==1){
|
deptObj = this.fetchDeptByParentIdAndName(toopObj.getId (), depts[i]);
|
}else {
|
deptObj = this.fetchDeptByParentIdAndName(deptObj.getId() , depts[i]);
|
}
|
if (i == depts.length -1){
|
if (deptObj != null && !"".equals(deptObj.getId())){
|
deptId = deptObj.getId();
|
}else {
|
deptId = "";
|
}
|
}
|
}
|
|
String roleId = "";
|
RoleObject roleObj = this.fetchRoleByName(roleName);
|
if (roleObj != null && !"".equals(roleObj.getId())){
|
roleId = roleObj.getId();
|
}
|
UserObject[] userObjs = this.fetchUserInfoByDeptAndRole(new String[]{deptId}, new String[]{roleId});
|
|
if (userObjs != null && userObjs.length > 0){
|
userNames = new String[userObjs.length];
|
for (int i = 0 ; i < userObjs.length ; i ++){
|
userNames[i] = userObjs[i].getUserName();
|
}
|
|
}
|
|
return userNames;
|
}
|
|
private DeptObject fetchDeptByParentIdAndName(String parentId , String deptName)throws VCIException {
|
DeptObject deptObj = null;
|
try {
|
DeptInfo departmentInfo = ClientSession.getFrameworkService().fetchDeptByParentIdAndName(parentId,deptName);
|
if (departmentInfo != null) {
|
deptObj = changeDepartmentInfoToDeptObject(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public DeptInfo changeDeptObjectToDepartmentInfo(DeptObject DeptObject) {
|
DeptInfo departmentInfo = new DeptInfo();
|
departmentInfo.id = DeptObject.getId() == null ? "" : DeptObject.getId();
|
departmentInfo.name = DeptObject.getName() == null ? "" : DeptObject.getName();
|
departmentInfo.num = DeptObject.getNum() == null ? "" : DeptObject.getNum();
|
departmentInfo.code = DeptObject.getCode() == null ? "" : DeptObject.getCode();
|
departmentInfo.specialties = DeptObject.getSpecialties() == null ? "" : DeptObject.getSpecialties();
|
departmentInfo.status = DeptObject.getStatus() == 0 ? 0 : DeptObject.getStatus();
|
departmentInfo.description = DeptObject.getDescription() == null ? "" : DeptObject.getDescription();
|
departmentInfo.parentId = DeptObject.getParentId() == null ? "" : DeptObject.getParentId();
|
departmentInfo.createUser = DeptObject.getCreateUser() == null ? "" : DeptObject.getCreateUser();
|
departmentInfo.createTime = DeptObject.getCreateTime();
|
departmentInfo.updateTime = System.currentTimeMillis();
|
departmentInfo.updateUser = DeptObject.getUpdateUser() == null ? "" : DeptObject.getUpdateUser();
|
departmentInfo.grantor = DeptObject.getGrantor() == null ? "" : DeptObject.getGrantor();
|
return departmentInfo;
|
}
|
|
public DeptObject[] changeDepartmentInfoToDeptObjects(DeptInfo[] departmentInfos) {
|
int length = departmentInfos.length;
|
DeptObject[] DeptObject = new DeptObject[length];
|
for (int i = 0; i < length; i++) {
|
DeptObject[i] = changeDepartmentInfoToDeptObject(departmentInfos[i]);
|
}
|
return DeptObject;
|
}
|
|
public DeptObject changeDepartmentInfoToDeptObject(DeptInfo departmentInfo) {
|
DeptObject department = new DeptObject();
|
department.setId(departmentInfo.id);
|
department.setDescription(departmentInfo.description);
|
department.setName(departmentInfo.name);
|
department.setNum(departmentInfo.num);
|
department.setCode(departmentInfo.code);
|
department.setStatus(departmentInfo.status);
|
department.setSpecialties(departmentInfo.specialties);
|
department.setParentId(departmentInfo.parentId);
|
department.setCreateTime(departmentInfo.createTime);
|
department.setCreateUser(departmentInfo.createUser);
|
department.setUpdateTime(departmentInfo.updateTime);
|
department.setUpdateUser(departmentInfo.updateUser);
|
department.setGrantor(departmentInfo.grantor);
|
return department;
|
}
|
|
public RoleInfo changeRoleObjectToRoleInfo(RoleObject role) {
|
RoleInfo roleInfo = new RoleInfo();
|
roleInfo.id = role.getId() == null ? "" : role.getId();
|
roleInfo.name = role.getName();
|
roleInfo.description = role.getDescription() == null ? "" : role.getDescription();
|
roleInfo.type = role.getType();
|
roleInfo.createTime = role.getCreateTime();
|
roleInfo.createUser = role.getCreateUser() == null ? "" : role.getCreateUser();
|
roleInfo.updateTime = role.getUpdateTime();
|
roleInfo.updateUser = role.getUpdateUser() == null ? "" : role.getUpdateUser();
|
roleInfo.grantor = role.getGrantor() == null ? "" : role.getGrantor();
|
return roleInfo;
|
}
|
|
public RoleObject changeRoleInfoToRoleObject(RoleInfo roleInfo) {
|
RoleObject role = new RoleObject();
|
role.setId(roleInfo.id);
|
role.setDescription(roleInfo.description);
|
role.setName(roleInfo.name);
|
role.setType(roleInfo.type);
|
role.setCreateTime(roleInfo.createTime);
|
role.setCreateUser(roleInfo.createUser);
|
role.setUpdateTime(roleInfo.updateTime);
|
role.setUpdateUser(roleInfo.updateUser);
|
role.setGrantor(roleInfo.grantor);
|
return role;
|
}
|
public CombinationObject changeCombinationInfoToObject(CombinationInfo info) {
|
CombinationObject obj = new CombinationObject();
|
obj.setId(info.id);
|
obj.setDescription(info.description);
|
obj.setName(info.name);
|
obj.setCreateTime(info.createTime);
|
obj.setCreateUser(info.createUser);
|
obj.setUpdateTime(info.updateTime);
|
obj.setUpdateUser(info.updateUser);
|
obj.setGrantor(info.grantor);
|
return obj;
|
}
|
public CombinationValueObject changeCombinationValueInfoToObject(CombinationValueInfo info) {
|
CombinationValueObject obj = new CombinationValueObject();
|
obj.setId(info.id);
|
obj.setParentId(info.parentId);
|
obj.setValue(info.value);
|
return obj;
|
}
|
public CombinationInfo changeCombinationObjectToInfo(CombinationObject obj) {
|
CombinationInfo info = new CombinationInfo();
|
info.id = obj.getId() == null ? "" : obj.getId();
|
info.name = obj.getName();
|
info.description = obj.getDescription() == null ? "" : obj.getDescription();
|
info.createTime = obj.getCreateTime();
|
info.createUser =obj.getCreateUser() == null ? "" : obj.getCreateUser();
|
info.updateTime = obj.getUpdateTime();
|
info.updateUser = obj.getUpdateUser() == null ? "" : obj.getUpdateUser();
|
info.grantor = obj.getGrantor() == null ? "" : obj.getGrantor();
|
return info;
|
}
|
public CombinationValueInfo changeCombinationValueObjectToInfo(CombinationValueObject obj) {
|
CombinationValueInfo info = new CombinationValueInfo();
|
info.id = obj.getId() == null ? "" : obj.getId();
|
info.parentId = obj.getParentId() == null ? "" : obj.getParentId();
|
info.value = obj.getValue() == null ? "" : obj.getValue();
|
return info;
|
}
|
public UserObject changeUserInfoToUserObject(UserInfo userInfo) {
|
UserObject user = new UserObject();
|
user.setId(userInfo.id);
|
user.setUserName(userInfo.userName);
|
user.setPwd(userInfo.pwd);
|
user.setEmail(userInfo.email);
|
user.setTrueName(userInfo.trueName);
|
user.setSpecialties(userInfo.specialties);
|
user.setDesc(userInfo.desc);
|
user.setUserType(userInfo.userType);
|
user.setStatus(userInfo.status);
|
user.setCreateTime(userInfo.createTime);
|
user.setCreateUser(userInfo.createUser);
|
user.setUpdateTime(userInfo.updateTime);
|
user.setUpdateUser(userInfo.updateUser);
|
user.setPwdUpdateTime(userInfo.pwdUpdateTime);
|
user.setGrantor(userInfo.grantor);
|
user.setSecretGrade(userInfo.secretGrade);
|
user.setIsDeptLeader(userInfo.isDeptLeader);
|
return user;
|
}
|
|
/***
|
* 用户从客户端对象到corba对象
|
*
|
* @param UserObject
|
* @return
|
*/
|
public UserInfo changeUserObjectToUserInfo(UserObject user) {
|
UserInfo userInfo = new UserInfo();
|
userInfo.id = user.getId() == null ? "" : user.getId();
|
userInfo.userName = user.getUserName() == null ? "" : user.getUserName();
|
userInfo.pwd = user.getPwd() == null ? "" : user.getPwd();
|
userInfo.trueName = user.getTrueName() == null ? "" : user.getTrueName();
|
userInfo.specialties = user.getSpecialties() == null ? "" : user.getSpecialties();
|
userInfo.email = user.getEmail() == null ? "" : user.getEmail();
|
userInfo.desc = user.getDesc() == null ? "" : user.getDesc();
|
userInfo.userType = user.getUserType();
|
userInfo.status = user.getStatus();
|
userInfo.createTime = user.getCreateTime();
|
userInfo.createUser = user.getCreateUser() == null ? "" : user.getCreateUser();
|
userInfo.updateTime = user.getUpdateTime();
|
userInfo.updateUser = user.getUpdateUser() == null ? "" : user.getUpdateUser();
|
userInfo.pwdUpdateTime = user.getPwdUpdateTime();
|
userInfo.grantor = user.getGrantor() == null ? "" : user.getGrantor();
|
userInfo.secretGrade = user.getSecretGrade() == null ? "" : user.getSecretGrade();
|
userInfo.isDeptLeader = user.getIsDeptLeader() == null ? "0" : user.getIsDeptLeader();
|
return userInfo;
|
}
|
|
public PasswordStrategyObject[] changePasswordStrategyInfoToObjs(PasswordStrategyInfo[] pwdStgInfos){
|
PasswordStrategyObject[] objs = new PasswordStrategyObject[pwdStgInfos.length];
|
for (int i = 0 ; i < pwdStgInfos.length ; i ++){
|
objs[i] = this.changePasswordStrategyInfoToObj(pwdStgInfos[i]);
|
}
|
return objs;
|
}
|
|
public PasswordStrategyObject changePasswordStrategyInfoToObj(PasswordStrategyInfo info){
|
PasswordStrategyObject obj = new PasswordStrategyObject();
|
obj.setId(info.id );
|
obj.setName(info.name);
|
obj.setPasswordLen(info.passwordLen);
|
obj.setPasswordMaxLen(info.passwordMaxLen);
|
obj.setCharTypes(info.charTypes);
|
obj.setRequiredType(info.requiredType);
|
obj.setOverdueDay(info.overdueDay);
|
obj.setRemideDay(info.remideDay);
|
obj.setRetryTime(info.retryTime);
|
obj.setLockTime(info.lockTime);
|
obj.setIsDefault(info.isDefault);
|
obj.setDesc(info.desc == "" ? null : info.desc);
|
obj.setCreateTime(info.createTime);
|
obj.setCreateUser(info.createUser);
|
obj.setUpdateTime(info.updateTime);
|
obj.setUpdateTime(info.updateTime);
|
obj.setGrantor(info.grantor == null ? "" : info.grantor);
|
return obj;
|
}
|
|
private PasswordStrategyInfo changePasswordStrategyObjToInfo(PasswordStrategyObject obj){
|
PasswordStrategyInfo info = new PasswordStrategyInfo();
|
info.id = obj.getId();
|
info.name = obj.getName();
|
info.passwordLen = obj.getPasswordLen();
|
info.passwordMaxLen = obj.getPasswordMaxLen();
|
info.charTypes = obj.getCharTypes();
|
info.requiredType = obj.getRequiredType();
|
info.overdueDay = obj.getOverdueDay();
|
info.remideDay = obj.getRemideDay();
|
info.retryTime = obj.getRetryTime();
|
info.lockTime = obj.getLockTime();
|
info.isDefault = obj.getIsDefault();
|
info.desc = obj.getDesc() == null ? "" : obj.getDesc();
|
info.createTime = obj.getCreateTime();
|
info.createUser = obj.getCreateUser() == null ? "" : obj.getCreateUser();
|
info.updateTime = obj.getUpdateTime();
|
info.updateUser = obj.getUpdateUser() == null ? "" : obj.getUpdateUser();
|
info.grantor = obj.getGrantor() == null ? "" : obj.getGrantor();
|
return info;
|
}
|
|
private UserLogonObject transferCorbaObjToUserLogonObj(UserLogonInfo info){
|
UserLogonObject obj = new UserLogonObject();
|
if (!StringUtils.isEmpty(info.pluserOid)) {
|
obj.setPluserOid(info.pluserOid);
|
obj.setPlWrongNum(info.plWrongNum);
|
obj.setPlLogonTime(info.plLogonTime);
|
}
|
return obj;
|
}
|
|
/**
|
* 根据文件柜id和用户类型获取成员
|
* @param roleId
|
* @param type
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject[] fetchUserInfoByPvolumeId(String pvolumeId , short type ) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByPvolumeId(pvolumeId ,type);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
/**
|
* 创建文件柜和用户的关系
|
* @param roleId
|
* @param userIds
|
* @return
|
* @throws VCIError
|
*/
|
public boolean savePvolume(String pvolumId ,String[] userIds) throws VCIException{
|
try{
|
return ClientSession.getFrameworkService().savePvolumeUser(pvolumId, userIds, userEntityInfo);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
static class NameComparator implements Comparator<Object>{
|
private final Collator collator=Collator.getInstance();
|
@Override
|
public int compare(Object arg0, Object arg1) {
|
RoleObject ro1=(RoleObject) arg0;
|
RoleObject ro2=(RoleObject) arg1;
|
return collator.compare(ro1.getName(), ro2.getName());
|
}
|
|
}
|
static class UserNameComparator implements Comparator<Object>{
|
private final Collator collator=Collator.getInstance();
|
@Override
|
public int compare(Object arg0, Object arg1) {
|
UserObject uo1=(UserObject) arg0;
|
UserObject uo2=(UserObject) arg1;
|
return collator.compare(uo1.getTrueName(), uo2.getTrueName());
|
}
|
|
}
|
/**
|
* <p>记录身份验证过程中登陆失败的日志信息</p>
|
*
|
* @author liyp
|
* @time 2016-9-28
|
* @param message
|
* @throws VCIException
|
*/
|
public void savelogGeneralOperation(String result, String content, String dataId,String plType) throws VCIException{
|
try{
|
ClientSession.getFrameworkService().savelogGeneralOperation(result, content, userEntityInfo, dataId,plType);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
}
|
|
/***
|
* 根据查询条件获取用户
|
* @param otherFiterString
|
* @return
|
* @throws VCIError
|
* @throws VCIException
|
*/
|
public DeptObject[] fetchDepartmentInfoByIds(String otherFiterString) throws VCIException {
|
DeptObject[] deptObj = null ;
|
try {
|
DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfoByIds(otherFiterString);
|
if (departmentInfo != null && departmentInfo.length > 0) {
|
deptObj = changeDepartmentInfoToDeptObjects(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
|
}
|
/**
|
* 返回部门下的子部门
|
*
|
* @param prtoid 父节点oid
|
* @param iscontains 是否查询所有层级,false:当前节点下的层级,true :所有层级
|
* @param otherFiterString 补充查询语句
|
* @return
|
* @throws VCIError
|
*/
|
public DeptObject[] fetchDepartmentInfoByParentId(String prtoid,boolean iscontains,String otherFiterString) throws VCIException {
|
DeptObject[] deptObj = null ;
|
try {
|
DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchChildrenDeptByParentOid(prtoid, iscontains, otherFiterString);
|
if (departmentInfo != null && departmentInfo.length > 0) {
|
deptObj = changeDepartmentInfoToDeptObjects(departmentInfo);
|
}
|
return deptObj;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
|
/***
|
* 查询分页
|
* @param filterString 查询条件
|
* @param pageNo //第几页
|
* @param pageSize//每页条目数
|
* @return
|
* @throws VCIException
|
*/
|
public UserObject[] fetchUserInfoByFilterString(String filterString,int pageNo,int pageSize) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByFilterString(filterString, pageNo, pageSize);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
List<UserObject> userList=Arrays.asList(userObject);
|
Collections.sort(userList, new UserNameComparator());
|
UserObject[] userObject1=(UserObject[]) userList.toArray();
|
return userObject1;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
|
public int fetchUserInfoByFilterStringCount(String filterString) throws VCIException {
|
int count =0;
|
try{
|
count = (int)ClientSession.getFrameworkService().fetchUserInfoByFilterStringCount(filterString);
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
return count;
|
}
|
|
/***
|
* 根据用户名批量获取成员
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject[] fetchUserInfoByNames(String[] userNames) throws VCIException {
|
try{
|
UserInfo[] userInfos = ClientSession.getFrameworkService().fetchUserInfoByNames(userNames);
|
int length = userInfos.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfos[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/**
|
*
|
* @param filterString 查询条件
|
* @param pageNo //第几页
|
* @param pageSize//每页条目数
|
* @return
|
* @throws VCIException
|
*/
|
public UserObject[] fetchUserInfosByFilterStringsql(String filterString) throws VCIException {
|
try{
|
UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfosByFilterStringsql(filterString);
|
int length = userInfo.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfo[i]);
|
}
|
List<UserObject> userList=Arrays.asList(userObject);
|
Collections.sort(userList, new UserNameComparator());
|
UserObject[] userObject1=(UserObject[]) userList.toArray();
|
return userObject1;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
/***
|
* 根据用户名批量获取成员
|
*
|
* @return
|
* @throws VCIError
|
*/
|
public UserObject[] getUserObjectByoid(String[] userOid) throws VCIException {
|
try{
|
UserInfo[] userInfos = ClientSession.getFrameworkService().getUserObjectByoids(userOid);
|
int length = userInfos.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfos[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
|
public UserObject getUserObjectByoid(String oid) throws VCIException{
|
UserObject userObj = null;
|
try{
|
UserInfo info = ClientSession.getFrameworkService().getUserObjectByoid(oid);
|
if (!"".equals(info.id)){
|
userObj = changeUserInfoToUserObject(info);
|
}
|
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code), e.messages);
|
}
|
return userObj;
|
}
|
|
|
public UserObject getUserObjectsByOid(String userOid)throws VCIException {
|
try{
|
UserInfo userInfo = ClientSession.getFrameworkService().getUserObjectByoid(userOid);
|
UserObject userObject = new UserObject();
|
userObject = changeUserInfoToUserObject(userInfo);
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public UserObject[] getUserObjectsByOids(String[] userOids)throws VCIException {
|
try{
|
UserInfo[] userInfos = ClientSession.getFrameworkService().getUserObjectByoids(userOids);
|
int length = userInfos.length;
|
UserObject[] userObject = new UserObject[length];
|
for (int i = 0; i < length; i++) {
|
userObject[i] = changeUserInfoToUserObject(userInfos[i]);
|
}
|
return userObject;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
public DeptObject[] gridDeptDataGrids(String filter ,int pageNo,int pageSize) throws VCIException {
|
DeptInfo[] departmentInfo = null;
|
try{
|
departmentInfo = ClientSession.getFrameworkService().gridDeptDataGrids(filter, pageNo, pageSize);
|
return changeDepartmentInfoToDeptObjects(departmentInfo);
|
}catch(VCIError e) {
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
|
}
|
public int gridDeptDataGridsCount(String filter ) throws VCIException {
|
try{
|
return (int)ClientSession.getFrameworkService().gridDeptDataGridsCount(filter);
|
}catch(VCIError e) {
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/***
|
* 查询分页
|
* @param filterString 查询条件
|
* @param pageNo //第几页
|
* @param pageSize//每页条目数
|
* @return
|
* @throws VCIException
|
*/
|
public RoleObject[] queryRoleInfos(String filterString,int pageNo,int pageSize) throws VCIException {
|
try{
|
RoleInfo[] roleInfos = ClientSession.getFrameworkService().queryRoleInfos(filterString, pageNo, pageSize);
|
int length = roleInfos.length;
|
RoleObject[] roleObjects = new RoleObject[length];
|
for (int i = 0; i < length; i++) {
|
roleObjects[i] = this.changeRoleInfoToRoleObject(roleInfos[i]);
|
}
|
return roleObjects;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
/***
|
* 查询分页
|
* @param filterString 查询条件
|
* @return 总数
|
* @throws VCIException
|
*/
|
public int queryRoleInfosCount(String filterString) throws VCIException {
|
try{
|
int count = (int)ClientSession.getFrameworkService().queryRoleInfosCount(filterString);
|
return count;
|
}catch(VCIError e){
|
throw new VCIException(String.valueOf(e.code),e.messages);
|
}
|
}
|
|
}
|