?? ssoauthenticator.java
字號:
package dev.trade.cs.securityfilter;
import java.security.*;
import com.newland.security.usermgr.baseobj.*;
import dev.trade.common.securityfilter.authenticator.*;
import dev.trade.cs.util.*;
/**
* <p>Title: </p>
*
* <p>Description: SSO(單點登錄)驗證器</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not ZhengYanNan
* @version 1.0
*/
public class SSOAuthenticator extends AbstractAuthenticator{
public static final String SSO_AUTH = "SSO";
public static final String SSO_SESSION_ID = "ssoSessionId";
public static final String SSO_SESSION_PWD = "ssoSessionPwd";
public SSOAuthenticator(){
super(SSO_AUTH, SSO_SESSION_ID, SSO_SESSION_PWD);
}
/**
* 驗證用戶有效性,登錄時調用,可用于處理用戶信息的初始化
* @param username a username
* @param password a plain text password, as entered by the user
* @return a Principal object representing the user if successful, false otherwise
*/
public Principal authenticate(String username, String password){
UserInfo userInfo = SecurityUtil.isLoginUser(username);
if (userInfo!=null) {
SSOPrincipal p = new SSOPrincipal(userInfo);
return p;
} else {
return null;
}
}
/**
* 測試用戶的權限
* @param username The name of the user
* @param role name of a role to test for membership
* @return true if the user is in the role, false otherwise
*/
public boolean isUserInRole(Principal principal, String funId){
SSOPrincipal p = (SSOPrincipal)principal;
String fId = "";
String opt = "";
String[] fids = funId.split("#");
if(fids.length > 1){
fId = fids[0];
opt = fids[1];
if("VISIBLE".equalsIgnoreCase(opt)){
opt = SecurityUtil.OPERATION_VISIBLE;
} else if("WRITE".equalsIgnoreCase(opt)){
opt = SecurityUtil.OPERATION_WRITE;
} else{
opt = SecurityUtil.OPERATION_READ;
}
} else{
fId = funId;
opt = SecurityUtil.OPERATION_READ;
}
return SecurityUtil.checkFuncPermission(p.getUserId(),fId,opt);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -