Get the public key.

@throws WardenBadResponseException
If the response status was not 200
777762
public function getPublicKey() {

    if (empty($this->wardenPublicKey)) {
      $result = $this->request('/public-key');
      $this->wardenPublicKey = base64_decode($result->getBody());
    }

    return $this->wardenPublicKey;
  }
682193
@Override
  public final PublicKey lazyGetPublicKeyAnotherAjetty() throws Exception {
    if (this.publicKeyAnotherAjetty == null && this.publicKeyDir != null
      && lazyGetOurPublicKey() != null) {
      File pkDir = new File(this.publicKeyDir);
      if (pkDir.exists()) {
        File[] lstFl = pkDir.listFiles();
        if (lstFl != null && lstFl.length == 1 && lstFl[0].isFile()) {
          FileInputStream fis = null;
          try {
            fis = new FileInputStream(lstFl[0]);
            ByteArrayOutputStream baus = new ByteArrayOutputStream();
            int b;
            while ((b = fis.read()) != -1) {
              baus.write(b);
            }
            byte[] encKey = baus.toByteArray();
            X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(encKey);
            KeyFactory keyFactory = KeyFactory
              .getInstance("RSA", this.cryptoProvider);
            PublicKey pkaj = keyFactory.generatePublic(pubKeySpec);
            if (!lazyGetOurPublicKey().equals(pkaj)) {
              this.publicKeyAnotherAjetty = pkaj;
            }
          } finally {
            if (fis != null) {
              try {
                fis.close();
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          }
        }
      }
    }
    return this.publicKeyAnotherAjetty;
  }
1342267
private PublicKey getRSAPublicKey(Provider provider) {

        try {
            RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec();
            KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider)
                    : KeyFactory.getInstance("RSA");

            return factory.generatePublic(publicKeySpec);
        } catch (GeneralSecurityException e) {
            throw new IllegalStateException(e);
        }
    }
909875
public char[] getID() {
        try {
            char[] keyChars = this.readKeyChars();
            NKey nkey =  NKey.fromSeed(keyChars);
            char[] pubKey = nkey.getPublicKey();
            nkey.clear();
            return pubKey;
        } catch (Exception exp) {
            throw new IllegalStateException("problem getting public key", exp);
        }
    }
1086360
private RSAPublicKey getKeyForUser(String userName) throws KeyNotFoundException {
    RSAPublicKey key = null;
    for (final KeyProvider keyProvider : keyProviders) {
      try {
        key = keyProvider.getKey(userName);
        break;
      } catch (KeyNotFoundException e) {
        // that's fine, try the next provider
      }
    }

    if (key == null) {
      throw new KeyNotFoundException();
    }

    return key;
  }
672935
function(publicKey, callback) {
        request.head(
            this.getResourceUrl({ path: '/keys/' + publicKey, user: null }),
            get404Handler(callback)
        );
        return this;
    }
193350
public function getPublicKey()
    {
        $cached = $this->getCache('publicKey');
        if (!empty($cached)) {
            return $cached;
        }

        $wellKnown = $this->getWellKnown();
        if (empty($wellKnown->jwks_uri)) {
            return null;
        }

        try {
            $response = $this->client->get($wellKnown->jwks_uri);
        } catch (RequestException $e) {
            $this->lastException = $e;
            return null;
        }

        $jwks = json_decode($response->getBody());
        if (empty($jwks->keys[0]->x5c[0])) {
            return null;
        }

        $X509 = new X509();
        if (!$X509->loadX509($jwks->keys[0]->x5c[0])) {
            return null;
        }

        $key = (string)$X509->getPublicKey();

        $this->setCache('publicKey', $key);

        return $key;
    }
172359
@SuppressWarnings("unchecked")
  public Key getKey(String name) {
    return ((Value<Key>) getValue(name)).get();
  }
1050122
public DERObject getPublicKey()
        throws IOException
    {
        ByteArrayInputStream    bIn = new ByteArrayInputStream(keyData.getBytes());
        ASN1InputStream         aIn = new ASN1InputStream(bIn);

        return aIn.readObject();
    }
837948
@Override
    public byte[] getKey() {
        StringBuilder sb = new StringBuilder(128);
        sb.append(clusterName).append(MetricUtils.AT).append(topologyId).append(MetricUtils.AT)
                .append(taskId).append(MetricUtils.AT);
        if (start != null) {
            sb.append(start.getTime());
        } else {
            sb.append(end.getTime());
        }
        return sb.toString().getBytes();
    }
1271587
private KeyPair loadKeyPair() throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
        // Read Private Key
        final File filePrivateKey = getKeyPath(KeyType.PRIVATE);

        // Read Public Key
        final File filePublicKey = getKeyPath(KeyType.PUBLIC);

        byte[] encodedPrivateKey;
        byte[] encodedPublicKey;

        try (InputStream pvtfis = Files.newInputStream(filePrivateKey.toPath());
             InputStream pubfis = Files.newInputStream(filePublicKey.toPath())) {

            encodedPrivateKey = new byte[(int) filePrivateKey.length()];
            pvtfis.read(encodedPrivateKey);

            encodedPublicKey = new byte[(int) filePublicKey.length()];
            pubfis.read(encodedPublicKey);
        }

        // Generate KeyPair
        final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        final X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(encodedPublicKey);
        final PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);
        final PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedPrivateKey);
        final PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);

        return this.keyPair = new KeyPair(publicKey, privateKey);
    }
17792
public static String getPublicKey(Map<String, Object> keyMap) throws Exception {
        Key key = (Key) keyMap.get(PUBLIC_KEY);
        return String.valueOf(Base64Utils.encode(key.getEncoded()));
    }
152878
static PublicKey
toPublicKey(KEYBase r) throws DNSSECException {
	int alg = r.getAlgorithm();
	try {
		switch (alg) {
		case Algorithm.RSAMD5:
		case Algorithm.RSASHA1:
		case Algorithm.RSA_NSEC3_SHA1:
		case Algorithm.RSASHA256:
		case Algorithm.RSASHA512:
			return toRSAPublicKey(r);
		case Algorithm.DSA:
		case Algorithm.DSA_NSEC3_SHA1:
			return toDSAPublicKey(r);
		case Algorithm.ECC_GOST:
			return toECGOSTPublicKey(r, GOST);
		case Algorithm.ECDSAP256SHA256:
			return toECDSAPublicKey(r, ECDSA_P256);
		case Algorithm.ECDSAP384SHA384:
			return toECDSAPublicKey(r, ECDSA_P384);
		default:
			throw new UnsupportedAlgorithmException(alg);
		}
	}
	catch (IOException e) {
		throw new MalformedKeyException(r);
	}
	catch (GeneralSecurityException e) {
		throw new DNSSECException(e.toString());
	}
}
690734
public static PublicKey readPublicKey(InputStream pemStream) {
		final Certificate certificate = KeyUtil.readX509Certificate(pemStream);
		if(null == certificate) {
			return null;
		}
		return certificate.getPublicKey();
	}
442092
public function getRsaPublicKey()
    {
        if ($this->rsaPublicKey) {
            return $this->rsaPublicKey;
        }

        if (!file_exists($this->rsaPublicKeyFile)) {
            throw new CredentialsException('Could not read the public key file.');
        }

        $this->rsaPublicKey = openssl_get_publickey(file_get_contents($this->rsaPublicKeyFile));

        if (!$this->rsaPublicKey) {
            throw new CredentialsException('Cannot access public key for signing');
        }

        return $this->rsaPublicKey;
    }
21170
function(publicKey, aclRuleId, callback) {
        request.get(
            this.getResourceUrl({
                path: '/keys/' + publicKey + '/access/' + aclRuleId,
                user: null
            }),
            function onAccessControlRulesResponse(err, res, body) {
                callback(err, body, res);
            }
        );
        return this;
    }
828387
@Override
    public HashMap<String, PublicKey> getPublicKeys() throws MpJwtProcessingException {
        String methodName = "getPublicKeys";
        if (tc.isDebugEnabled()) {
            Tr.entry(tc, methodName);
        }
        if (this.jsseHelper == null) {
            init();
        }
        // TODO due to dynamic changes on keyStore, we have to load the public keys every time.
        HashMap<String, PublicKey> publicKeys = new HashMap<String, PublicKey>();
        if (this.sslTrustStoreName == null) {
            if (tc.isDebugEnabled()) {
                Tr.exit(tc, methodName, publicKeys);
            }
            return publicKeys;
        }
        try {
            publicKeys = getPublicKeysFromKeystore();
        } catch (Exception e) {
            String msg = Tr.formatMessage(tc, "FAILED_TO_LOAD_PUBLIC_KEYS", new Object[] { sslTrustStoreName, e.getLocalizedMessage() });
            Tr.error(tc, msg);
            throw new MpJwtProcessingException(msg, e);
        }

        if (tc.isDebugEnabled()) {
            Tr.exit(tc, methodName, publicKeys);
        }
        return publicKeys;
    }