-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
10 changed files
with
181 additions
and
35 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
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/czertainly/ca/connector/ejbca/exception/CertificateRequestException.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.czertainly.ca.connector.ejbca.exception; | ||
|
||
public class CertificateRequestException extends RuntimeException { | ||
|
||
public CertificateRequestException(String message) { | ||
super(message); | ||
} | ||
|
||
public CertificateRequestException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/czertainly/ca/connector/ejbca/request/CertificateRequest.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.czertainly.ca.connector.ejbca.request; | ||
|
||
import com.czertainly.api.model.core.enums.CertificateRequestFormat; | ||
import org.bouncycastle.asn1.x500.X500Name; | ||
|
||
public interface CertificateRequest { | ||
|
||
/** | ||
* Get encoded request | ||
* | ||
* @return encoded request | ||
*/ | ||
byte[] getEncoded(); | ||
|
||
/** | ||
* Get subject of the request as X500Name | ||
* | ||
* @return subject | ||
*/ | ||
X500Name getSubject(); | ||
|
||
/** | ||
* Get format of the request | ||
* | ||
* @return format | ||
*/ | ||
CertificateRequestFormat getFormat(); | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/czertainly/ca/connector/ejbca/request/CrmfCertificateRequest.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.czertainly.ca.connector.ejbca.request; | ||
|
||
import com.czertainly.api.model.core.enums.CertificateRequestFormat; | ||
import com.czertainly.ca.connector.ejbca.exception.CertificateRequestException; | ||
import org.bouncycastle.asn1.x500.X500Name; | ||
import org.bouncycastle.cert.crmf.jcajce.JcaCertificateRequestMessage; | ||
|
||
public class CrmfCertificateRequest implements CertificateRequest { | ||
|
||
private final byte[] encoded; | ||
private final JcaCertificateRequestMessage certificateRequestMessage; | ||
|
||
public CrmfCertificateRequest(byte[] crmfRequest) throws CertificateRequestException { | ||
this.encoded = crmfRequest; | ||
this.certificateRequestMessage = new JcaCertificateRequestMessage(crmfRequest); | ||
} | ||
|
||
@Override | ||
public byte[] getEncoded() { | ||
return encoded; | ||
} | ||
|
||
@Override | ||
public X500Name getSubject() { | ||
return certificateRequestMessage.getCertTemplate().getSubject(); | ||
} | ||
|
||
@Override | ||
public CertificateRequestFormat getFormat() { | ||
return CertificateRequestFormat.CRMF; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/czertainly/ca/connector/ejbca/request/Pkcs10CertificateRequest.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.czertainly.ca.connector.ejbca.request; | ||
|
||
import com.czertainly.api.model.core.enums.CertificateRequestFormat; | ||
import com.czertainly.ca.connector.ejbca.exception.CertificateRequestException; | ||
import org.bouncycastle.asn1.x500.X500Name; | ||
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest; | ||
|
||
import java.io.IOException; | ||
|
||
public class Pkcs10CertificateRequest implements CertificateRequest { | ||
|
||
private final byte[] encoded; | ||
private final JcaPKCS10CertificationRequest pkcs10CertificationRequest; | ||
|
||
public Pkcs10CertificateRequest(byte[] pkcs10Request) { | ||
this.encoded = pkcs10Request; | ||
try { | ||
this.pkcs10CertificationRequest = new JcaPKCS10CertificationRequest(pkcs10Request); | ||
} catch (IOException e) { | ||
throw new CertificateRequestException("Cannot process PKCS#10 request", e); | ||
} | ||
} | ||
|
||
@Override | ||
public byte[] getEncoded() { | ||
return encoded; | ||
} | ||
|
||
@Override | ||
public X500Name getSubject() { | ||
return pkcs10CertificationRequest.getSubject(); | ||
} | ||
|
||
@Override | ||
public CertificateRequestFormat getFormat() { | ||
return CertificateRequestFormat.PKCS10; | ||
} | ||
|
||
} |
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
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