Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
99daacb5
Commit
99daacb5
authored
Oct 30, 2018
by
钱雯君
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
536fbc63
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
571 additions
and
0 deletions
+571
-0
HdtoolConfDB.java
src/test/java/http/db/HdtoolConfDB.java
+110
-0
DESCrypto.java
src/test/java/utils/DESCrypto.java
+133
-0
HbaseService.java
src/test/java/utils/HbaseService.java
+67
-0
Md5SignGen.java
src/test/java/utils/Md5SignGen.java
+73
-0
PublicMethod.java
src/test/java/utils/PublicMethod.java
+21
-0
RedisUtil.java
src/test/java/utils/RedisUtil.java
+70
-0
TypeChangeUtil.java
src/test/java/utils/TypeChangeUtil.java
+50
-0
decode.java
src/test/java/utils/decode.java
+47
-0
No files found.
src/test/java/http/db/HdtoolConfDB.java
0 → 100644
View file @
99daacb5
package
http
.
db
;
import
base.MysqlUtils
;
import
java.sql.SQLException
;
import
java.util.Map
;
/**
* hdtool_conf库 数据库操作类
* Created by hubinbin on 2018/3/29.
*
*/
//@Service
public
class
HdtoolConfDB
{
MysqlUtils
jdbc
=
MysqlUtils
.
mysqlDuiba
(
"hdtool_conf"
);
/**
* 自定义活动工具
* @param id 自定义活动工具id
* @return
*/
public
Map
<
String
,
Object
>
selectDuibaHdTool
(
Long
id
)
{
try
{
Map
<
String
,
Object
>
map
=
jdbc
.
findSimpleResult
(
" SELECT * FROM duiba_hdtool where id="
+
id
);
return
map
;
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
return
null
;
}
public
boolean
deleteDuibaHdTool
(
Long
id
)
{
try
{
return
jdbc
.
update
(
"delete from duiba_hdtool where id="
+
id
);
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
return
false
;
}
/**
* 答题-题库
* @param name 题库名称
* @return
*/
public
Map
<
String
,
Object
>
selectDuibaQuestionBank
(
String
name
)
{
try
{
Map
<
String
,
Object
>
map
=
jdbc
.
findSimpleResult
(
"SELECT * FROM duiba_question_bank where name = '"
+
name
+
"'"
);
return
map
;
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
return
null
;
}
public
boolean
deleteDuiBaQuestionBank
(
Integer
bankId
)
{
try
{
return
jdbc
.
update
(
"delete from duiba_question_bank where id="
+
bankId
);
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
return
false
;
}
/**
* 答题-题目
* @param qid
* @return
*/
public
Map
<
String
,
Object
>
selectDuibaQuestionRecord
(
Integer
qid
){
try
{
Map
<
String
,
Object
>
map
=
jdbc
.
findSimpleResult
(
"SELECT * FROM duiba_question_record where id = "
+
qid
);
return
map
;
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
return
null
;
}
/**
* 总计题库下的题目数
* @param bankId
* @return
*/
public
Map
<
String
,
Object
>
countQuesRecodeByBankId
(
Integer
bankId
){
try
{
Map
<
String
,
Object
>
map
=
jdbc
.
findSimpleResult
(
"SELECT count(*) as cnum FROM duiba_question_record where bank_id=? and deleted=0"
,
bankId
);
return
map
;
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
return
null
;
}
/**
* 清理题库的题目
* @param bankId
* @return
*/
public
boolean
deleteQuestionRecord
(
Integer
bankId
)
{
try
{
return
jdbc
.
update
(
"delete from duiba_question_record where bank_id="
+
bankId
);
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
return
false
;
}
}
src/test/java/utils/DESCrypto.java
0 → 100644
View file @
99daacb5
/**
* Copyright (C), 2015-2018
* FileName: DESCrypto
* Author: qianwenjun
* Date: 2018/6/23 11:06
* Description:
*/
package
utils
;
import
base.DuibaLog
;
import
org.apache.commons.codec.DecoderException
;
import
org.apache.commons.codec.binary.Hex
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.security.GeneralSecurityException
;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/6/23
* @since 1.0.0
*/
public
class
DESCrypto
{
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
static
final
String
DES_KEY
=
"ZO-=/lFQhv0DjGph0TkuIqw+"
;
private
static
final
String
TRIPLE_DES
=
"TripleDES"
;
public
static
String
encrypt3DE
(
String
source
)
{
if
(
source
==
null
)
{
return
null
;
}
try
{
SecretKeySpec
spec
=
new
SecretKeySpec
(
DES_KEY
.
getBytes
(),
"DESede"
);
// Cipher对象实际完成加密操作
Cipher
cipher
=
Cipher
.
getInstance
(
TRIPLE_DES
);
// 用密匙初始化Cipher对象
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
spec
);
byte
[]
data
=
cipher
.
doFinal
(
URLEncoder
.
encode
(
source
,
"UTF-8"
).
getBytes
());
return
new
String
(
Hex
.
encodeHex
(
data
,
false
));
}
catch
(
GeneralSecurityException
|
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
String
decrypt3DE1
(
String
encrypted
)
{
if
(
encrypted
==
null
)
{
return
null
;
}
try
{
SecretKeySpec
spec
=
new
SecretKeySpec
(
DES_KEY
.
getBytes
(),
"DESede"
);
// Cipher对象实际完成加密操作
Cipher
cipher
=
Cipher
.
getInstance
(
TRIPLE_DES
);
// 用密匙初始化Cipher对象
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
spec
);
byte
[]
data
=
cipher
.
doFinal
(
Hex
.
decodeHex
(
encrypted
.
toCharArray
()));
return
new
String
(
data
,
"utf-8"
);
}
catch
(
GeneralSecurityException
|
DecoderException
|
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
String
decrypt3DE
(
String
encrypted
)
{
if
(
encrypted
==
null
)
{
return
null
;
}
try
{
SecretKeySpec
spec
=
new
SecretKeySpec
(
DES_KEY
.
getBytes
(),
"DESede"
);
// Cipher对象实际完成加密操作
Cipher
cipher
=
Cipher
.
getInstance
(
TRIPLE_DES
);
// 用密匙初始化Cipher对象
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
spec
);
byte
[]
data
=
cipher
.
doFinal
(
Hex
.
decodeHex
(
encrypted
.
toCharArray
()));
String
str
=
new
String
(
data
,
"utf-8"
);
//对encode的字符串解码
str
=
java
.
net
.
URLDecoder
.
decode
(
str
,
"UTF-8"
);
return
str
;
}
catch
(
GeneralSecurityException
|
DecoderException
|
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
String
decryptJS3DES
(
String
key
)
{
try
{
key
=
key
.
substring
(
2
,
key
.
length
());
String
jsKey
=
DES_KEY
;
SecretKeySpec
secretKeySpec
=
new
SecretKeySpec
(
jsKey
.
getBytes
(),
TRIPLE_DES
);
// Cipher对象实际完成加密操作
Cipher
cipher
=
Cipher
.
getInstance
(
TRIPLE_DES
);
// 用密匙初始化Cipher对象
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKeySpec
);
// 现在,获取数据并加密
// 正式执行加密操作
byte
[]
data
=
cipher
.
doFinal
(
" "
.
getBytes
());
String
strRandom
=
new
String
(
Hex
.
encodeHex
(
data
,
false
));
String
strSuffix
=
strRandom
.
substring
(
strRandom
.
length
()
-
16
);
String
cipherText
=
key
.
toUpperCase
().
substring
(
0
,
key
.
length
()
-
16
)
+
strSuffix
;
Cipher
newCipher
=
Cipher
.
getInstance
(
TRIPLE_DES
);
newCipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKeySpec
);
byte
[]
result
=
newCipher
.
doFinal
(
Hex
.
decodeHex
(
cipherText
.
toCharArray
()));
return
new
String
(
result
,
"utf-8"
);
}
catch
(
GeneralSecurityException
|
DecoderException
|
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
DESCrypto
DESCrypto
=
new
DESCrypto
();
String
code
=
DESCrypto
.
encrypt3DE
(
"浙江省"
);
logger
.
info
(
"code="
+
code
);
String
enCode
=
DESCrypto
.
decrypt3DE
(
code
);
logger
.
info
(
"enCode="
+
enCode
);
//CF2B53B5988A06B08F89466E2807C1AB3C27FA3CBF77D5E03C3417752DFC848868178CF4807B0D3D
//CF2B53B5988A06B08F89466E2807C1AB3C27FA3CBF77D5E03C3417752DFC848868178CF4807B0D3D
}
}
\ No newline at end of file
src/test/java/utils/HbaseService.java
0 → 100644
View file @
99daacb5
/**
* Copyright (C), 2015-2018
* FileName: HbaseService
* Author: qianwenjun
* Date: 2018/8/27 18:20
* Description:
*/
package
utils
;
import
http.service.Authorization
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/27
* @since 1.0.0
*/
@Service
public
class
HbaseService
{
@Value
(
"${activity.host}"
)
String
activtyHost
;
@Autowired
Authorization
authorization
;
public
Response
getHBASEKey
(
String
key
)
{
String
url
=
activtyHost
+
"/activity/hb/get"
;
Map
<
String
,
Object
>
parm
=
new
HashMap
<>();
parm
.
put
(
"key"
,
key
);
parm
.
put
(
"code"
,
"DuiBaHbase"
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
2721
)).
params
(
parm
).
get
(
url
);
// response.prettyPrint();
return
response
;
}
public
void
deleteHBASEKey
(
String
key
)
{
String
url
=
activtyHost
+
"/activity/hb/delete"
;
Map
<
String
,
Object
>
parm
=
new
HashMap
<>();
parm
.
put
(
"key"
,
key
);
parm
.
put
(
"code"
,
"DuiBaHbase"
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
2721
)).
params
(
parm
).
get
(
url
);
// response.prettyPrint();
// return response;
}
}
\ No newline at end of file
src/test/java/utils/Md5SignGen.java
0 → 100644
View file @
99daacb5
/**
* Copyright (C), 2015-2018
* FileName: Md5SignGen
* Author: qianwenjun
* Date: 2018/10/10 15:51
* Description:
*/
package
utils
;
import
cn.com.duiba.credits.sdk.CreditTool
;
import
cn.com.duiba.credits.sdk.SignTool
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/10/10
* @since 1.0.0
*/
public
class
Md5SignGen
{
public
static
void
genSignUrl
(){
Random
rand
=
new
Random
();
int
randNum
=
rand
.
nextInt
(
100000
);
CreditTool
tool
=
new
CreditTool
(
"jlg88lyxz7siqtmr"
,
"CjexurxQmvyYXt94K9Dqg5292dKMiFUWo22hEkKmu"
);
// String url="https://home.m.duiba.com.cn/autoLogin/autologin?";
// String url="http://activity-pre.m.duiba.com.cn/aaw/api/notify?";
String
url
=
"http://activity.m.duibatest.com.cn/aaw/api/notify?"
;
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"uid"
,
"1"
);
//params.put("redirect", "https://activity.m.duiba.com.cn/hdtool/index?id=3018093");
//params.put("dcustom","isNewUser%3Dtrue%26isTopUp%3Dtrue");
params
.
put
(
"timestamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
params
.
put
(
"bizNum"
,
String
.
valueOf
(
randNum
));
params
.
put
(
"activityId"
,
"1"
);
params
.
put
(
"extra"
,
"count%3D1%26operationType%3Draise"
);
params
.
put
(
"taskType"
,
"2"
);
String
autologinUrl
=
tool
.
buildUrlWithSign
(
url
,
params
);
System
.
out
.
println
(
autologinUrl
);
}
//String appKey,String appSecret,String timestamp
public
static
void
genSign
(
Map
<
String
,
String
>
params
){
Map
<
String
,
String
>
newparams
=
new
HashMap
();
newparams
.
put
(
"appKey"
,
params
.
get
(
"appKey"
));
newparams
.
put
(
"appSecret"
,
params
.
get
(
"appSercret"
));
if
(
newparams
.
get
(
"timestamp"
)
==
null
)
{
newparams
.
put
(
"timestamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
}
String
sign
=
SignTool
.
sign
(
newparams
);
System
.
out
.
println
(
sign
);
}
public
static
void
main
(
String
[]
args
)
{
genSignUrl
();
// Map<String,String> map = new HashMap<>();
// map.put("appKey","");
// map.put("appSecret","");
// map.put("timestamp",String.valueOf(System.currentTimeMillis()));
System
.
out
.
println
(
"时间戳为="
+
String
.
valueOf
(
System
.
currentTimeMillis
()));
}
}
\ No newline at end of file
src/test/java/utils/PublicMethod.java
0 → 100644
View file @
99daacb5
package
utils
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* Created by zhaoran on 2018/4/10.
*/
public
class
PublicMethod
{
/**
* Function:创建时间标记
* return: 返回当前时间的字符串
* author: zhaoran
*/
public
static
String
data
()
{
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
//设置日期格式
String
date
=
df
.
format
(
new
Date
());
// new Date()为获取当前系统时间,也可使用当前时间戳
return
date
;
}
}
src/test/java/utils/RedisUtil.java
0 → 100644
View file @
99daacb5
package
utils
;
import
io.restassured.response.Response
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by mabo on 2018/8/16
*/
public
class
RedisUtil
{
//Stringredis
public
static
String
getKey
(
String
key
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"key"
,
key
);
Response
response
=
given
().
params
(
map
).
get
(
"http://activity.m.duibatest.com.cn/seedRedPacket/getKey"
);
return
response
.
jsonPath
().
getString
(
"data"
);
}
public
static
String
getTtlKey
(
String
key
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"key"
,
key
);
Response
response
=
given
().
params
(
map
).
get
(
"http://activity.m.duibatest.com.cn/seedRedPacket/getTtlByKey"
);
return
response
.
jsonPath
().
getString
(
"data"
);
}
public
static
void
setKey
(
String
key
,
String
value
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"key"
,
key
);
map
.
put
(
"value"
,
value
);
Response
response
=
given
().
params
(
map
).
get
(
"http://activity.m.duibatest.com.cn/seedRedPacket/setKey"
);
}
public
static
void
clearKey
(
String
key
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"key"
,
key
);
Response
response
=
given
().
params
(
map
).
get
(
"http://activity.m.duibatest.com.cn/seedRedPacket/clearKey"
);
}
//redis
public
static
String
getObjectKey
(
String
key
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"key"
,
key
);
Response
response
=
given
().
params
(
map
).
get
(
"http://activity.m.duibatest.com.cn/seedRedPacket/getObjectKey"
);
return
response
.
jsonPath
().
getString
(
"data"
);
}
public
static
void
clearObjectKey
(
String
key
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"key"
,
key
);
Response
response
=
given
().
params
(
map
).
get
(
"http://activity.m.duibatest.com.cn/seedRedPacket/clearObjectKey"
);
}
public
static
void
main
(
String
[]
args
)
{
Date
dNow
=
new
Date
(
);
SimpleDateFormat
ft
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
System
.
out
.
println
(
ft
.
format
(
dNow
));
}
}
src/test/java/utils/TypeChangeUtil.java
0 → 100644
View file @
99daacb5
/**
* Copyright (C), 2015-2018
* FileName: TypeChangeUtil
* Author: qianwenjun
* Date: 2018/9/5 13:47
* Description:
*/
package
utils
;
import
java.beans.BeanInfo
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/9/5
* @since 1.0.0
*/
public
class
TypeChangeUtil
{
public
static
Map
<
String
,
Object
>
ObjectToMap
(
Object
obj
)
{
Map
<
String
,
Object
>
para
=
new
HashMap
<>();
try
{
BeanInfo
beanInfo
=
null
;
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
if
(
key
.
compareToIgnoreCase
(
"class"
)
==
0
)
{
continue
;
}
Method
getter
=
property
.
getReadMethod
();
Object
value
=
getter
!=
null
?
getter
.
invoke
(
obj
)
:
null
;
para
.
put
(
key
,
value
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
para
;
}
}
\ No newline at end of file
src/test/java/utils/decode.java
0 → 100644
View file @
99daacb5
/**
* Copyright (C), 2015-2018
* FileName: decode
* Author: qianwenjun
* Date: 2018/6/23 10:44
* Description:
*/
package
utils
;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/6/23
* @since 1.0.0
*/
public
class
decode
{
public
String
pub
=
""
;
public
void
decode
(
String
str
)
{
if
(
str
.
charAt
(
0
)
==
'_'
)
{
pub
=
pub
+
"//UL"
;
}
else
if
(
"123456789"
.
indexOf
(
str
.
charAt
(
0
))
==
-
1
){
pub
=
pub
+
str
.
charAt
(
0
)+
"_"
;
}
else
if
(
str
.
length
()==
1
){
pub
=
pub
+
str
;
return
;
}
else
{
for
(
int
i
=
0
;
i
<
"123456789"
.
indexOf
(
str
.
charAt
(
0
))+
2
;
i
++){
pub
=
pub
+
str
.
charAt
(
1
);
pub
=
pub
+
"_"
;
}
}
if
(
str
.
length
()
!=
1
){
this
.
decode
(
str
.
substring
(
1
));
}
}
public
static
void
main
(
String
[]
args
)
{
decode
d
=
new
decode
();
d
.
decode
(
"http%3A%2F%2Factivity.m.duibatest.com.cn%2Fngame%2Fpreview%3Fid%3D1338%26type%3Dduiba%26dbnewopen"
);
System
.
out
.
println
(
d
.
pub
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment