Examples of SshPublicKey


Examples of com.openshift.client.SSHPublicKey

     
      // operation
      int newNumOfKeys = user.getSSHKeys().size();
      assertThat(user.getSSHKeys().size()).isEqualTo(originalNumOfKeys);
      String newKeyName = SSHKeyTestUtils.createRandomKeyName();
      user.addSSHKey(newKeyName, new SSHPublicKey(publicKeyPath));     
      newNumOfKeys = user.getSSHKeys().size();
     
      // verification
      assertThat(newNumOfKeys).isEqualTo(originalNumOfKeys + 1);
    } finally {
View Full Code Here

Examples of com.openshift.client.SSHPublicKey

  public static void addTestKeyToOpenShift(IUser user) throws OpenShiftException, FileNotFoundException, IOException, JSchException {
    assertThat(user).isNotNull();
    createSSHTestKeys();
    user.removeSSHKey(SSH_TEST_KEY_NAME);
    user.addSSHKey(SSH_TEST_KEY_NAME, new SSHPublicKey(SSH_TEST_PUBLICKEY));
  }
View Full Code Here

Examples of com.openshift.client.SSHPublicKey

  public void shouldLoadPublicKeyRsa() throws Exception {
    // pre-conditions
    String publicKeyPath = createRandomTempFile().getAbsolutePath();
    String privateKeyPath = createRandomTempFile().getAbsolutePath();
    SSHKeyPair.create(SSHKeyTestUtils.DEFAULT_PASSPHRASE, privateKeyPath, publicKeyPath);
    ISSHPublicKey sshKey = new SSHPublicKey(new File(publicKeyPath));
    String publicKey = sshKey.getPublicKey();
    assertNotNull(sshKey.getKeyType());
    String keyType = sshKey.getKeyType().getTypeId();
    assertNotNull(publicKey);
    assertThat(publicKey)
        // no identifier
        .doesNotContain(SSHKeyTestUtils.SSH_RSA)
        // no comment
View Full Code Here

Examples of com.openshift.client.SSHPublicKey

  public void shouldLoadPublicKeyDsa() throws Exception {
    // pre-conditions
    String publicKeyPath = createRandomTempFile().getAbsolutePath();
    String privateKeyPath = createRandomTempFile().getAbsolutePath();
    SSHKeyTestUtils.createDsaKeyPair(publicKeyPath, privateKeyPath);
    ISSHPublicKey sshKey = new SSHPublicKey(publicKeyPath);
    String publicKey = sshKey.getPublicKey();
    assertNotNull(sshKey.getKeyType());
    String keyType = sshKey.getKeyType().getTypeId();
    assertNotNull(publicKey);
    assertThat(publicKey)
        // no identifier
        .doesNotContain(SSHKeyTestUtils.SSH_DSA)
        // no comment
View Full Code Here

Examples of com.openshift.client.SSHPublicKey

        .mockGetKeys(Samples.GET_USER_KEYS_NONE)
        .mockCreateKey(Samples.PUT_BBCC_DSA_USER_KEYS_SOMEKEY);
    String publicKeyPath = createRandomTempFile().getAbsolutePath();
    String privateKeyPath = createRandomTempFile().getAbsolutePath();
    SSHKeyTestUtils.createDsaKeyPair(publicKeyPath, privateKeyPath);
    SSHPublicKey publicKey = new SSHPublicKey(publicKeyPath);
    assertThat(user.getSSHKeys()).isEmpty();
   
    String keyName = "somekey";
    // operation
    user.addSSHKey(keyName, publicKey);
View Full Code Here

Examples of com.openshift.client.SSHPublicKey

    // pre-conditions
    mockDirector.mockGetKeys(Samples.GET_USER_KEYS_1KEY);
    String publicKeyPath = createRandomTempFile().getAbsolutePath();
    String privateKeyPath = createRandomTempFile().getAbsolutePath();
    SSHKeyTestUtils.createDsaKeyPair(publicKeyPath, privateKeyPath);
    SSHPublicKey publicKey = new SSHPublicKey(publicKeyPath);

    // operation
    assertThat(user.getSSHKeys()).hasSize(1);
    String existingKeyName = user.getSSHKeys().get(0).getName();
    user.addSSHKey(existingKeyName, publicKey);
View Full Code Here

Examples of com.openshift.client.SSHPublicKey

        .mockGetKeys(Samples.GET_USER_KEYS_1KEY)
        .mockCreateKey(Samples.PUT_BBCC_DSA_USER_KEYS_SOMEKEY);
    String publicKeyPath = createRandomTempFile().getAbsolutePath();
    String privateKeyPath = createRandomTempFile().getAbsolutePath();
    SSHKeyTestUtils.createDsaKeyPair(publicKeyPath, privateKeyPath);
    SSHPublicKey publicKey = new SSHPublicKey(publicKeyPath);

    // operation
    assertThat(user.getSSHKeys()).onProperty("name").contains(keyName);
    user.addSSHKey(keyName, publicKey); // throws
  }
View Full Code Here

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

        try {
            baw.writeInt(keys.size());

            Map.Entry entry;
            Iterator it = keys.entrySet().iterator();
            SshPublicKey key;
            String description;

            while (it.hasNext()) {
                entry = (Map.Entry) it.next();
                key = (SshPublicKey) entry.getKey();
                description = (String) entry.getValue();
                baw.writeBinaryString(key.getEncoded());
                baw.writeString(description);
            }
        } catch (IOException ex) {
            throw new InvalidMessageException("Failed to write message data");
        }
View Full Code Here

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

    public void constructMessage(ByteArrayReader bar)
        throws java.io.IOException,
            com.sshtools.j2ssh.transport.InvalidMessageException {
        try {
            int num = (int) bar.readInt();
            SshPublicKey key;
            String description;
            byte[] buf;

            for (int i = 0; i < num; i++) {
                buf = bar.readBinaryString();
View Full Code Here

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

        // Iterate the agents keys, find an acceptable key and authenticate
        Map keys = agent.listKeys();
        Iterator it = keys.entrySet().iterator();
        boolean acceptable = false;
        SshPublicKey key = null;
        String description;
        Map.Entry entry;

        while (it.hasNext() && !acceptable) {
            entry = (Map.Entry) it.next();
            key = (SshPublicKey) entry.getKey();
            description = (String) entry.getValue();
            acceptable = acceptsKey(authentication, getUsername(),
                    serviceToStart, key);
            log.info("Agent authentication with key " + key.getFingerprint() +
                " [" + description + "] is " +
                (acceptable ? " acceptable" : " not acceptable"));

            if (acceptable) {
                ByteArrayWriter baw = new ByteArrayWriter();
                log.info("Generating data to sign");
                log.info("Preparing public key authentication request");

                // Now prepare and send the message
                baw.write(1);
                baw.writeString(key.getAlgorithmName());
                baw.writeBinaryString(key.getEncoded());

                // Create the signature data
                ByteArrayWriter data = new ByteArrayWriter();
                data.writeBinaryString(authentication.getSessionIdentifier());
                data.write(SshMsgUserAuthRequest.SSH_MSG_USERAUTH_REQUEST);
                data.writeString(getUsername());
                data.writeString(serviceToStart);
                data.writeString(getMethodName());
                data.write(1);
                data.writeString(key.getAlgorithmName());
                data.writeBinaryString(key.getEncoded());

                // Generate the signature
                baw.writeBinaryString(agent.hashAndSign(key, data.toByteArray()));

                SshMsgUserAuthRequest msg = new SshMsgUserAuthRequest(getUsername(),
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.