casLoginView.jsp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <!DOCTYPE html>
  2. <%@ page session="true"%>
  3. <%@ page pageEncoding="UTF-8"%>
  4. <%@ page contentType="text/html; charset=UTF-8"%>
  5. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  6. <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
  7. <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
  8. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
  9. <%@ page import="org.springframework.webflow.execution.RequestContext"%>
  10. <%@ page import="org.apache.commons.lang.StringUtils"%>
  11. <%@ page import="com.jsjty.sso.util.DesPasswordEncoder"%>
  12. <c:set var="basePath" value="${pageContext.request.contextPath}" />
  13. <%
  14. String userName = "";
  15. String passKey = "";
  16. //System.out.println("autoSubmit:"+request.getSession().getAttribute("autoSubmit"));
  17. // if(request.getSession().getAttribute("autoSubmit")==null){
  18. if (request.getAttribute("service") != null) {
  19. String service = request.getAttribute("service").toString();
  20. if (service.indexOf("userName") != -1
  21. && service.indexOf("passKey") != -1) {
  22. int m = service.indexOf("userName");
  23. int n = service.indexOf("&", m + 9);
  24. int j = service.indexOf("passKey");
  25. userName = service.substring(m + 9, n);
  26. passKey = service.substring(j + 8);
  27. passKey = DesPasswordEncoder.decrypt(passKey, "");
  28. userName = StringUtils.isEmpty(userName) ? "" : userName;
  29. passKey = StringUtils.isEmpty(passKey) ? "" : passKey;
  30. } else {
  31. userName = "";
  32. passKey = "";
  33. }
  34. }
  35. %>
  36. <html >
  37. <head>
  38. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  39. <script type="text/javascript" src="${basePath}/js/jquery-1.7.1.min.js"></script>
  40. <script>
  41. function gotopage(){
  42. $('#iscredential').val("false");
  43. console.log("iscredential",$('#iscredential').val());
  44. $("#frm1").submit();
  45. }
  46. function isNotBlank(value){
  47. if(typeof(value)!='undefined'&&value!=null){
  48. value=value+"";
  49. for(var i=0; i<value.length; i++) {
  50. var c = value.charAt(i);
  51. if ((c!=' ')&&(c!='\n')&&(c!='\t')) return true;
  52. }
  53. }
  54. return false;
  55. }
  56. $(document).ready(function () {
  57. //openValidateExternalAccount('http://10.1.30.107//login,GKSSO,','SZmfuLcEiehu0rNSkGVYSseGkVT+QeLpjsUNmc2CsxWYtT8a1UtxrOcsWOvaR8Hb','admin','jsjt')
  58. //var credential='${param.credential}';
  59. var credential=$('#credential').val();
  60. <%--credential='SZmfuLcEiehu0rNSkGVYSseGkVT+QeLpjsUNmc2CsxWYtT8a1UtxrOcsWOvaR8Hb';--%>
  61. <%--credential="<spring:eval expression="T(com.jsjty.sso.util.DesPasswordEncoder).encrypt('{userName:\"shentz2\",userName:\"123456\"}','yjpt_gkj')" />";--%>
  62. <%-- http://localhost:8080/znjg/login?credential=JrDBOacSk3SETlnM%2B3PHk9TKKxl0stT5AAYziT4CRX28v2GV3Y0fng== --%>
  63. //credential="JrDBOacSk3SETlnM+3PHk9TKKxl0stT5AAYziT4CRX28v2GV3Y0fng==";
  64. //credential="<spring:eval expression="T(com.jsjty.sso.util.DesPasswordEncoder).encrypt('{username:\"shentz\",password:\"123456\"}','yjpt_gkj')" />";
  65. //credential="<spring:eval expression="T(com.jsjty.sso.util.DesPasswordEncoder).encrypt('{username:\"shentz\"}','yjpt_gkj')" />";
  66. console.log("credential",credential);
  67. console.log("iscredential",$('#iscredential').val());
  68. if($('#iscredential').val()!='false'&&isNotBlank(credential)){
  69. $.ajax({
  70. type : 'post',
  71. datatype : 'json',
  72. contentType : 'application/json;charset=utf-8',
  73. //timeout : 10000, //超时时间设置,单位毫秒
  74. cache : false,// 不从缓存中去数据
  75. async : true,
  76. url : "${basePath}/user/virtualDrive.html",
  77. data : JSON.stringify({credential:credential,verification:'true',runtime:new Date().getTime()}),
  78. //headers:headinfo,
  79. success : function(data) {
  80. if(data&&typeof(data)=='object'){
  81. //alert(typeof(data));
  82. //alert(JSON.stringify(data));
  83. console.log(data);
  84. if(data.credentialDecrypt&&
  85. isNotBlank(data.credentialDecrypt.username)&&isNotBlank(data.credentialDecrypt.password)){
  86. if(data.credentialDecrypt){
  87. for(key in data.credentialDecrypt){
  88. $('#'+key).val(data.credentialDecrypt[key]);
  89. }
  90. }
  91. $('#iscredential').val("false");
  92. $('#credential').val("");
  93. $("#frm1").submit();
  94. }else{
  95. console.log("自动登录失败...");
  96. }
  97. }
  98. },
  99. error : function(jqXHR, textStatus, errorThrown) {
  100. //alert(jqXHR.responseText);
  101. }
  102. });
  103. }
  104. });
  105. </script>
  106. <link rel="stylesheet" type="text/css" href="${basePath}/css/login.css" />
  107. <title>统一认证登录</title>
  108. </head>
  109. <body >
  110. <div>
  111. <img id="bg_images" src="${basePath}/static/image/login_bg.jpg" />
  112. </div>
  113. <img id="logo_words_portal"
  114. src="${basePath}/static/image/logo_words_portal.png" />
  115. <div id="login">
  116. <form:form method="post" id="frm1"
  117. name="frm1" commandName="${commandName}" htmlEscape="true">
  118. <div id="login_bg">
  119. <div id="usrName_div">
  120. <p>用户名:</p>
  121. <input type="text" id="username" style="background-color: #fff" value="<%=userName%>"
  122. accesskey="n" name="username" size="25" />
  123. </div>
  124. <div id="password_div">
  125. <p style="background-position: 0px -40px;">密&nbsp;&nbsp;&nbsp;码:</p>
  126. <input type="password" id="password" value="<%=passKey%>"
  127. accesskey="p" name="password" size="25" />
  128. </div>
  129. </div>
  130. <form:errors path="*" id="msg" cssClass="errors" element="div" style="text-align:right;color:red;margin-top:-10px;padding-right:20px;" />
  131. <input type="hidden" name="lt" value="${loginTicket}" />
  132. <input type="hidden" name="execution" value="${flowExecutionKey}" />
  133. <input type="hidden" id="credential" name="credential" value="${param.credential}" />
  134. <input type="hidden" id="iscredential" name="iscredential" value="${param.iscredential}" />
  135. <input type="hidden" name="_eventId" value="submit" />
  136. <div id="button_bg">
  137. <button style="cursor:pointer" id="submits">登 录</button>
  138. </div>
  139. <div id="button_bg2" style="display:none">
  140. <button style="cursor:pointer" onclick="gotopage()">登 录2</button>
  141. </div>
  142. </form:form>
  143. </div>
  144. <footer> <img src="${basePath}/static/image/footer_img.png" />
  145. <p id="footer">Copyright 2015 江苏省新通智能交通科技发展有限公司 版权所有</p>
  146. </footer>
  147. <script type="text/javascript">
  148. $(function() {
  149. //var userName = $('#p_username').val();
  150. //var passKey = $('#p_password').val();
  151. if("<%=userName%>"!=""&&"<%=passKey%>" != "") {
  152. // $('#username').val(userName);
  153. // $('#password').val(passKey);
  154. // $('#p_username').val("");
  155. // $('#p_password').val("");
  156. //alert("自动提交表单");
  157. $("#frm1").submit();
  158. }
  159. //User.manage.viewform.init();
  160. });
  161. </script>
  162. </body>
  163. </html>