Examples of SshPrivateKey


Examples of com.adito.security.pki.SshPrivateKey

   
    if(!hasLoadedKey(username))
      throw new PrivateKeyNotInitializedException();
   
    try {
      SshPrivateKey pk = (SshPrivateKey) loadedPrivateKeys.get(username);
     
     
      StringTokenizer blocks = new StringTokenizer(text, "\n");
     
      String plainText = "";
     
     
      while(blocks.hasMoreTokens()) {
        Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
       
        cipher.init(Cipher.DECRYPT_MODE, pk.getPrivateKey());
       
        byte[] encrypted = Base64.decode(blocks.nextToken());
        byte[] ctext = cipher.doFinal(encrypted);
       
        plainText += new String(ctext);
View Full Code Here

Examples of com.adito.security.pki.SshPrivateKey

  protected SshPrivateKey getPrivateKey(String username, String passphrase) throws IOException, InvalidKeyException {
   
    if(loadedPrivateKeys.containsKey(username))
      return (SshPrivateKey) loadedPrivateKeys.get(username);
   
    SshPrivateKey pk = getPrivateKeyFromStore(username, passphrase);
   
    loadedPrivateKeys.put(username, pk);
   
    return pk;
 
View Full Code Here

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

            PublicKeyAuthenticationClient publicKeyAuth = new PublicKeyAuthenticationClient();

            publicKeyAuth.setUsername(username);

            SshPrivateKeyFile file = SshPrivateKeyFile.parse( key );
            SshPrivateKey privateKey = file.toPrivateKey( keyPassPhrase );
            publicKeyAuth.setKey( privateKey );

            // Authenticate
            int result = sshClient.authenticate( publicKeyAuth );
            if( result != AuthenticationProtocolState.COMPLETE )
View Full Code Here

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

            // Initialize the authentication data.
            PublicKeyAuthenticationClient publicKeyAuth = new PublicKeyAuthenticationClient();
            publicKeyAuth.setUsername("ec2-user");
            SshPrivateKeyFile file = SshPrivateKeyFile.parse(new File(PRIVATE_KEY_FILE_PATH));
            SshPrivateKey privateKey = file.toPrivateKey("");
            publicKeyAuth.setKey(privateKey);

            // Authenticate
            int result = sshClient.authenticate(publicKeyAuth);
            if(result== AuthenticationProtocolState.FAILED) {
View Full Code Here

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

                PublicKeyAuthenticationClient pk = new PublicKeyAuthenticationClient();
                pk.setUsername(user);

                SshPrivateKeyFile file = SshPrivateKeyFile.parse(new File(keyfile));
                SshPrivateKey key = file.toPrivateKey(pass);

                pk.setKey(key);
                result = ssh.authenticate(pk);
            }
View Full Code Here

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

        // Create an instance of the public key from the factory
        //SshKeyPair pair = SshKeyPairFactory.newInstance(keyType);
        // Get the configuration and get the relevant host key
        Map keys = config.getServerHostKeys();
        Iterator it = keys.entrySet().iterator();
        SshPrivateKey pk; //privateKeyFile = null;

        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();

            if (entry.getKey().equals(keyType)) {
View Full Code Here

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

            // Initialize the authentication data.
            PublicKeyAuthenticationClient publicKeyAuth = new PublicKeyAuthenticationClient();
            publicKeyAuth.setUsername(amazonSecurityContext.getUserName());
            SshPrivateKeyFile file = SshPrivateKeyFile.
                    parse(new File(System.getProperty("user.home") + "/.ssh/" + KEY_PAIR_NAME));
            SshPrivateKey privateKey = file.toPrivateKey("");
            publicKeyAuth.setKey(privateKey);

            // Authenticate
            int result = sshClient.authenticate(publicKeyAuth);
            if(result== AuthenticationProtocolState.FAILED) {
View Full Code Here

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

            // Initialize the authentication data.
            PublicKeyAuthenticationClient publicKeyAuth = new PublicKeyAuthenticationClient();
            publicKeyAuth.setUsername(amazonSecurityContext.getUserName());
            SshPrivateKeyFile file = SshPrivateKeyFile.
                    parse(new File(System.getProperty("user.home") + "/.ssh/" + KEY_PAIR_NAME));
            SshPrivateKey privateKey = file.toPrivateKey("");
            publicKeyAuth.setKey(privateKey);

            // Authenticate
            int result = sshClient.authenticate(publicKeyAuth);
            if(result== AuthenticationProtocolState.FAILED) {
View Full Code Here

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

            // Initialize the authentication data.
            PublicKeyAuthenticationClient publicKeyAuth = new PublicKeyAuthenticationClient();
            publicKeyAuth.setUsername(amazonSecurityContext.getUserName());
            SshPrivateKeyFile file = SshPrivateKeyFile.
                    parse(new File(System.getProperty("user.home") + "/.ssh/" + KEY_PAIR_NAME));
            SshPrivateKey privateKey = file.toPrivateKey("");
            publicKeyAuth.setKey(privateKey);

            // Authenticate
            int result = sshClient.authenticate(publicKeyAuth);
            if(result== AuthenticationProtocolState.FAILED) {
View Full Code Here

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

      if (file.isPassphraseProtected()) {
        System.out.print("Enter passphrase? ");
        passphrase = reader.readLine();
      }
      // Get the key
      SshPrivateKey key = file.toPrivateKey(passphrase);
      pk.setKey(key);
      // Try the authentication
      int result = ssh.authenticate(pk);
      // Evaluate the result
      if (result == AuthenticationProtocolState.COMPLETE) {
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.