Commit 518fce8a authored by eddie.woo's avatar eddie.woo

Merge branch 'dev_oracle' of http://code.tech.tax.asia.pwcinternal.com/root/atms into dev_oracle

parents e8bfb201 a48b297f
......@@ -127,7 +127,7 @@ public class WPSR extends FunctionBase implements FreeRefFunction {
dto.setColumnName("");
dto.setRowName("");
dto.setReportName(ec.getWorkbook().getSheetName(ec.getSheetIndex()));
dto.setType(FormulaDataSourceType.Report.getCode());
dto.setType(FormulaDataSourceType.TrialBalanceSource.getCode());
Long dataSourceId = saveDataSource(ec, Lists.newArrayList(dto), FormulaDataSourceDetailType.InputInvoiceDataSourceDto, val, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, val, dataSourceId,
......
......@@ -111,6 +111,18 @@
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.nutz/nutz -->
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.63.r2</version>
</dependency>
</dependencies>
......@@ -198,7 +210,7 @@
<version>2.1</version>
<configuration>
<!-- 通过maven tomcat7:run运行项目时,访问项目的端口号 -->
<port>8080</port>
<port>28080</port>
<!-- 项目访问路径 本例:localhost:9090, 如果配置的aa, 则访问路径为localhost:9090/aa-->
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
......
package pwc.taxtech.atms.web.controller;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import pwc.taxtech.atms.dto.AtmsTokenDto;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
@Controller
@RequestMapping("/")
public class IndexController {
@Value("${api.url}")
private String apiUrl;
@Autowired
JwtUtil jwtUtil;
@RequestMapping(value = { "/", "/index", "/index.html" }, method = RequestMethod.GET)
public String login(@CookieValue(value = "AtmsApiToken", required = false) String atmsApiToken) {
@RequestMapping(value = {"/", "/index", "/index.html"}, method = RequestMethod.GET)
public String login(@CookieValue(value = "AtmsApiToken", required = false) String atmsApiToken,
@CookieValue(value = "LtpaToken", required = false) String ltpaToken,
HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (StringUtils.hasText(atmsApiToken)) {
return "index";
} else if (StringUtils.hasText(ltpaToken)) {
String user = LtpaToken.validate(ltpaToken);
if (StringUtils.isEmpty(user)) return "redirect:Account/LogOn";
else {
AtmsTokenDto token = new AtmsTokenDto();
String accessToken = jwtUtil.generateToken(user, user, user);
token.setAccess_token(accessToken);
token.setToken_type("bearer");
token.setExpires_in(86400000L);
// api_host可以由atms-web端来赋值
token.setApi_host(apiUrl);
token.setVat_api_host(apiUrl);
token.setTp_url(apiUrl);
token.setVersion("1.0" + ".0.0");
token.setUser_name(user);
token.setLocal_name(user);
token.setNeed_change_password(false);
token.setIs_external_user(true);
token.setUser_id(user);
String cookieString = JSON.toJSONString(token);
String cookieValue = URLEncoder.encode(cookieString, "UTF-8");
Cookie cookie = new Cookie("AtmsApiToken", cookieValue);
response.addCookie(cookie);
return "redirect:index";
}
}
return "redirect:Account/LogOn";
}
@RequestMapping(value = {"/admin", "/admin.html" }, method = RequestMethod.GET)
@RequestMapping(value = {"/admin", "/admin.html"}, method = RequestMethod.GET)
public String admin(@CookieValue(value = "AtmsApiToken", required = false) String atmsApiToken) {
if (StringUtils.hasText(atmsApiToken)) {
return "admin";
......
package pwc.taxtech.atms.web.controller;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.nutz.lang.Times;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.UUID;
@Component
public class JwtUtil {
private static final Logger logger = LoggerFactory.getLogger(JwtUtil.class);
@Value("${jwt.expireSecond}")
private Integer jwtExpireSecond;
@Value("${jwt.base64Secret}")
private String jwtBase64Secret;
/***
* @param username
* 登录名,大小写不限,可以是全大写或全小写,如:admin, ADMIN
* @param databaseUsername
* 数据库用户名, 比如Admin
* @param userid
* 用户Id
* @return
*/
public String generateToken(String username, String databaseUsername, String userid) {
Date now = new Date();
// 过期时间设置为2天
int expireSecond = jwtExpireSecond;
Date expiration = Times.nextSecond(now, expireSecond);
JwtBuilder jwtBuilder = Jwts.builder();
// 设置Subject为登录用户名
jwtBuilder.setSubject(username);
jwtBuilder.setExpiration(expiration);
jwtBuilder.setIssuedAt(now);
// 设置时钟误差偏移量,即10分钟
Date notBefore = Times.nextSecond(now, -600);
jwtBuilder.setNotBefore(notBefore);
jwtBuilder.setId(getUUID());
jwtBuilder.claim("username", username);
jwtBuilder.claim("databaseUsername", databaseUsername);
jwtBuilder.claim("userid", userid);
// 设置body.username为数据库用户名
jwtBuilder.signWith(SignatureAlgorithm.HS512, jwtBase64Secret);
return jwtBuilder.compact();
}
public static String getUUID() {
return UUID.randomUUID().toString().toUpperCase();
}
}
\ No newline at end of file
package pwc.taxtech.atms.web.controller;
import org.apache.commons.codec.binary.Base64;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;
public class LtpaToken {
private byte[] header;
private byte[] creation;
private byte[] expires;
private byte[] user;
//SHA-1校验和(长度20)
private byte[] digest;
private Date creationDate;
private Date expiresDate;
private byte[] hash;
private String ltpaToken;
private Properties properties = null;
private byte[] rawToken;
/*
* //Cookie name.
* public final static String COOKIE_NAME =PropertiesUtil.findPropertyInClasspath("conf/sso-config.properties","sso.ltpa.cookie.name");///"LtpaToken";
*
* //private final static String COOKIE_DOMAIN = ".blabla.bla.NET";
*
* private final static String DOMINO_SECRET =PropertiesUtil.findPropertyInClasspath("conf/sso-config.properties","sso.ltpa.cookie.secret"); //"密钥";
*/
public final static String COOKIE_NAME = "LtpaToken";
// private final static String DOMINO_SECRET = "JytUSYHnoFtU9dbkyXUny7FPn88="; // "密钥";
private final static String DOMINO_SECRET = "UFrEIY2n686Ph6kRB6X4Hjp41NA="; // "密钥";
public LtpaToken() {
init();
}
public LtpaToken(String token) {
init();
ltpaToken = token;
rawToken = Base64.decodeBase64(token);
user = new byte[(rawToken.length) - 40];
for (int i = 0; i < 4; i++) {
header[i] = rawToken[i];
}
for (int i = 4; i < 12; i++) {
creation[i - 4] = rawToken[i];
}
for (int i = 12; i < 20; i++) {
expires[i - 12] = rawToken[i];
}
for (int i = 20; i < (rawToken.length - 20); i++) {
user[i - 20] = rawToken[i];
}
for (int i = (rawToken.length - 20); i < rawToken.length; i++) {
digest[i - (rawToken.length - 20)] = rawToken[i];
}
creationDate = new Date(Long.parseLong(new String(creation), 16) * 1000);
setExpiresDate(new Date(Long.parseLong(new String(expires), 16) * 1000));
}
private void init() {
creation = new byte[8];
digest = new byte[20];
expires = new byte[8];
hash = new byte[20];
header = new byte[4];
}
/**
* 创建一个新的SHA-1代码>消息IGEST < /代码>实例
*
* @return
* @method getDigest Create on 2018年6月29日 上午11:33:24
* Copyright (c) 2018 by future-info.
* @author caoj
* @tel 15991758179
* @mail caoj@landray.com.cn
* @version 0.1
*/
private MessageDigest getDigest() {
try {
return MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException nsae) {
}
return null;
}
/**
* 给定参数生成一个新的LTPATOKEN
*
* @param canonicalUser 登录名
* @param tokenCreation token创建时间
* @param tokenExpires token过期时间
* @return
* @method generate Create on 2018年6月29日 上午11:32:26
* Copyright (c) 2018 by future-info.
* @author caoj
* @tel 15991758179
* @mail caoj@landray.com.cn
* @version 0.1
*/
public static LtpaToken generate(String canonicalUser, Date tokenCreation, Date tokenExpires) {
LtpaToken ltpa = new LtpaToken();
Calendar calendar = Calendar.getInstance();
MessageDigest md = ltpa.getDigest();
ltpa.header = new byte[]{0, 1, 2, 3};
ltpa.user = canonicalUser.getBytes();
byte[] token = null;
calendar.setTime(tokenCreation);
ltpa.creation = Long.toHexString(calendar.getTime().getTime() / 1000).toUpperCase().getBytes();
calendar.setTime(tokenExpires);
// calendar.add(Calendar.HOUR,8);
ltpa.expires = Long.toHexString(calendar.getTime().getTime() / 1000).toUpperCase().getBytes();
ltpa.user = canonicalUser.getBytes();
token = concatenate(token, ltpa.header);
token = concatenate(token, ltpa.creation);
token = concatenate(token, ltpa.expires);
token = concatenate(token, ltpa.user);
md.update(token);
ltpa.digest = md.digest(Base64.decodeBase64(DOMINO_SECRET));
token = concatenate(token, ltpa.digest);
return new LtpaToken(new String(Base64.encodeBase64(token)));
}
/**
* 连接字节数组的帮助方法
*
* @param a
* @param b
* @return
* @method concatenate Create on 2018年6月29日 上午11:33:47
* Copyright (c) 2018 by future-info.
* @author caoj
* @tel 15991758179
* @mail caoj@landray.com.cn
* @version 0.1
*/
private static byte[] concatenate(byte[] a, byte[] b) {
if (a == null) {
return b;
} else {
byte[] bytes = new byte[a.length + b.length];
System.arraycopy(a, 0, bytes, 0, a.length);
System.arraycopy(b, 0, bytes, a.length, b.length);
return bytes;
}
}
public String toString() {
return ltpaToken;
}
/**
* 通过获取cookie指定名称的token值,解析用户是否合法并
* 返回用户名 或抛异常
*
* @param token
* @return
* @method validate Create on 2018年6月29日 上午11:34:24
* Copyright (c) 2018 by future-info.
* @author caoj
* @tel 15991758179
* @mail caoj@landray.com.cn
* @version 0.1
*/
public static String validate(String token) {
LtpaToken ltpa = new LtpaToken(token);
byte[] sh1 = null;
MessageDigest md = ltpa.getDigest();
sh1 = concatenate(sh1, ltpa.header);
sh1 = concatenate(sh1, ltpa.creation);
sh1 = concatenate(sh1, ltpa.expires);
sh1 = concatenate(sh1, ltpa.user);
md.update(sh1);
//通过解析token值获取到的用户名
System.err.println(new String(ltpa.user));
byte[] ndigest = md.digest(Base64.decodeBase64(DOMINO_SECRET));
//当前时间
Long date = Calendar.getInstance().getTimeInMillis();
//校验密文合法性、校验时间合法性
if (Arrays.equals(ndigest, ltpa.digest) && date >= ltpa.creationDate.getTime() && date <= ltpa.expiresDate.getTime()) {
return new String(ltpa.user);
}
return null;
}
/**
* 将cookie封装到Map里面
*
* @param request
* @return
* @method ReadCookieMap Create on 2018年6月29日 上午11:35:45
* Copyright (c) 2018 by future-info.
* @author caoj
* @tel 15991758179
* @mail caoj@landray.com.cn
* @version 0.1
*/
// public static Map<String, Cookie> ReadCookieMap(HttpServletRequest request) {
// Map<String, Cookie> cookieMap = new HashMap<String, Cookie>();
// Cookie[] cookies = request.getCookies();
// if (null != cookies) {
// for (Cookie cookie : cookies) {
// cookieMap.put(cookie.getName(), cookie);
// }
// }
// return cookieMap;
// }
public static void main(String[] args) {
try {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LtpaToken token = LtpaToken.generate("SuperAdmin", sd.parse("2018-11-28 00:00:00"), sd.parse("2018-12-27 23:59:59"));
System.out.println("组装——" + token.toString());
// System.out.println("解析登录名——" + LtpaToken.validate(token.toString()));
System.out.println("解析登录名——" + LtpaToken.validate(token.toString()));
//System.out.println(URLDecoder.decode("cookie=LtpaToken%3DAAECAzVCNEQ3NkQwNUI0RDc2RTkxMDM5MjX0gUNwIFvV2RqsWiPrETS2HCRERA%3D%3D&url=http%3A%2F%2Foa%2Ech%2Ecom%2Ecn%3A8080%2Fekp%2Fkm%2Fcarmng%2Eindex", "utf-8"));
System.out.println(URLEncoder.encode("LtpaToken=" + token.toString()));
//http://kk.ch.com.cn:8000/serverj/forward?domanId=3&cookie=LtpaToken%3DAAECAzVCNENDMTAwNUI0RTEyN0YxMDM5MjawmMtC7Et4uESvZgLgSuBaoaejKQ%3D%3D&url=http%3A%2F%2Foa%2Ech%2Ecom%2Ecn%3A8080%2Fekp%2Fkm%2Fcarmng%2Eindex
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
public Date getExpiresDate() {
return expiresDate;
}
public void setExpiresDate(Date expiresDate) {
this.expiresDate = expiresDate;
}
}
\ No newline at end of file
api.url=${api.url}
cookie.maxAgeSeconds=${cookie.maxAgeSeconds}
\ No newline at end of file
cookie.maxAgeSeconds=${cookie.maxAgeSeconds}
jwt.base64Secret=${jwt.base64Secret}
jwt.powerToken=${jwt.powerToken}
jwt.expireSecond=${jwt.expireSecond}
jwt.refreshSecond=${jwt.refreshSecond}
\ No newline at end of file
api.url=http://etms.longi-silicon.com:8180/
api.url=http://10.158.230.144:8181/
cookie.maxAgeSeconds=86400
jwt.base64Secret=TXppQjFlZFBSbnJzMHc0Tg==
jwt.powerToken=xxxx
jwt.expireSecond=180000
jwt.refreshSecond=600
api.url=http://etms.longi-silicon.com:8181/
cookie.maxAgeSeconds=86400
jwt.base64Secret=TXppQjFlZFBSbnJzMHc0Tg==
jwt.powerToken=xxxx
jwt.expireSecond=180000
jwt.refreshSecond=600
api.url=http://etms.longi-silicon.com:8182/
cookie.maxAgeSeconds=86400
jwt.base64Secret=TXppQjFlZFBSbnJzMHc0Tg==
jwt.powerToken=xxxx
jwt.expireSecond=180000
jwt.refreshSecond=600
......@@ -239,11 +239,42 @@
closeOnCancel: true
},
function (isConfirm) {
if (isConfirm) {
doConfirmEventHandler();
if(isConfirm){
var message;
var r = /^00\d*|^\.\d+|\.$/;
if ($scope.detail.inputValue && (isNaN($scope.detail.inputValue) || r.test($scope.detail.inputValue))) {
message = $translate.instant('CheckInputValueFormat');
} else if ($scope.detail.inputValue && parseFloat($scope.detail.inputValue).toFixed(2) > 9999999999999) {
message = $translate.instant('CheckInputValueLength');
} else if ($scope.detail.dataType === 5) {
r = /^(-[1-9]\d*|[1-9]\d*|[0]{1,1})$/;
if (!r.test($scope.detail.inputValue)) {
message = $translate.instant('CheckIntInputValue');
}
}
if ($scope.detail.inputMemo && $scope.detail.inputMemo.length > 500) {
message = $translate.instant('CheckInputMemoLength');
}
if (message) {
setTimeout(function () {
swal({
title: "warning!",
text: message,
type: "warning",
showCancelButton: false,
confirmButtonColor: "#DD6B55",
confirmButtonText: '确认',
closeOnConfirm: true
}, function (isConfirm) {
if (isConfirm) {
return;
}
})},500);
} else {
doConfirmEventHandler();
}
}
else {
swal.close();
}
});
......@@ -736,6 +767,8 @@
return '贷方发生';
} else if(formula.indexOf('JFFS') > -1){
return '借方发生';
} else if(formula.indexOf('WPSR') > -1){
return 'WPSR';
}
return '';
},
......
......@@ -277,6 +277,11 @@
return regionName;
};
$scope.loginAtms =function(){
document.cookie="LtpaToken=AAECAzVCRkQ2QTAwNUMyNEY2RkZTdXBlckFkbWlumd6hrZ2+cxiAEdE7sMEjLrIBGGg=;";
window.open("http://localhost:18080/index","_blank");
}
$scope.initCitDataProcessMockData = function () {
var task = function (id, status, name, tasklevel, parentId, hasButton, seqNo) {
this.id = id;
......
......@@ -51,6 +51,7 @@
<input type="text" id="overviewDatepicker" class="datepicker vat-subheader" style="width:120px;" readonly="readonly" />
<i class="fa fa-calendar vat-subheader red-color" style="width:20px;"></i>
</div>-->
<!--<span style="background-color:red" ng-click="loginAtms()">SuperAdmin登陆Atms_index</span>-->
</div>
<div class="project-staus">
<span style="padding-right: 10px;" class="result-style">{{projectMsg}}</span>
......
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