public class AuthenticationHandler extends AbstractHandler { public static ResourceBundle resourceBundle; static { resourceBundle = ResourceBundle.getBundle("sysParam"); } public void invoke(MessageContext cfx) throws Exception { if (cfx.getInMessage().getHeader() == null) { throw new org.codehaus.xfire.fault.XFireFault("请求必须包含验证信息",org.codehaus.xfire.fault.XFireFault.SENDER); } Element token = cfx.getInMessage().getHeader().getChild( "AuthenticationToken"); if (token == null) { throw new org.codehaus.xfire.fault.XFireFault("请求必须包含身份验证信息",org.codehaus.xfire.fault.XFireFault.SENDER); } String check_usernames = resourceBundle.getString("username"); HashMapcurrentUser = new HashMap ,string>(); String check_userName [] = check_usernames.split(","); for(String _s : check_userName){ currentUser.put(_s,resourceBundle.getString(_s+"_psw")); } String username = token.getChild("Username").getValue(); String password = token.getChild("Password").getValue(); try { if(!clsstringTool.isEmpty(currentUser.get(username))){ if(currentUser.get(username).equals(password)){ //System.out.println("用户名密码验证通过"); String ip = XFireServletController.getRequest().getHeader("remoteIp"); if( ip == null) ip = XFireServletController.getRequest().getRemoteAddr(); //System.out.println("ip==="+ip); if(resourceBundle.getString("ip").contains(ip)){ //System.out.println("用户IP验证通过"); }else{ throw new org.codehaus.xfire.fault.XFireFault("非法的IP来源",org.codehaus.xfire.fault.XFireFault.SENDER); } }else{ throw new Exception(); } }else{ throw new Exception(); } } catch (Exception e) { throw new org.codehaus.xfire.fault.XFireFault("非法的用户名、密码或IP",org.codehaus.xfire.fault.XFireFault.SENDER); } } ,string>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。