CAS Server 如何连接WebService验密
来源:互联网 发布:coc女王升级数据 编辑:程序博客网 时间:2024/04/25 02:40
CAS Server 如何连接WebService验密?
一般常用的有连接AD 域控的LDAP或DB去做用户和密码的验证,网上也有很多介绍。
CAS Server的source code初始化时,使用的是casuser/Mellon,以方便大家初次使用。
最简的方式就是从这里入手,大家可以在deployerConfigContext.xml里找CASUSER或Mellon.
下面是我修改后的配置文件,用最简单的SOAP去连接,利用原始功能从配置文件里读取URL和SOAP信息。
直接修改这个方法的中问部分即可,如果验证不成功直接抛出异常即可。接下的事情就交给CAS 去生成TOKEN......
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential) throws GeneralSecurityException, PreventedException { final String username = credential.getUsername(); final String password = credential.getPassword(); final String cacheurl = this.users.get("url"); final String cachesoap = this.users.get("soap"); String result = "false";try {//服务的地址URL wsUrl;wsUrl = new URL(cacheurl);HttpURLConnection conn;conn = (HttpURLConnection) wsUrl.openConnection();conn.setDoInput(true);conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8"); OutputStream os = conn.getOutputStream(); //请求体 String soap = cachesoap; soap = soap.replace("username-param", username).replace("password-param",password);//替换用户名和密码 os.write(soap.getBytes()); InputStream is = conn.getInputStream(); Document doc; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); doc = db.parse(is); NodeList nl = doc.getElementsByTagName("LoginResult"); StringBuffer sb = new StringBuffer(); Node n = nl.item(0); result = n.getFirstChild().getNodeValue(); is.close(); os.close(); conn.disconnect();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}System.out.println("------User ["+username+"]Login result: "+result); if(!result.equals("Success")){ logger.debug("{} :wrong username or password.", username); throw new AccountNotFoundException(username + " wrong username or password."); } final String encodedPassword = this.getPasswordEncoder().encode(credential.getPassword()); return createHandlerResult(credential, new SimplePrincipal(username), null); }
0 0
- CAS Server 如何连接WebService验密
- 4、cas Server连接mysql
- 二、cas-server-4.0连接mysql
- CAS Server
- CAS(2)-部署Cas Server
- CAS(2)-部署Cas Server
- 如何配置webservice及连接delphi
- 如何远程连接SQL SERVER
- C#如何连接SQL Server
- vs如何连接连接sql server数据库?
- vs如何连接连接sql server数据库?
- CAS+RESTful WebService 使用文档
- CAS(Central Authentication Server)
- CAS Server 2
- CAS Server改造
- 3、部署Cas Server
- CAS server配置教程
- CAS Server端配置
- 公告 我的另外一个博客
- 别傻了,人家离职你也离
- Flexpaper播放swf的问题
- JavaScript
- Java单例你所不知道的事,与Volatile关键字有染
- CAS Server 如何连接WebService验密
- HDU 4766 模拟退火(最小圆覆盖) + 二分
- 随机数
- 计算某一个字符串中的大小写与其它字符
- IndentationError: unindent does not match any outer indentation level
- zjnu 1744 EKSPLOZIJA(模拟栈)
- lua 调用.so 和 require 使用
- 图解正向代理、反向代理、透明代理
- Scanner 的坑