Skip to content

Commit

Permalink
Bump org.openidentityplatform.openicf 1.6.2 (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
vharseko authored Jun 26, 2024
1 parent 0c9ef7b commit 2442932
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
3 changes: 1 addition & 2 deletions openidm-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
<!-- Third party dependencies -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk16</artifactId>
<version>1.46</version>
<artifactId>bcmail-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
Expand Down
3 changes: 1 addition & 2 deletions openidm-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@
<!-- Third-party dependencies -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk16</artifactId>
<version>1.46</version>
<artifactId>bcmail-jdk18on</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
import org.bouncycastle.cert.X509v3CertificateBuilder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.openssl.PEMReader;
import org.bouncycastle.openssl.PEMWriter;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.bouncycastle.jce.PKCS10CertificationRequest;
import org.bouncycastle.util.io.pem.PemObject;
import org.forgerock.json.resource.InternalServerErrorException;
import org.forgerock.json.resource.ResourceException;
import org.joda.time.DateTime;
Expand Down Expand Up @@ -157,7 +159,21 @@ public static Pair<X509Certificate, PrivateKey> generateCertificate(String commo
* @throws Exception
*/
public static String getCertString(Object object) throws Exception {
try (StringWriter sw = new StringWriter(); PEMWriter pemWriter = new PEMWriter(sw)) {
if (object instanceof PKCS10CertificationRequest) {
PKCS10CertificationRequest pkcs10=(PKCS10CertificationRequest)object;
String type = "CERTIFICATE REQUEST";
byte[] encoding = pkcs10.getEncoded();

PemObject pemObject = new PemObject(type, encoding);

StringWriter str = new StringWriter();
JcaPEMWriter pemWriter = new JcaPEMWriter(str);
pemWriter.writeObject(pemObject);
pemWriter.close();
str.close();
return str.getBuffer().toString();
}
try (StringWriter sw = new StringWriter(); JcaPEMWriter pemWriter = new JcaPEMWriter(sw)) {
pemWriter.writeObject(object);
pemWriter.flush();
return sw.getBuffer().toString();
Expand All @@ -174,7 +190,7 @@ public static String getCertString(Object object) throws Exception {
@SuppressWarnings("unchecked")
public static <T> T fromPem(String pem) throws Exception {
StringReader sr = new StringReader(pem);
PEMReader pw = new PEMReader(sr);
PEMParser pw = new PEMParser(sr);
Object object = pw.readObject();
return (T) object;
}
Expand All @@ -188,7 +204,7 @@ public static <T> T fromPem(String pem) throws Exception {
*/
public static Certificate readCertificate(String certString) throws Exception {
StringReader sr = new StringReader(certString);
PEMReader pw = new PEMReader(sr);
PEMParser pw = new PEMParser(sr);
Object object = pw.readObject();
if (object instanceof X509Certificate) {
return (X509Certificate)object;
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,15 @@
<dependency>
<groupId>org.openidentityplatform</groupId>
<artifactId>openicf</artifactId>
<version>1.6.0</version>
<version>1.6.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk18on</artifactId>
<version>1.78.1</version>
</dependency>
<!-- Commons -->
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down

0 comments on commit 2442932

Please sign in to comment.