基于rsa SecurID的二次驗證。RSA server自身可以作為Radius服務器,RSA也可以和其他的軟件集合,使用其他的server作為Radius服務器。
radius的驗證的一般流程如下圖:
用java實現的主要代碼實現如下(需要導入radius相關jar包,主要為radiusclient3.jar):
①radius第一次驗證, RADIUSClient的4個參數分別為server ip,port,Radius的密鑰,radius輸入超時時間. authenticate的username和passWord即為所需要驗證的用戶.
1 RADIUSClient r = null;2 int nResult = 0; r = new RADIUSClient("ip", port , "secret" , radius_soctet_timeout);3 r.setDebug(true);4 AttributeList aList = new AttributeList();5 aList.addAttribute(Attribute.NAS_Port, 1);6 nResult = r.authenticate(username, password, aList);
②跟據返回的nResult進行判斷.代碼中的數字3代表access_reject, 數字0代表access_badpacket, 數字11代表access_challenge, 數字2代表access_accept.
當遇到access_challenge時,有兩種情況,一只是需要new pin(new pin的情況相對復雜一點), 另一種是需要next token.另外,這個Attribute.State屬性是一直要繼承的,用來區分
是否是我們需要的那一次驗證(如代碼25, 26行,就把state帶入下一次驗證,用來驗證識別).
1 switch (nResult) { 2 case 3: 3 try{ 4 AttributeList response = r.getAttributes(); 5 AttributeList state = response.getAttributeList(Attribute.State); 6 } 7 catch(Exception e){ 8 9 }10 11 break;12 case 0:13 14 break;15 case 11:16 AttributeList response = r.getAttributes();17 AttributeList state = response.getAttributeList(Attribute.State);18 r.reset();19 System.out.轉載請注明出處:http://www.49028c.com/huhanbo/p/4087827.html
新聞熱點
疑難解答