Skip to content

Commit

Permalink
migrate to monorepos
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkhala committed May 19, 2024
1 parent afd82df commit 566badb
Show file tree
Hide file tree
Showing 30 changed files with 163 additions and 143 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ build
.idea
gradle/*
.gradle
out
out
gradlew
gradlew.bat
32 changes: 18 additions & 14 deletions build.gradle → crypto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ plugins {
id 'maven-publish'
id 'java-library'
}

group = 'org.davidkhala'
version = '0.0.0'

repositories {
mavenCentral()
}

dependencies {
// org.spongycastle
implementation('com.madgag.spongycastle:pkix:latest.integration')

testImplementation platform('org.junit:junit-bom:5.10.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
}

test {
useJUnitPlatform()
}



publishing {
publications {
github(MavenPublication) {
group 'davidkhala'
artifactId 'common'
version "0.0.1"
from components.java
}
}
Expand All @@ -27,14 +42,3 @@ publishing {
}
}
}

dependencies {
// com.google.common.io
implementation('com.google.guava:guava:latest.integration')
// org.spongycastle
implementation('com.madgag.spongycastle:pkix:latest.integration')
// test
testImplementation('junit:junit:latest.integration')

}

2 changes: 2 additions & 0 deletions crypto/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = 'crypto'

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common.secure;
package org.davidkhala;

import java.nio.charset.Charset;
import java.security.InvalidKeyException;
Expand Down
51 changes: 51 additions & 0 deletions crypto/src/main/java/org/davidkhala/CSRTool.java
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common.secure;
package org.davidkhala;

import java.io.*;
import java.security.NoSuchProviderException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common.secure;
package org.davidkhala;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common.secure;
package org.davidkhala;

import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common.secure;
package org.davidkhala;

import java.security.*;
import java.security.interfaces.RSAPrivateCrtKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package davidkhala.common.secure;
package org.davidkhala;

import org.spongycastle.asn1.x500.X500Name;
import org.spongycastle.operator.OperatorCreationException;
import org.spongycastle.pkcs.PKCS10CertificationRequest;

import java.io.IOException;
import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package secure;

import davidkhala.common.secure.X509CertTool;
import org.davidkhala.X509CertTool;
import javax.security.auth.x500.X500Principal;
import org.junit.Test;

import org.junit.jupiter.api.Test;
import org.spongycastle.asn1.x500.X500Name;

public class X509CertTest {
Expand Down
46 changes: 46 additions & 0 deletions light/build.gradle
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")
}
}
}
}

2 changes: 2 additions & 0 deletions light/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = 'light'

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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common;
package org.davidkhala;

import java.io.IOException;

Expand Down
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common;
package org.davidkhala;


import java.io.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package davidkhala.common;
package org.davidkhala;

import com.google.common.io.BaseEncoding;

import java.text.ParseException;
import java.text.SimpleDateFormat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common;
package org.davidkhala;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
Expand Down
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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package davidkhala.common;
package org.davidkhala;

import java.io.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import davidkhala.common.CLI;
import org.junit.Test;
import org.davidkhala.CLI;
import org.junit.jupiter.api.Test;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import davidkhala.common.CountryTool;
import org.junit.Test;
import org.davidkhala.CountryTool;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import davidkhala.common.FileTool;
import davidkhala.common.Resource;
import org.junit.Test;
import org.davidkhala.FileTool;
import org.davidkhala.Resource;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import davidkhala.common.AbstractPropertiesLoader;
import davidkhala.common.Stream;
import org.junit.Test;
import org.davidkhala.AbstractPropertiesLoader;
import org.davidkhala.Stream;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
Expand Down
14 changes: 14 additions & 0 deletions light/src/test/java/ReflectionTest.java
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.
48 changes: 0 additions & 48 deletions src/main/java/davidkhala/common/secure/CSRTool.java

This file was deleted.

Loading

0 comments on commit 566badb

Please sign in to comment.