~tritone-team/tritone/eucalyptus

« back to all changes in this revision

Viewing changes to clc/modules/www/src/main/java/edu/ucsb/eucalyptus/admin/server/X509Download.java

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-12-01 21:09:28 UTC
  • mto: This revision was merged to the branch mainline in revision 75.
  • Revision ID: james.westby@ubuntu.com-20091201210928-o2dvg0ubljhb0ft6
Tags: upstream-1.6.1~bzr1083
ImportĀ upstreamĀ versionĀ 1.6.1~bzr1083

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
import java.io.IOException;
90
90
import java.security.GeneralSecurityException;
91
91
import java.security.KeyPair;
 
92
import java.security.KeyStore;
92
93
import java.security.cert.X509Certificate;
93
94
import java.util.ArrayList;
94
95
import java.util.Calendar;
183
184
 
184
185
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream( );
185
186
    ZipOutputStream zipOut = new ZipOutputStream( byteOut );
186
 
    String baseName = EucalyptusProperties.NAME_SHORT + "-" + userName + "-" + Hashes.getFingerPrint( keyPair.getPublic( ) ).replaceAll( ":", "" ).toLowerCase( ).substring( 0, 8 );
 
187
    String fingerPrint = Hashes.getFingerPrint( keyPair.getPublic( ) );    
 
188
    if(fingerPrint != null) {
 
189
        String baseName = EucalyptusProperties.NAME_SHORT + "-" + userName + "-" + fingerPrint.replaceAll( ":", "" ).toLowerCase( ).substring( 0, 8 );
187
190
 
188
191
    zipOut.setComment( "To setup the environment run: source /path/to/eucarc" );
189
192
    StringBuffer sb = new StringBuffer( );
198
201
    sb.append( "\nexport EC2_URL=" + EucalyptusProperties.getCloudUrl( ) );
199
202
    sb.append( "\nexport EC2_PRIVATE_KEY=${EUCA_KEY_DIR}/" + baseName + "-pk.pem" );
200
203
    sb.append( "\nexport EC2_CERT=${EUCA_KEY_DIR}/" + baseName + "-cert.pem" );
 
204
    sb.append( "\nexport EC2_JVM_ARGS=-Djavax.net.ssl.trustStore=${EUCA_KEY_DIR}/jssecacerts" );
201
205
    sb.append( "\nexport EUCALYPTUS_CERT=${EUCA_KEY_DIR}/cloud-cert.pem" );
202
206
    sb.append( "\nexport EC2_ACCESS_KEY='" + userAccessKey + "'" );
203
207
    sb.append( "\nexport EC2_SECRET_KEY='" + userSecretKey + "'" );
214
218
    zipOut.write( Hashes.getPemBytes( cloudCert ) );
215
219
    zipOut.closeEntry( );
216
220
 
 
221
    zipOut.putNextEntry( new ZipEntry( "jssecacerts" ) );
 
222
    KeyStore tempKs = KeyStore.getInstance("jks");
 
223
    tempKs.load( null );
 
224
    tempKs.setCertificateEntry( "eucalyptus", cloudCert );
 
225
    ByteArrayOutputStream bos = new ByteArrayOutputStream( );
 
226
    tempKs.store( bos, "changeit".toCharArray( ) );
 
227
    zipOut.write( bos.toByteArray( ) );
 
228
    zipOut.closeEntry( );
 
229
    
217
230
    /** write the private key to the zip stream **/
218
231
    zipOut.putNextEntry( new ZipEntry( baseName + "-pk.pem" ) );
219
232
    zipOut.write( Hashes.getPemBytes( keyPair.getPrivate( ) ) );
223
236
    zipOut.putNextEntry( new ZipEntry( baseName + "-cert.pem" ) );
224
237
    zipOut.write( Hashes.getPemBytes( x509 ) );
225
238
    zipOut.closeEntry( );
226
 
 
 
239
    }
227
240
    /** close the zip output stream and return the bytes **/
228
241
    zipOut.close( );
229
242
    return byteOut.toByteArray( );