Skip to content

Commit b4d553d

Browse files
author
soh boon keong
committed
backup before clean, verifysupportedkeyfiletype
1 parent 7c62589 commit b4d553d

File tree

18 files changed

+1973
-46
lines changed

18 files changed

+1973
-46
lines changed

.vscode/settings.json

Lines changed: 0 additions & 2 deletions
This file was deleted.

1:

Whitespace-only changes.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
### V2.0-SNAPSHOT
4+
5+
- Library to use authParam
6+
- Usage for APEX 2
7+
38
### V1.3.5-SNAPSHOT
49

510
- Fixed vulnerability CVE-2020-25649, CVE-2020-15522, CVE-2020-9488 and CVE-2019-17571

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ gradle test jacocoTestReport
124124
```
125125

126126
The compiled _jar_ file will be located in the **build/libs** folder
127-
+ java-apex-api-security-1.0-SNAPSHOT.jar
127+
+ java-apex-api-security-2.0-SNAPSHOT.jar
128128

129129
Import this jar into your java classpath to use the utility class
130130

@@ -139,7 +139,7 @@ repositories {
139139
mavenLocal()
140140
}
141141
dependencies {
142-
compile group: 'com.api.util', name: 'ApiSecurity', version: '1.3.5-SNAPSHOT'
142+
compile group: 'com.api.util', name: 'ApiSecurity', version: '2.0-SNAPSHOT'
143143
}
144144
145145
```

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
id 'com.github.kt3k.coveralls' version '2.6.3'
55
}
66

7-
version '1.3.5-SNAPSHOT'
7+
version '2.0.0-SNAPSHOT'
88

99
tasks.withType(JavaCompile) {
1010
options.encoding = "UTF-8"

expected

Whitespace-only changes.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.api.util</groupId>
44
<artifactId>ApiSecurity</artifactId>
5-
<version>1.3.5-SNAPSHOT</version>
5+
<version>2.0.0-SNAPSHOT</version>
66
<build>
77
<plugins>
88
<plugin>

src/main/java/com/api/util/ApiSecurity/ApiList.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.api.util.ApiSecurity;
22
import java.util.AbstractMap.SimpleEntry;
33
import java.util.ArrayList;
4-
import java.util.Arrays;
5-
import java.util.Collection;
64
import java.util.List;
75
import java.util.Map.Entry;
86
import java.util.stream.Collectors;
@@ -28,14 +26,7 @@ public String toString(Boolean isBaseString) {
2826
Boolean quote = false;
2927
return this.toString(delimiter, sort, quote, isBaseString);
3028
}
31-
32-
// public String toString(Boolean isBaseString, Boolean sort) {
33-
// String delimiter = "&";
34-
// Boolean quote = false;
35-
//
36-
// return this.toString(delimiter, sort, quote, isBaseString);
37-
// }
38-
29+
3930
public String toString(String delimiter, Boolean sort, Boolean quote, Boolean isBaseString)
4031
{
4132
List<String> list = new ArrayList<String>();

src/main/java/com/api/util/ApiSecurity/ApiSigning.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ public static PrivateKey getPrivateKey(String keystoreFileName, String password,
276276
//For JKS file
277277
privateKey = getPrivateKeyFromKeyStore(keystoreFileName, password, alias);
278278
}
279-
280279
return privateKey;
280+
281281
}
282282

283283
public static PrivateKey getPrivateKey(String keystoreFileName, String password) throws ApiUtilException {
@@ -419,10 +419,11 @@ public static PublicKey getPublicKeyFromX509Certificate(String publicCertificate
419419
* @return Public Key
420420
* @throws IOException
421421
* @throws GeneralSecurityException
422+
* @throws ApiUtilException
422423
*/
423-
public static PublicKey getPublicKeyPEM(String publicCertificateFileName) throws IOException, GeneralSecurityException {
424+
public static PublicKey getPublicKeyPEM(String publicCertificateFileName) throws IOException, GeneralSecurityException, ApiUtilException {
424425
//log.debug("Enter :: getPublicKeyFromPubKey :: publicCertificateFileName : {} ", publicCertificateFileName);
425-
426+
System.out.println("in publicKEYPEM error " + publicCertificateFileName);
426427

427428
log.debug("Enter :: getPublicKeyPEM :: publicCertificateFileName : {} ", publicCertificateFileName);
428429
PublicKey key = null;
@@ -445,8 +446,9 @@ public static PublicKey getPublicKeyPEM(String publicCertificateFileName) throws
445446
}
446447

447448
}catch(Exception e){
449+
System.out.println("in publicKEYPEM error " + e.toString());
448450
log.error(e.getMessage(),e);
449-
throw e;
451+
throw new ApiUtilException(e.getMessage(), e);
450452
}finally{
451453
if(null!=pemParser){
452454
pemParser.close();
@@ -1143,9 +1145,12 @@ public static PrivateKey getPrivateKeyPEM(String privateKeyFileName, String pass
11431145
key = converter.getPrivateKey(privateKeyInfo);
11441146
System.out.println(" what is this KEY " + key.toString());
11451147

1148+
}else {
1149+
throw new ApiUtilException("Error while getting Private Key from PEM");
11461150
}
11471151

11481152
}catch(Exception e){
1153+
System.out.println("I am in error fpr getPrivateKeyPEM " + e.getMessage());
11491154
// throw e;
11501155
throw new ApiUtilException(e.getMessage(), e);
11511156
}finally{
@@ -1160,7 +1165,7 @@ public static PrivateKey getPrivateKeyPEM(String privateKeyFileName, String pass
11601165
}
11611166
}
11621167
log.debug("Exit :: getPrivateKeyPEM");
1163-
1168+
System.out.println(" what is this KEYPEM " + key.toString());
11641169
return key;
11651170

11661171
}

src/test/java/com/api/util/ApiSecurity/AuthorizationTokenTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void Test_L2_Not_Supported_Cert_Test() throws ApiUtilException
161161
// , IOException, GeneralSecurityException
162162
{
163163
String fileName = getLocalPath("certificates/ssc.alpha.example.com.pem");
164-
String expectedMessage = "unable to read encrypted data: javax.crypto.BadPaddingException: pad block corrupted";
164+
String expectedMessage = "unable to read encrypted data: Error finalising cipher";
165165
//String fileName = getLocalPath("certificates/team20.pem");
166166
//String expectedMessage = "org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo cannot be cast to org.bouncycastle.openssl.PEMKeyPair";
167167

0 commit comments

Comments
 (0)