/** * Copyright (C) 2009-2015 Dell, Inc. * See annotations for authorship information * * ==================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ==================================================================== */ package org.dasein.cloud.identity; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.Serializable; /** * Represents an SSH keypair generated by the {@link ShellKeySupport}. Note that the {@link #privateKey} may be null * in some contexts. * @author George Reese (george.reese@imaginary.com) * @since 2012.02 * @version 2012.02 */ public class SSHKeypair implements Serializable { private String fingerprint; private String name; private byte[] privateKey; private String publicKey; private String providerKeypairId; private String providerOwnerId; private String providerRegionId; @SuppressWarnings("unused") public SSHKeypair() { } @Override @SuppressWarnings("unused") public boolean equals(@Nullable Object ob) { if( ob == null ) { return false; } if( ob == this ) { return true; } if( !getClass().getName().equals(ob.getClass().getName()) ) { return false; } SSHKeypair keys = (SSHKeypair)ob; //noinspection SimplifiableIfStatement if( (providerOwnerId == null && keys.providerOwnerId == null) || (providerOwnerId != null && providerOwnerId.equals(keys.providerOwnerId)) ) { return (providerRegionId.equals(keys.providerRegionId) && providerKeypairId.equals(keys.providerKeypairId)); } return false; } @SuppressWarnings("unused") public @Nullable String getFingerprint() { return fingerprint; } @SuppressWarnings("unused") public void setFingerprint(@Nonnull String fingerprint) { this.fingerprint = fingerprint; } @SuppressWarnings("unused") public @Nullable String getName() { return name; } @SuppressWarnings("unused") public void setName(@Nonnull String name) { this.name = name; } @SuppressWarnings("unused") public @Nullable byte[] getPrivateKey() { return privateKey; } @SuppressWarnings("unused") public void setPrivateKey(@Nullable byte[] privateKey) { this.privateKey = privateKey; } @SuppressWarnings("unused") public @Nullable String getProviderKeypairId() { return providerKeypairId; } @SuppressWarnings("unused") public void setProviderKeypairId(@Nonnull String providerKeypairId) { this.providerKeypairId = providerKeypairId; } @SuppressWarnings("unused") public @Nullable String getProviderOwnerId() { return providerOwnerId; } @SuppressWarnings("unused") public void setProviderOwnerId(@Nonnull String providerOwnerId) { this.providerOwnerId = providerOwnerId; } @SuppressWarnings("unused") public @Nullable String getProviderRegionId() { return providerRegionId; } @SuppressWarnings("unused") public void setProviderRegionId(@Nonnull String providerRegionId) { this.providerRegionId = providerRegionId; } @SuppressWarnings("unused") public @Nullable String getPublicKey() { return publicKey; } @SuppressWarnings("unused") public void setPublicKey(@Nullable String publicKey) { this.publicKey = publicKey; } @Override public @Nonnull String toString() { String f = getFingerprint(); return (f == null ? "--unknown fingerprint--" : f); } }