Commit cfe7f71b authored by lishiqing's avatar lishiqing

登录密码加密

parent b8f935d3
package com.hand.hap.security;
import com.hand.hap.mybatis.util.StringUtil;
import com.hand.hls.utils.RSACoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RSAPasswordManager extends PasswordManager {
public static Logger logger = LoggerFactory.getLogger(RSAPasswordManager.class);
public boolean matches(CharSequence rawPassword, String encodedPassword) {
if (StringUtil.isEmpty(encodedPassword))
return false;
try {
CharSequence decrypt = RSACoder.encryptByPrivateKey(rawPassword);
return super.matches(decrypt, encodedPassword);
} catch (Exception e) {
e.printStackTrace();
logger.error("decrypt password failed ,the exception is {}", e);
return false;
}
}
}
This diff is collapsed.
......@@ -62,10 +62,13 @@
<!-- <authentication-provider ref="ldapAuthProvider" />-->
<!--标准登录验证-->
<authentication-provider user-service-ref="customUserDetailsService">
<password-encoder ref="passwordManager"/>
<password-encoder ref="RSAPasswordManager"/>
</authentication-provider>
</authentication-manager>
<beans:bean id="RSAPasswordManager" class="com.hand.hap.security.RSAPasswordManager" parent="passwordManager">
</beans:bean>
<beans:bean id="captchaVerifierFilter" class="com.hand.hap.security.CaptchaVerifierFilter">
<beans:property name="captchaField" value="verifiCode"/>
</beans:bean>
......
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>${SYS_TITLE!'Hand Application Platform'}</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="${base.contextPath}/lib/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="${base.contextPath}/lib/font-awesome-4.6.3/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="${base.contextPath}/lib/assets/global/css/components.css" rel="stylesheet" id="style_components" type="text/css" />
<link href="${base.contextPath}/lib/assets/global/css/plugins.css" rel="stylesheet" type="text/css" />
<link href="${base.contextPath}/lib/assets/pages/css/login-5.css" rel="stylesheet" type="text/css" />
<script src="${base.contextPath}/lib/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<link href="${base.contextPath}/resources/upload/favicon.png" rel="shortcut icon"/>
<script>var _baseContext = '${base.contextPath}'</script>
<script src="${base.contextPath}/lib/rsa/jsencrypt.min.js"></script>
</head>
<body class=" login">
<script>
function changeCaptchaCode() {
$("#imgObj").attr("src", '${base.contextPath}/verifiCode?_r='+Math.random());
}
function doLogin() {
var rsakey = $("#pubkey").val();
if (rsakey) {
var encrypt = new JSEncrypt();
encrypt.setPublicKey(rsakey);
var pwd = $("#password").val();
if (pwd) {
$("#password").val(encrypt.encrypt(pwd));
$("#login_form").submit();
} else {
alert("请输入密码");
}
} else {
alert("页面已经过期,请刷新后重试,原因:找不到rsakey");
}
}
</script>
<style>
.user-login-5 input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 1000px white inset !important;
}
</style>
<!-- BEGIN : LOGIN PAGE 5-1 -->
<div class="user-login-5">
<script>
if(top.sessionExpiredLogin){
top.sessionExpiredLogin();
$('.user-login-5').hide();
}
</script>
<div class="row bs-reset">
<div class="col-md-6 bs-reset">
<div class="login-bg" style="background-image:url(${base.contextPath}/lib/assets/pages/img/login/bg1.jpg)">
<img class="login-logo" src="${base.contextPath}/resources/upload/logo.png" width="140"/>
</div>
</div>
<div class="col-md-6 login-container bs-reset">
<div class="login-content">
<h1>${SYS_TITLE!'Hand Application Platform'} Login</h1>
<#if msg?exists>
<div class="alert alert-danger">
<button class="close" data-close="alert"></button>
<span>${msg!}</span>
</div>
</#if>
<form id="login_form" class="login-form" action="login" method="post" autocomplete="off">
<input type="password" hidden="">
<div class="row">
<div class="col-xs-12 col-sm-6">
<input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="<@spring.message "user.username"/>" name="username" />
</div>
<div class="col-xs-12 col-sm-6">
<input class="form-control form-control-solid placeholder-no-fix <#if code! == "LOGIN_NOT_MATCH">error</#if>" placeholder="<@spring.message "user.password"/>" id="password" type="password" autocomplete="off" name="password"/>
<script type="text/javascript">
$('#password').on('focus',function(){
$(this).attr('type','password');
})
</script>
</div>
</div>
<div class="row">
<div class="col-sm-6" style="position:relative">
<#if ENABLE_CAPTCHA >
<input class="form-control form-control-solid placeholder-no-fix <#if code! == 'CAPTCHA_INVALID'>error</#if>" placeholder="<@spring.message 'user.verifiCode'/>" type="text" name="verifiCode" />
<img id="imgObj" title="<@spring.message 'sys.login.refreshverificationcode'/>" src="${base.contextPath}/verifiCode" style="cursor:pointer;position:absolute;right:15px;top:-20px" onclick="changeCaptchaCode()" />
</#if>
</div>
<div class="col-sm-6 text-right">
<!--<div class="forgot-password">-->
<!--<a href="javascript:;" id="forget-password" class="forget-password">忘记密码 ?</a>-->
<!--</div>-->
<button class="btn blue" onclick="doLogin()" style="min-width:100px"><@spring.message "hap.login"/></button>
</div>
</div>
<input type="hidden" id="pubkey" name="pubkey" value="${PUB_KEY}"/>
</form>
</div>
<div class="login-footer">
<div class="row bs-reset">
<div class="col-xs-12 bs-reset">
<div class="login-copyright text-right">
<p> Copyright © 1996 - 2017 上海汉得信息技术股份有限公司.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--[if lt IE 9]>
<script src="${base.contextPath}/lib/assets/global/plugins/respond.min.js"></script>
<script src="${base.contextPath}/lib/assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="${base.contextPath}/lib//assets/global/plugins/backstretch/jquery.backstretch.min.js" type="text/javascript"></script>
<script src="${base.contextPath}/lib/assets/pages/scripts/login-5.js" type="text/javascript"></script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment