code: public static void validatePublicKey(String value, PublicKeyCrypto crypto) throws BadPublicKeyException {
          if (org.springframework.util.StringUtils.hasText(value)) {
              int open = value.indexOf("-----BEGIN PGP PUBLIC KEY BLOCK-----");
              int close = value.indexOf("-----END PGP PUBLIC KEY BLOCK-----");
              if (open < 0) {
                  throw new BadPublicKeyException("PublicKeyValidator.noBeginBlock");
              }
              if (close < 0) {
                  throw new BadPublicKeyException("PublicKeyValidator.noEndBlock");
              }
              if (open >= 0 && close >= 0 &&open >= close) {
                  throw new BadPublicKeyException("PublicKeyValidator.wrongBlockOrder");
              }
  
              if (!crypto.isPublicKeyValid(value)) {
                  throw new BadPublicKeyException("PublicKeyValidator.invalidKey");
              }
          }
      }
docs: Validates a PGP public key.
  
  @param value        value to validate
  @param crypto    crypto implementation to carry out additional checks
  @throws BadPublicKeyException thrown if validation fails; getMessage()
  contains error code