Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hg-smart
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
platform
hg-smart
Commits
7f07fd39
Commit
7f07fd39
authored
Oct 31, 2024
by
宋祥
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-sx' of
http://129.211.46.84:8800/platform/hg-smart
into dev
parents
5bc30e6f
38e770c4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
204 additions
and
0 deletions
+204
-0
ByteUtils.java
src/main/java/com/baosight/hggp/util/ByteUtils.java
+179
-0
applicationContext-security-trust-udp.xml
...pring/framework/applicationContext-security-trust-udp.xml
+25
-0
No files found.
src/main/java/com/baosight/hggp/util/ByteUtils.java
0 → 100644
View file @
7f07fd39
package
com
.
baosight
.
hggp
.
util
;
import
java.security.KeyFactory
;
import
java.security.MessageDigest
;
import
java.security.PrivateKey
;
import
java.security.Signature
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
/**
* @author songx
* @date 2024/10/31,15:15
*/
public
class
ByteUtils
{
private
static
final
String
DSA
=
"DSA"
;
private
static
SimpleDateFormat
CRED_TIME_FORMAT
=
new
SimpleDateFormat
(
"yyyyMMddHHmm"
);
private
static
String
CRED_SEPERATOR
=
":"
;
private
static
String
signatureAlg
=
"SHA1WithDSA"
;
private
static
String
SELF_PROJECTENAME
=
"A"
;
private
static
String
privateKeyStr
=
"3082014b0201003082012c06072a8648ce3804013082011f02818100fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c70215009760508f15230bccb292b982a2eb840bf0581cf502818100f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a041602145898ad70090def72e9d6a8ce864e688c366994a6"
;
private
static
String
publicKeyStr
=
"*****"
;
/**
* md5
*
* @param data String
* @return md5 md5
*/
public
static
final
String
MD5
(
String
data
)
{
try
{
MessageDigest
digest
=
MessageDigest
.
getInstance
(
"MD5"
);
digest
.
update
(
data
.
getBytes
(
"utf-8"
));
return
encodeHex
(
digest
.
digest
());
}
catch
(
Exception
e
)
{
throw
new
IllegalStateException
(
e
.
getMessage
());
}
}
/**
* bytesmd5
*
* @param bytes bytes
* @return the string
*/
public
static
final
String
encodeHex
(
byte
bytes
[])
{
StringBuffer
buf
=
new
StringBuffer
(
bytes
.
length
*
2
);
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
if
((
bytes
[
i
]
&
0xff
)
<
16
)
{
buf
.
append
(
"0"
);
}
buf
.
append
(
Long
.
toString
(
bytes
[
i
]
&
0xff
,
16
));
}
return
buf
.
toString
();
}
/**
* byte
*
* @param hex
* @return byte[] byte
*/
public
static
final
byte
[]
decodeHex
(
String
hex
)
{
char
chars
[]
=
hex
.
toCharArray
();
byte
bytes
[]
=
new
byte
[
chars
.
length
/
2
];
int
byteCount
=
0
;
for
(
int
i
=
0
;
i
<
chars
.
length
;
i
+=
2
)
{
int
newByte
=
0
;
newByte
|=
hexCharToByte
(
chars
[
i
]);
newByte
<<=
4
;
newByte
|=
hexCharToByte
(
chars
[
i
+
1
]);
bytes
[
byteCount
]
=
(
byte
)
newByte
;
byteCount
++;
}
return
bytes
;
}
/**
*
*/
private
static
final
byte
hexCharToByte
(
char
ch
)
{
switch
(
ch
)
{
case
48
:
// '0'
return
0
;
case
49
:
// '1'
return
1
;
case
50
:
// '2'
return
2
;
case
51
:
// '3'
return
3
;
case
52
:
// '4'
return
4
;
case
53
:
// '5'
return
5
;
case
54
:
// '6'
return
6
;
case
55
:
// '7'
return
7
;
case
56
:
// '8'
return
8
;
case
57
:
// '9'
return
9
;
case
97
:
// 'a'
return
10
;
case
98
:
// 'b'
return
11
;
case
99
:
// 'c'
return
12
;
case
100
:
// 'd'
return
13
;
case
101
:
// 'e'
return
14
;
case
102
:
// 'f'
return
15
;
case
58
:
// ':'
case
59
:
// ';'
case
60
:
// '<'
case
61
:
// '='
case
62
:
// '>'
case
63
:
// '?'
case
64
:
// '@'
case
65
:
// 'A'
case
66
:
// 'B'
case
67
:
// 'C'
case
68
:
// 'D'
case
69
:
// 'E'
case
70
:
// 'F'
case
71
:
// 'G'
case
72
:
// 'H'
case
73
:
// 'I'
case
74
:
// 'J'
case
75
:
// 'K'
case
76
:
// 'L'
case
77
:
// 'M'
case
78
:
// 'N'
case
79
:
// 'O'
case
80
:
// 'P'
case
81
:
// 'Q'
case
82
:
// 'R'
case
83
:
// 'S'
case
84
:
// 'T'
case
85
:
// 'U'
case
86
:
// 'V'
case
87
:
// 'W'
case
88
:
// 'X'
case
89
:
// 'Y'
case
90
:
// 'Z'
case
91
:
// '['
case
92
:
// '\\'
case
93
:
// ']'
case
94
:
// '^'
case
95
:
// '_'
case
96
:
// '`'
default
:
return
0
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
DSA
);
byte
pri
[]
=
ByteUtils
.
decodeHex
(
privateKeyStr
);
PKCS8EncodedKeySpec
privKeySpec
=
new
PKCS8EncodedKeySpec
(
pri
);
PrivateKey
priKey
=
keyFactory
.
generatePrivate
(
privKeySpec
);
Calendar
now
=
Calendar
.
getInstance
();
String
minuteStr
=
CRED_TIME_FORMAT
.
format
(
now
.
getTime
());
StringBuffer
str
=
new
StringBuffer
();
String
user
=
"YG5918"
;
str
.
append
(
minuteStr
).
append
(
CRED_SEPERATOR
).
append
(
user
).
append
(
CRED_SEPERATOR
).
append
(
"UDP"
).
append
(
CRED_SEPERATOR
).
append
(
"HGGP"
);
Signature
sig
=
Signature
.
getInstance
(
signatureAlg
);
sig
.
initSign
(
priKey
);
sig
.
update
(
str
.
toString
().
getBytes
(
"UTF8"
));
byte
[]
signature
=
sig
.
sign
();
String
signatureStr
=
ByteUtils
.
encodeHex
(
signature
);
str
.
append
(
CRED_SEPERATOR
).
append
(
signatureStr
);
System
.
out
.
println
(
str
);
}
}
src/main/resources/spring/framework/applicationContext-security-trust-udp.xml
0 → 100644
View file @
7f07fd39
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:sec=
"http://www.springframework.org/schema/security"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://www.springframework.org/schema/beans"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.2.xsd"
>
<bean
id=
"keyPairLocator"
class=
"com.baosight.xservices.xs.sso.SecretKeyPairLocator4Config"
>
<property
name=
"keyPairMapping"
>
<map>
<entry
key=
"UDP"
>
<bean
class=
"com.baosight.xservices.xs.sso.SecretKeyPair4DSA"
>
<property
name=
"private"
value=
"3082014b0201003082012c06072a8648ce3804013082011f02818100fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c70215009760508f15230bccb292b982a2eb840bf0581cf502818100f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a041602145898ad70090def72e9d6a8ce864e688c366994a6"
/>
<property
name=
"public"
value=
"308201b73082012c06072a8648ce3804013082011f02818100fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c70215009760508f15230bccb292b982a2eb840bf0581cf502818100f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a0381840002818009202eda89c00359a104d5ffbd043f515c737588bac7be945d89c995b9c50f43b08881f3b93592d31ec4e55a905c30e1f4fdb39a4241697a526ebedfd6fc5238d3fb0ac793af0183a4716182aaa8cb2b325f2f8d4d298f115a430866e0c99e5386a1309853e43d17fc2bdc39a4ba64c714f33c2e7049d22440c947479f9c3f6c"
/>
</bean>
</entry>
</map>
</property>
</bean>
</beans>
\ 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