Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IDPServer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josh Ji
IDPServer
Commits
f9fb0ed0
Commit
f9fb0ed0
authored
Dec 02, 2022
by
Josh Ji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change param's name in IdentityRequest DataModel
parent
290f6aca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
pom.xml
pom.xml
+4
-0
src/main/java/com/prlab/idpserver/controller/RESTfulApi.java
src/main/java/com/prlab/idpserver/controller/RESTfulApi.java
+5
-7
src/main/java/com/prlab/idpserver/model/IdentityRequest.java
src/main/java/com/prlab/idpserver/model/IdentityRequest.java
+2
-2
No files found.
pom.xml
View file @
f9fb0ed0
...
@@ -70,6 +70,10 @@
...
@@ -70,6 +70,10 @@
<artifactId>
spring-security-test
</artifactId>
<artifactId>
spring-security-test
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-jdbc
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/com/prlab/idpserver/controller/RESTfulApi.java
View file @
f9fb0ed0
package
com.prlab.idpserver.controller
;
package
com.prlab.idpserver.controller
;
import
com.prlab.idpserver.model.IdentityRequest
;
import
com.prlab.idpserver.model.IdentityRequest
;
import
org.apache.logging.log4j.util.Base64Util
;
import
org.apache.tomcat.util.buf.HexUtils
;
import
org.apache.tomcat.util.buf.HexUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.security.crypto.codec.Hex
;
import
org.springframework.util.Base64Utils
;
import
org.springframework.util.Base64Utils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.crypto.*
;
import
javax.crypto.*
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.xml.bind.annotation.adapters.HexBinaryAdapter
;
import
java.security.InvalidAlgorithmParameterException
;
import
java.security.InvalidAlgorithmParameterException
;
import
java.security.InvalidKeyException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
...
@@ -34,12 +31,13 @@ public class RESTfulApi {
...
@@ -34,12 +31,13 @@ public class RESTfulApi {
@PostMapping
(
"/idp/askIdentity"
)
@PostMapping
(
"/idp/askIdentity"
)
public
String
queryIdentity
(
@RequestBody
IdentityRequest
identityRequest
)
throws
NoSuchAlgorithmException
,
NoSuchPaddingException
,
InvalidKeyException
,
InvalidAlgorithmParameterException
,
IllegalBlockSizeException
,
BadPaddingException
{
public
String
queryIdentity
(
@RequestBody
IdentityRequest
identityRequest
)
throws
NoSuchAlgorithmException
,
NoSuchPaddingException
,
InvalidKeyException
,
InvalidAlgorithmParameterException
,
IllegalBlockSizeException
,
BadPaddingException
{
String
sql
=
"SELECT * FROM identities WHERE HMACbase64 = ?"
;
String
sql
=
"SELECT * FROM identities WHERE HMACbase64 LIKE ?;"
;
List
<
Map
<
String
,
Object
>>
list
=
jdbcTemplate
.
queryForList
(
sql
,
new
Object
[]{
identityRequest
.
p1
},
new
int
[]{
Types
.
VARCHAR
});
List
<
Map
<
String
,
Object
>>
list
=
jdbcTemplate
.
queryForList
(
sql
,
new
Object
[]{
identityRequest
.
HMAC
+
"%"
},
new
int
[]{
Types
.
VARCHAR
});
logger
.
debug
(
"identityRequest : {}, {}"
,
identityRequest
.
HMAC
,
identityRequest
.
Cx
);
Cipher
aesCipher
=
Cipher
.
getInstance
(
"AES/CBC/NoPadding"
);
Cipher
aesCipher
=
Cipher
.
getInstance
(
"AES/CBC/NoPadding"
);
IvParameterSpec
IV
=
new
IvParameterSpec
(
new
byte
[]{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
});
IvParameterSpec
IV
=
new
IvParameterSpec
(
new
byte
[]{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
});
logger
.
debug
(
"encryptedCx in base64 form : "
+
identityRequest
.
p2
);
logger
.
debug
(
"encryptedCx in base64 form : "
+
identityRequest
.
Cx
);
for
(
Map
<
String
,
Object
>
map
:
list
){
for
(
Map
<
String
,
Object
>
map
:
list
){
byte
[]
sharedSecret
=
(
byte
[])
map
.
get
(
"SharedSecret"
);
byte
[]
sharedSecret
=
(
byte
[])
map
.
get
(
"SharedSecret"
);
byte
[]
Cx
=
(
byte
[])
map
.
get
(
"Cx"
);
byte
[]
Cx
=
(
byte
[])
map
.
get
(
"Cx"
);
...
@@ -50,7 +48,7 @@ public class RESTfulApi {
...
@@ -50,7 +48,7 @@ public class RESTfulApi {
logger
.
debug
(
"Cx in db : "
+
HexUtils
.
toHexString
(
Cx
));
logger
.
debug
(
"Cx in db : "
+
HexUtils
.
toHexString
(
Cx
));
aesCipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
,
IV
);
aesCipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
,
IV
);
byte
[]
encryptedCx
=
Base64Utils
.
decodeFromString
(
identityRequest
.
p2
);
byte
[]
encryptedCx
=
Base64Utils
.
decodeFromString
(
identityRequest
.
Cx
);
logger
.
debug
(
"encryptedCx : "
+
HexUtils
.
toHexString
(
encryptedCx
));
logger
.
debug
(
"encryptedCx : "
+
HexUtils
.
toHexString
(
encryptedCx
));
byte
[]
decryptedCx
=
aesCipher
.
doFinal
(
encryptedCx
,
0
,
16
);
byte
[]
decryptedCx
=
aesCipher
.
doFinal
(
encryptedCx
,
0
,
16
);
logger
.
debug
(
"decryptedCx : "
+
HexUtils
.
toHexString
(
decryptedCx
));
logger
.
debug
(
"decryptedCx : "
+
HexUtils
.
toHexString
(
decryptedCx
));
...
...
src/main/java/com/prlab/idpserver/model/IdentityRequest.java
View file @
f9fb0ed0
package
com.prlab.idpserver.model
;
package
com.prlab.idpserver.model
;
public
class
IdentityRequest
{
public
class
IdentityRequest
{
public
String
p1
;
public
String
HMAC
;
public
String
p2
;
public
String
Cx
;
}
}
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