Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
asset-app
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
asset-app
Commits
a5d56b9f
Commit
a5d56b9f
authored
Apr 18, 2023
by
youguoqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录加入标志位方便后台不去解密用户名密码(SM2加密方式因M10设备系统不支持屏蔽)
parent
f7c16ce3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
8 deletions
+103
-8
app/build.gradle
+3
-1
app/src/main/java/com/stm/asset/base/ConfigKey.java
+2
-3
app/src/main/java/com/stm/asset/base/StmApplication.java
+2
-2
app/src/main/java/com/stm/asset/http/HttpService.java
+1
-0
app/src/main/java/com/stm/asset/utils/SM2Util.java
+83
-0
build.gradle
+10
-2
gradle.properties
+2
-0
No files found.
app/build.gradle
View file @
a5d56b9f
...
@@ -13,7 +13,7 @@ android {
...
@@ -13,7 +13,7 @@ android {
minSdkVersion
21
minSdkVersion
21
targetSdkVersion
28
targetSdkVersion
28
versionCode
1
versionCode
1
versionName
"1.
0
"
versionName
"1.
1
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
multiDexEnabled
true
}
}
...
@@ -39,8 +39,10 @@ dependencies {
...
@@ -39,8 +39,10 @@ dependencies {
implementation
'androidx.multidex:multidex:2.0.1'
implementation
'androidx.multidex:multidex:2.0.1'
implementation
"androidx.room:room-runtime:2.2.3"
implementation
"androidx.room:room-runtime:2.2.3"
annotationProcessor
"androidx.room:room-compiler:2.2.3"
annotationProcessor
"androidx.room:room-compiler:2.2.3"
implementation
'cn.hutool:hutool-all:5.7.19'
implementation
'com.github.bumptech.glide:glide:3.7.0'
implementation
'com.github.bumptech.glide:glide:3.7.0'
implementation
'com.google.code.gson:gson:2.8.9'
implementation
'com.google.code.gson:gson:2.8.9'
implementation
'org.bouncycastle:bcprov-jdk15on:1.68'
implementation
'com.squareup.okhttp3:okhttp:3.14.2'
implementation
'com.squareup.okhttp3:okhttp:3.14.2'
implementation
'com.squareup.okio:okio:1.17.4'
implementation
'com.squareup.okio:okio:1.17.4'
implementation
'com.tencent.bugly:crashreport:3.4.4'
implementation
'com.tencent.bugly:crashreport:3.4.4'
...
...
app/src/main/java/com/stm/asset/base/ConfigKey.java
View file @
a5d56b9f
...
@@ -4,11 +4,10 @@ public class ConfigKey {
...
@@ -4,11 +4,10 @@ public class ConfigKey {
public
final
static
String
GATEWAYIP
=
"mfms.citictrust.com.cn"
;
public
final
static
String
GATEWAYIP
=
"mfms.citictrust.com.cn"
;
public
final
static
String
GATWAYPORT
=
""
;
public
final
static
String
GATWAYPORT
=
""
;
// http://10.50.251.101
18081
测试地址
// http://10.50.251.101
8848
测试地址
// https://fms.citictrust.com.cn 生产地址
// https://
m
fms.citictrust.com.cn 生产地址
public
final
static
String
PLAYFORM
=
"FMPAPP"
;
public
final
static
String
PLAYFORM
=
"FMPAPP"
;
// CJFKAPP 长江养老
public
final
static
String
SIGNATURENAME
=
"stream"
;
// 测试环境请配置成stream(生产环境具体再通知)
public
final
static
String
SIGNATURENAME
=
"stream"
;
// 测试环境请配置成stream(生产环境具体再通知)
public
final
static
String
SIGNATUREPASSWORD
=
"stream123"
;
// 测试环境请配置成stream123(生产环境具体再通知)
public
final
static
String
SIGNATUREPASSWORD
=
"stream123"
;
// 测试环境请配置成stream123(生产环境具体再通知)
...
...
app/src/main/java/com/stm/asset/base/StmApplication.java
View file @
a5d56b9f
...
@@ -51,8 +51,8 @@ public class StmApplication extends Application {
...
@@ -51,8 +51,8 @@ public class StmApplication extends Application {
// 开启bugly异常捕获
// 开启bugly异常捕获
CrashReport
.
UserStrategy
strategy
=
new
CrashReport
.
UserStrategy
(
getApplicationContext
());
CrashReport
.
UserStrategy
strategy
=
new
CrashReport
.
UserStrategy
(
getApplicationContext
());
strategy
.
setAppChannel
(
"
BASE"
);
//设置渠道
strategy
.
setAppChannel
(
"
ZXXTU8"
);
CrashReport
.
initCrashReport
(
getApplicationContext
(),
"
24e17bedee"
,
tru
e
,
strategy
);
CrashReport
.
initCrashReport
(
getApplicationContext
(),
"
9f314845ea"
,
fals
e
,
strategy
);
}
}
public
static
StmApplication
getInstance
()
{
public
static
StmApplication
getInstance
()
{
...
...
app/src/main/java/com/stm/asset/http/HttpService.java
View file @
a5d56b9f
...
@@ -28,6 +28,7 @@ public class HttpService {
...
@@ -28,6 +28,7 @@ public class HttpService {
RequestParams
params
=
new
RequestParams
();
RequestParams
params
=
new
RequestParams
();
params
.
addBodyParameter
(
"username"
,
accout
);
params
.
addBodyParameter
(
"username"
,
accout
);
params
.
addBodyParameter
(
"password"
,
password
);
params
.
addBodyParameter
(
"password"
,
password
);
params
.
addBodyParameter
(
"fromM10"
,
"Y"
);
HttpUtil
.
getInstance
().
sendJson
(
InterfaceKey
.
UNIONLOGINAPP
,
params
,
requestCallback
);
HttpUtil
.
getInstance
().
sendJson
(
InterfaceKey
.
UNIONLOGINAPP
,
params
,
requestCallback
);
}
}
...
...
app/src/main/java/com/stm/asset/utils/SM2Util.java
0 → 100644
View file @
a5d56b9f
package
com
.
stm
.
asset
.
utils
;
import
org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey
;
import
cn.hutool.core.util.HexUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SmUtil
;
import
cn.hutool.crypto.asymmetric.KeyType
;
import
cn.hutool.crypto.asymmetric.SM2
;
/**
* SM2国密工具类
* @author LIULEI
*/
public
class
SM2Util
{
private
final
static
String
publicKey
=
"MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEOqXlubX090WW6WQ1msIpw/b+DsZRtGQG1Cs0WYS2q8HQq76CYYqN1W3wiw6bf9GjY+SS/z4k8UCn0c7R8aqfIA=="
;
private
final
static
String
publicQKey
=
"043aa5e5b9b5f4f74596e964359ac229c3f6fe0ec651b46406d42b345984b6abc1d0abbe82618a8dd56df08b0e9b7fd1a363e492ff3e24f140a7d1ced1f1aa9f20"
;
private
final
static
String
privateKey
=
"MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgoy5Dj/P5Dw+xhkPLz7riyylgBOkUDKmxfb0a4PzVCgigCgYIKoEcz1UBgi2hRANCAAQ6peW5tfT3RZbpZDWawinD9v4OxlG0ZAbUKzRZhLarwdCrvoJhio3VbfCLDpt/0aNj5JL/PiTxQKfRztHxqp8g"
;
public
static
void
getSm2KeyPair
()
{
SM2
sm2
=
SmUtil
.
sm2
();
/* 公钥 */
String
publicKey
=
sm2
.
getPublicKeyBase64
();
System
.
out
.
println
(
"publicKey>>【"
+
publicKey
+
"】"
);
/* js端公钥 JS代码实现 SM2的方案,都是直接使用的私钥的d值和公钥的q值直接进行的加解密,所以后端返回的最好是从公钥里面提取的q值,以q值作为js端的加密公钥 */
String
publicQKey
=
HexUtil
.
encodeHexStr
(((
BCECPublicKey
)
sm2
.
getPublicKey
()).
getQ
().
getEncoded
(
false
));
System
.
out
.
println
(
"publicQKey>>【"
+
publicQKey
+
"】"
);
/* 私钥 */
String
privateKey
=
sm2
.
getPrivateKeyBase64
();
System
.
out
.
println
(
"privateKey>>【"
+
privateKey
+
"】"
);
}
/**
* 公钥加密
* @param data
* @param publicKey
* @return
*/
public
static
String
encrypt
(
String
data
,
String
publicKey
)
{
SM2
sm2
=
SmUtil
.
sm2
(
null
,
publicKey
);
String
encryptStr
=
sm2
.
encryptBcd
(
data
,
KeyType
.
PublicKey
);
return
encryptStr
;
}
/**
* 公钥加密
* @param data
* @return
*/
public
static
String
encrypt
(
String
data
)
{
return
encrypt
(
data
,
publicKey
);
}
/**
* 私钥解密 公钥加密密文
* @param encryptStr
* @param privateKey
* @return
*/
public
static
String
decrypt
(
String
encryptStr
,
String
privateKey
)
{
if
(!
encryptStr
.
startsWith
(
"04"
))
{
encryptStr
=
"04"
.
concat
(
encryptStr
);
}
SM2
sm2
=
SmUtil
.
sm2
(
privateKey
,
null
);
String
decryptStr
=
StrUtil
.
utf8Str
(
sm2
.
decryptFromBcd
(
encryptStr
,
KeyType
.
PrivateKey
));
return
decryptStr
;
}
/**
* 私钥解密 公钥加密密文
* @param encryptStr
* @return
*/
public
static
String
decrypt
(
String
encryptStr
)
{
return
decrypt
(
encryptStr
,
privateKey
);
}
public
static
void
main
(
String
[]
args
)
{
getSm2KeyPair
();
}
}
build.gradle
View file @
a5d56b9f
...
@@ -3,8 +3,12 @@
...
@@ -3,8 +3,12 @@
buildscript
{
buildscript
{
repositories
{
repositories
{
google
()
google
()
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
'https://maven.aliyun.com/repository/public/'
}
maven
{
url
'https://maven.aliyun.com/repository/google/'
}
maven
{
url
'https://maven.aliyun.com/repository/jcenter/'
}
maven
{
url
'https://maven.aliyun.com/repository/central/'
}
jcenter
()
jcenter
()
}
}
dependencies
{
dependencies
{
classpath
'com.android.tools.build:gradle:3.5.2'
classpath
'com.android.tools.build:gradle:3.5.2'
...
@@ -17,8 +21,12 @@ buildscript {
...
@@ -17,8 +21,12 @@ buildscript {
allprojects
{
allprojects
{
repositories
{
repositories
{
google
()
google
()
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
'https://maven.aliyun.com/repository/public/'
}
maven
{
url
'https://maven.aliyun.com/repository/google/'
}
maven
{
url
'https://maven.aliyun.com/repository/jcenter/'
}
maven
{
url
'https://maven.aliyun.com/repository/central/'
}
jcenter
()
jcenter
()
}
}
}
}
...
...
gradle.properties
View file @
a5d56b9f
...
@@ -17,4 +17,6 @@ org.gradle.jvmargs=-Xmx1536m
...
@@ -17,4 +17,6 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX
=
true
android.useAndroidX
=
true
# Automatically convert third-party libraries to use AndroidX
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier
=
true
android.enableJetifier
=
true
# SM2
android.jetifier.blacklist
=
bcprov-jdk15on
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