35
35
kp = SshKeyPair.NO_KEY;
38
return new VmKeyInfo( kp.getDisplayName(), kp.getPublicKey(), kp.getFingerPrint() );
39
return new VmKeyInfo( kp.getDisplayName(), kp.getPublicKey(), kp.getFingerPrint() );
41
43
public VmAllocationInfo verify( VmAllocationInfo vmAllocInfo ) throws EucalyptusCloudException {
76
78
public CreateKeyPairResponseType CreateKeyPair( CreateKeyPairType request ) throws EucalyptusCloudException {
77
79
CreateKeyPairResponseType reply = ( CreateKeyPairResponseType ) request.getReply( );
78
PrivateKey pk = KeyPairUtil.createUserKeyPair( request.getUserId( ), request.getKeyName( ) );
79
reply.setKeyFingerprint( Hashes.getFingerPrint( pk ) );
80
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
81
PEMWriter privOut = new PEMWriter( new OutputStreamWriter( byteOut ) );
83
privOut.writeObject( pk );
85
} catch ( IOException e ) {
87
throw new EucalyptusCloudException( e );
81
KeyPairUtil.getUserKeyPair( request.getUserId( ), request.getKeyName( ) );
82
} catch ( Exception e1 ) {
83
PrivateKey pk = KeyPairUtil.createUserKeyPair( request.getUserId( ), request.getKeyName( ) );
84
reply.setKeyFingerprint( Hashes.getFingerPrint( pk ) );
85
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
86
PEMWriter privOut = new PEMWriter( new OutputStreamWriter( byteOut ) );
88
privOut.writeObject( pk );
90
} catch ( IOException e ) {
92
throw new EucalyptusCloudException( e );
94
reply.setKeyName( request.getKeyName( ) );
95
reply.setKeyMaterial( byteOut.toString( ) );
89
reply.setKeyName( request.getKeyName( ) );
90
reply.setKeyMaterial( byteOut.toString( ) );
98
throw new EucalyptusCloudException( "Creation failed. Keypair already exists: " + request.getKeyName( ) );