Skip to content

Commit

Permalink
fix: jans-auth-server: extending crypto support, sub pr4; fixes; #142/#…
Browse files Browse the repository at this point in the history
  • Loading branch information
smansoft committed Jan 25, 2022
1 parent 4d7f574 commit 2742575
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,24 @@ public Certificate(SignatureAlgorithm signatureAlgorithm, X509Certificate x509Ce
* @return Public Key from X509 Certificate.
*/
public PublicKey getPublicKey() {
if(x509Certificate == null) {
return null;
}
PublicKey publicKey = null;

if (x509Certificate != null && x509Certificate.getPublicKey() instanceof BCRSAPublicKey) {
if (x509Certificate.getPublicKey() instanceof BCRSAPublicKey) {
BCRSAPublicKey jcersaPublicKey = (BCRSAPublicKey) x509Certificate.getPublicKey();

publicKey = new RSAPublicKey(jcersaPublicKey.getModulus(), jcersaPublicKey.getPublicExponent());
} else if (x509Certificate != null && x509Certificate.getPublicKey() instanceof BCECPublicKey) {
} else if (x509Certificate.getPublicKey() instanceof BCECPublicKey) {
BCECPublicKey jceecPublicKey = (BCECPublicKey) x509Certificate.getPublicKey();

publicKey = new ECDSAPublicKey(signatureAlgorithm, jceecPublicKey.getQ().getXCoord().toBigInteger(),
jceecPublicKey.getQ().getYCoord().toBigInteger());
} else if (x509Certificate != null && x509Certificate.getPublicKey() instanceof BCEdDSAPublicKey) {
} else if (x509Certificate.getPublicKey() instanceof BCEdDSAPublicKey) {
BCEdDSAPublicKey jceedPublicKey = (BCEdDSAPublicKey) x509Certificate.getPublicKey();

publicKey = new EDDSAPublicKey(signatureAlgorithm, jceedPublicKey.getEncoded());
}

return publicKey;
}

Expand Down

0 comments on commit 2742575

Please sign in to comment.