1 package org.openslx.imagemaster.db.models;
3 import java.math.BigInteger;
4 import java.security.NoSuchAlgorithmException;
5 import java.security.PublicKey;
6 import java.security.spec.InvalidKeySpecException;
8 import org.apache.logging.log4j.LogManager;
9 import org.apache.logging.log4j.Logger;
30 if ( publickey == null && publickeyString != null ) {
31 String parts[] = publickeyString.split(
" " );
32 BigInteger mod = null;
33 BigInteger exp = null;
34 for (
int i = 0; i < parts.length; ++i ) {
35 if ( parts[i].startsWith(
"mod:" ) ) {
37 mod =
new BigInteger( parts[i].substring( 4 ) );
39 if ( parts[i].startsWith(
"exp:" ) ) {
41 exp =
new BigInteger( parts[i].substring( 4 ) );
45 LOGGER.error(
"No modulus for building public key was found." );
49 LOGGER.error(
"No public exponent for building public key was found." );
53 publickey =
new AsymKeyHolder( null, exp, mod ).getPublicKey();
54 }
catch ( InvalidKeySpecException | NoSuchAlgorithmException e ) {
55 LOGGER.info(
"PubKey of " + this.name +
" is not valid.", e );
56 }
catch ( NumberFormatException e ) {
57 LOGGER.info(
"PubKey of " + this.name +
" is corrupted in database!", e );
PublicKey getPubkey()
Get the public key of this organization, if known and valid.
static final Logger LOGGER