@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getKeyFingerprint() == null) ? 0 : getKeyFingerprint().hashCode()); hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); return hashCode; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getKeyFingerprint() != null) sb.append("KeyFingerprint: ").append(getKeyFingerprint()).append(","); if (getKeyName() != null) sb.append("KeyName: ").append(getKeyName()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KeyPairInfo == false) return false; KeyPairInfo other = (KeyPairInfo) obj; if (other.getKeyFingerprint() == null ^ this.getKeyFingerprint() == null) return false; if (other.getKeyFingerprint() != null && other.getKeyFingerprint().equals(this.getKeyFingerprint()) == false) return false; if (other.getKeyName() == null ^ this.getKeyName() == null) return false; if (other.getKeyName() != null && other.getKeyName().equals(this.getKeyName()) == false) return false; return true; }
public static void main(String[] args) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DescribeKeyPairsResult response = ec2.describeKeyPairs(); for(KeyPairInfo key_pair : response.getKeyPairs()) { System.out.printf( "Found key pair with name %s " + "and fingerprint %s", key_pair.getKeyName(), key_pair.getKeyFingerprint()); } } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KeyPairInfo == false) return false; KeyPairInfo other = (KeyPairInfo)obj; if (other.getKeyName() == null ^ this.getKeyName() == null) return false; if (other.getKeyName() != null && other.getKeyName().equals(this.getKeyName()) == false) return false; if (other.getKeyFingerprint() == null ^ this.getKeyFingerprint() == null) return false; if (other.getKeyFingerprint() != null && other.getKeyFingerprint().equals(this.getKeyFingerprint()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); hashCode = prime * hashCode + ((getKeyFingerprint() == null) ? 0 : getKeyFingerprint().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getKeyName() != null) sb.append("KeyName: " + getKeyName() + ","); if (getKeyFingerprint() != null) sb.append("KeyFingerprint: " + getKeyFingerprint() ); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getKeyFingerprint() == null) ? 0 : getKeyFingerprint().hashCode()); hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); return hashCode; }
protected Optional<KeyPairInfo> getKeyPairInfo(String name, List<KeyPairInfo> list) { for (KeyPairInfo element : list) { logger.debug("fingerprint - {}, name - {}", element.getKeyFingerprint(), element.getKeyName()); if (name.equals(element.getKeyName())) { return Optional.of(element); } } return Optional.<KeyPairInfo> absent(); }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getKeyFingerprint() != null) sb.append("KeyFingerprint: ").append(getKeyFingerprint()).append(","); if (getKeyName() != null) sb.append("KeyName: ").append(getKeyName()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KeyPairInfo == false) return false; KeyPairInfo other = (KeyPairInfo) obj; if (other.getKeyFingerprint() == null ^ this.getKeyFingerprint() == null) return false; if (other.getKeyFingerprint() != null && other.getKeyFingerprint().equals(this.getKeyFingerprint()) == false) return false; if (other.getKeyName() == null ^ this.getKeyName() == null) return false; if (other.getKeyName() != null && other.getKeyName().equals(this.getKeyName()) == false) return false; return true; }
/** * Finds the {@link KeyPairInfo} that corresponds to this key in EC2. */ public com.amazonaws.services.ec2.model.KeyPair find(AmazonEC2 ec2) throws IOException, AmazonClientException { String fp = getFingerprint(); String pfp = getPublicFingerprint(); for (KeyPairInfo kp : ec2.describeKeyPairs().getKeyPairs()) { if (kp.getKeyFingerprint().equalsIgnoreCase(fp)) { com.amazonaws.services.ec2.model.KeyPair keyPair = new com.amazonaws.services.ec2.model.KeyPair(); keyPair.setKeyName(kp.getKeyName()); keyPair.setKeyFingerprint(fp); keyPair.setKeyMaterial(Secret.toString(privateKey)); return keyPair; } if (kp.getKeyFingerprint().equalsIgnoreCase(pfp)) { com.amazonaws.services.ec2.model.KeyPair keyPair = new com.amazonaws.services.ec2.model.KeyPair(); keyPair.setKeyName(kp.getKeyName()); keyPair.setKeyFingerprint(pfp); keyPair.setKeyMaterial(Secret.toString(privateKey)); return keyPair; } } return null; }
/** * Finds the {@link KeyPairInfo} that corresponds to this key in EC2. */ public com.amazonaws.services.ec2.model.KeyPair find(AmazonEC2 ec2) throws IOException, AmazonClientException { String fp = getFingerprint(); String pfp = getPublicFingerprint(); for(KeyPairInfo kp : ec2.describeKeyPairs().getKeyPairs()) { if(kp.getKeyFingerprint().equalsIgnoreCase(fp)) { com.amazonaws.services.ec2.model.KeyPair keyPair = new com.amazonaws.services.ec2.model.KeyPair(); keyPair.setKeyName(kp.getKeyName()); keyPair.setKeyFingerprint(fp); keyPair.setKeyMaterial(Secret.toString(privateKey)); return keyPair; } if(kp.getKeyFingerprint().equalsIgnoreCase(pfp)) { com.amazonaws.services.ec2.model.KeyPair keyPair = new com.amazonaws.services.ec2.model.KeyPair(); keyPair.setKeyName(kp.getKeyName()); keyPair.setKeyFingerprint(pfp); keyPair.setKeyMaterial(Secret.toString(privateKey)); return keyPair; } } return null; }