bluecrystal.service.jwt.CredentialPKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bluecrystal.deps.service Show documentation
Show all versions of bluecrystal.deps.service Show documentation
API that should be used by applications
package bluecrystal.service.jwt;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import org.bouncycastle.util.encoders.Base64;
public class CredentialPKey implements Credential {
private PrivateKey privateKey;
private PublicKey publicKey;
public CredentialPKey(PrivateKey privateKey, PublicKey publicKey) {
super();
this.privateKey = privateKey;
this.publicKey = publicKey;
}
public CredentialPKey(String publicKey) throws InvalidKeySpecException, NoSuchAlgorithmException {
super();
byte[] pkBytes = Base64.decode(publicKey);
this.privateKey = null;
this.publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(pkBytes));
}
public CredentialPKey() {
super();
// TODO Auto-generated constructor stub
}
@Override
public AppAlgorithm getAlgorithn() {
return AppAlgorithm.RS256;
}
public PrivateKey getPrivateKey() {
return privateKey;
}
public PublicKey getPublicKey() {
return publicKey;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy