-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afd82df
commit 566badb
Showing
30 changed files
with
163 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ build | |
.idea | ||
gradle/* | ||
.gradle | ||
out | ||
out | ||
gradlew | ||
gradlew.bat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rootProject.name = 'crypto' | ||
|
2 changes: 1 addition & 1 deletion
2
...in/java/davidkhala/common/secure/AES.java → crypto/src/main/java/org/davidkhala/AES.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.davidkhala; | ||
|
||
import org.spongycastle.asn1.x500.X500Name; | ||
import org.spongycastle.operator.ContentSigner; | ||
import org.spongycastle.operator.OperatorCreationException; | ||
import org.spongycastle.operator.jcajce.JcaContentSignerBuilder; | ||
import org.spongycastle.pkcs.PKCS10CertificationRequest; | ||
import org.spongycastle.pkcs.PKCS10CertificationRequestBuilder; | ||
import org.spongycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder; | ||
|
||
import java.io.IOException; | ||
import java.security.KeyPair; | ||
import java.util.Base64; | ||
|
||
import javax.security.auth.x500.X500Principal; | ||
|
||
public class CSRTool { | ||
public static String wrapPublicReq(PKCS10CertificationRequest csr) throws IOException { | ||
byte[] CSRder; | ||
CSRder = csr.getEncoded(); | ||
|
||
String publicreq = Base64.getEncoder().encodeToString(CSRder); | ||
publicreq = | ||
"-----BEGIN NEW CERTIFICATE REQUEST-----\n" | ||
+ publicreq | ||
+ "-----END NEW CERTIFICATE REQUEST-----"; | ||
return publicreq; | ||
} | ||
|
||
public static PKCS10CertificationRequest generateCSR(KeyPair keyPair, X500Principal x500Principal) | ||
throws OperatorCreationException { | ||
PKCS10CertificationRequestBuilder p10Builder = | ||
new JcaPKCS10CertificationRequestBuilder(x500Principal, keyPair.getPublic()); | ||
|
||
JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256withRSA"); | ||
ContentSigner signer = csBuilder.build(keyPair.getPrivate()); | ||
|
||
return p10Builder.build(signer); | ||
} | ||
|
||
public static PKCS10CertificationRequest generateCSR(KeyPair keyPair, X500Name x500Name) | ||
throws OperatorCreationException { | ||
PKCS10CertificationRequestBuilder p10Builder = | ||
new JcaPKCS10CertificationRequestBuilder(x500Name, keyPair.getPublic()); | ||
|
||
JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256withRSA"); | ||
ContentSigner signer = csBuilder.build(keyPair.getPrivate()); | ||
|
||
return p10Builder.build(signer); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...va/davidkhala/common/secure/CertTool.java → ...rc/main/java/org/davidkhala/CertTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/java/davidkhala/common/secure/Hash.java → ...to/src/main/java/org/davidkhala/Hash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...avidkhala/common/secure/KeyStoreTool.java → ...ain/java/org/davidkhala/KeyStoreTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../davidkhala/common/secure/RSAKeyPair.java → .../main/java/org/davidkhala/RSAKeyPair.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...avidkhala/common/secure/X509CertTool.java → ...ain/java/org/davidkhala/X509CertTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
src/test/java/secure/X509CertTest.java → crypto/src/test/java/X509CertTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
plugins { | ||
id 'java' | ||
id 'maven-publish' | ||
id 'java-library' | ||
} | ||
group = 'org.davidkhala' | ||
version = '0.0.0' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// com.google.common.io | ||
implementation('com.google.guava:guava:latest.integration') | ||
|
||
testImplementation platform('org.junit:junit-bom:5.10.2') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
|
||
|
||
|
||
|
||
publishing { | ||
publications { | ||
github(MavenPublication) { | ||
from components.java | ||
} | ||
} | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = "https://maven.pkg.github.com/davidkhala/java-common" | ||
credentials { | ||
username = 'davidkhala' | ||
password = System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rootProject.name = 'light' | ||
|
2 changes: 1 addition & 1 deletion
2
...hala/common/AbstractPropertiesLoader.java → .../davidkhala/AbstractPropertiesLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package davidkhala.common; | ||
package org.davidkhala; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
2 changes: 1 addition & 1 deletion
2
src/main/java/davidkhala/common/CLI.java → light/src/main/java/org/davidkhala/CLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package davidkhala.common; | ||
package org.davidkhala; | ||
|
||
import java.io.IOException; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...n/java/davidkhala/common/CountryTool.java → ...main/java/org/davidkhala/CountryTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package davidkhala.common; | ||
package org.davidkhala; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
|
2 changes: 1 addition & 1 deletion
2
...main/java/davidkhala/common/FileTool.java → ...rc/main/java/org/davidkhala/FileTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package davidkhala.common; | ||
package org.davidkhala; | ||
|
||
|
||
import java.io.*; | ||
|
3 changes: 1 addition & 2 deletions
3
src/main/java/davidkhala/common/Format.java → .../src/main/java/org/davidkhala/Format.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...in/java/davidkhala/common/Reflection.java → .../main/java/org/davidkhala/Reflection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...main/java/davidkhala/common/Resource.java → ...rc/main/java/org/davidkhala/Resource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package davidkhala.common; | ||
package org.davidkhala; | ||
|
||
import com.google.common.io.Resources; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
src/main/java/davidkhala/common/Stream.java → .../src/main/java/org/davidkhala/Stream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package davidkhala.common; | ||
package org.davidkhala; | ||
|
||
import java.io.*; | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
src/test/java/CLITest.java → light/src/test/java/CLITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/test/java/CountryTest.java → light/src/test/java/CountryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/test/java/FileTest.java → light/src/test/java/FileTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/test/java/PropertiesLoaderTest.java → ...t/src/test/java/PropertiesLoaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import org.davidkhala.Reflection; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ReflectionTest { | ||
@Test | ||
public void selfLift() { | ||
Class<Reflection> clazz = Reflection.class; | ||
assert clazz.getName().equals("org.davidkhala.Reflection"); | ||
assert clazz.getPackageName().equals("org.davidkhala"); | ||
assert clazz.getSimpleName().equals("Reflection"); | ||
assert clazz.getCanonicalName().equals("org.davidkhala.Reflection"); | ||
assert clazz.getTypeName().equals("org.davidkhala.Reflection"); | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.