Examples of InvalidSshKeyException


Examples of com.google.gerrit.common.errors.InvalidSshKeyException

  }

  @Override
  public AccountSshKey create(AccountSshKey.Id id, String encoded)
      throws InvalidSshKeyException {
    throw new InvalidSshKeyException();
  }
View Full Code Here

Examples of com.google.gerrit.common.errors.InvalidSshKeyException

      final AccountSshKey key =
          new AccountSshKey(id, SshUtil.toOpenSshPublicKey(encoded));
      SshUtil.parse(key);
      return key;
    } catch (NoSuchAlgorithmException e) {
      throw new InvalidSshKeyException();

    } catch (InvalidKeySpecException e) {
      throw new InvalidSshKeyException();

    } catch (NoSuchProviderException e) {
      log.error("Cannot parse SSH key", e);
      throw new InvalidSshKeyException();
    }
  }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(key);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidSshKeyException();
            }

            BigInteger p = bar.readBigInteger();
            BigInteger q = bar.readBigInteger();
            BigInteger g = bar.readBigInteger();
            BigInteger y = bar.readBigInteger();
            dsaKey = new DSAPublicKeySpec(y, p, q, g);

            KeyFactory kf = KeyFactory.getInstance("DSA");
            pubkey = (DSAPublicKey) kf.generatePublic(dsaKey);
        } catch (Exception e) {
            throw new InvalidSshKeyException();
        }
    }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(key);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidSshKeyException();
            }

            BigInteger p = bar.readBigInteger();
            BigInteger q = bar.readBigInteger();
            BigInteger g = bar.readBigInteger();
            BigInteger x = bar.readBigInteger();
            dsaKey = new DSAPrivateKeySpec(x, p, q, g);

            KeyFactory kf = KeyFactory.getInstance("DSA");
            prvkey = (DSAPrivateKey) kf.generatePrivate(dsaKey);
        } catch (Exception e) {
            throw new InvalidSshKeyException();
        }
    }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

            // Read the public key
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidSshKeyException();
            }

            BigInteger e = bar.readBigInteger();
            BigInteger n = bar.readBigInteger();

            // Read the private key
            BigInteger p = bar.readBigInteger();
            RSAPrivateKeySpec prvSpec = new RSAPrivateKeySpec(n, p);
            RSAPublicKeySpec pubSpec = new RSAPublicKeySpec(n, e);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            prvKey = (RSAPrivateKey) kf.generatePrivate(prvSpec);
            pubKey = (RSAPublicKey) kf.generatePublic(pubSpec);
        } catch (Exception e) {
            throw new InvalidSshKeyException();
        }
    }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

                baw.writeBigInteger(keyInfo.getModulus());
                baw.writeBigInteger(keyInfo.getPrivateExponent());

                return baw.toByteArray();
            } else {
                throw new InvalidSshKeyException("Unsupported type: " +
                    pem.getType());
            }
        } catch (GeneralSecurityException e) {
            //e.printStackTrace();
            throw new InvalidSshKeyException(
                "Can't read key due to cryptography problems: " + e);
        } catch (IOException e) {
            //e.printStackTrace();
            throw new InvalidSshKeyException(
                "Can't read key due to internal IO problems: " + e);
        }
    }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

                SimpleASNWriter asn = new SimpleASNWriter();
                RSAKeyInfo.writeRSAKeyInfo(asn, keyInfo);
                payload = asn.toByteArray();
                pem.setType(PEM.RSA_PRIVATE_KEY);
            } else {
                throw new InvalidSshKeyException(
                    "Unsupported J2SSH algorithm: " + algorithm);
            }

            pem.setPayload(payload);
            pem.encryptPayload(payload, passphrase);

            StringWriter w = new StringWriter();
            pem.write(w);

            return w.toString().getBytes("US-ASCII");
        } catch (GeneralSecurityException e) {
            //e.printStackTrace();
            throw new InvalidSshKeyException(
                "Can't read key due to cryptography problems: " + e);
        } catch (IOException e) {
            //e.printStackTrace();
            throw new InvalidSshKeyException(
                "Can't read key due to internal IO problems: " + e);
        }
    }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

            // Read the public key
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidSshKeyException();
            }

            BigInteger e = bar.readBigInteger();
            BigInteger n = bar.readBigInteger();

            // Read the private key
            BigInteger p = bar.readBigInteger();
            RSAPrivateKeySpec prvSpec = new RSAPrivateKeySpec(n, p);
            RSAPublicKeySpec pubSpec = new RSAPublicKeySpec(n, e);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            prvKey = (RSAPrivateKey) kf.generatePrivate(prvSpec);
            pubKey = (RSAPublicKey) kf.generatePublic(pubSpec);
        } catch (Exception e) {
            throw new InvalidSshKeyException();
        }
    }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(key);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidSshKeyException();
            }

            BigInteger p = bar.readBigInteger();
            BigInteger q = bar.readBigInteger();
            BigInteger g = bar.readBigInteger();
            BigInteger y = bar.readBigInteger();
            dsaKey = new DSAPublicKeySpec(y, p, q, g);

            KeyFactory kf = KeyFactory.getInstance("DSA");
            pubkey = (DSAPublicKey) kf.generatePublic(dsaKey);
        } catch (Exception e) {
            throw new InvalidSshKeyException();
        }
    }
View Full Code Here

Examples of com.sshtools.j2ssh.transport.publickey.InvalidSshKeyException

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(key);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidSshKeyException();
            }

            BigInteger p = bar.readBigInteger();
            BigInteger q = bar.readBigInteger();
            BigInteger g = bar.readBigInteger();
            BigInteger x = bar.readBigInteger();
            dsaKey = new DSAPrivateKeySpec(x, p, q, g);

            KeyFactory kf = KeyFactory.getInstance("DSA");
            prvkey = (DSAPrivateKey) kf.generatePrivate(dsaKey);
        } catch (Exception e) {
            throw new InvalidSshKeyException();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.