~tritone-team/tritone/eucalyptus

« back to all changes in this revision

Viewing changes to clc/modules/configuration/src/main/java/com/eucalyptus/config/ConfigurationUtil.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:
2
2
 
3
3
import java.io.File;
4
4
import java.io.FileWriter;
 
5
import java.io.IOException;
5
6
import java.lang.reflect.InvocationTargetException;
6
7
import java.security.KeyPair;
7
8
import java.security.cert.X509Certificate;
67
68
    String directory = SubDirectory.KEYS.toString( ) + File.separator + newComponent.getName( );
68
69
    File keyDir = new File( directory );
69
70
    Configuration.LOG.info( "creating keys in " + directory );
70
 
    if ( !keyDir.mkdir( ) ) { throw new EucalyptusCloudException( "Failed to create cluster key directory: " + keyDir.getAbsolutePath( ) ); }
 
71
    if ( !keyDir.mkdir( ) && !keyDir.exists( ) ) { throw new EucalyptusCloudException( "Failed to create cluster key directory: " + keyDir.getAbsolutePath( ) ); }
 
72
    FileWriter out = null;
71
73
    try {
72
74
      KeyTool keyTool = new KeyTool( );
73
75
      KeyPair clusterKp = keyTool.getKeyPair( );
83
85
      X509Certificate systemX509 = SystemCredentialProvider.getCredentialProvider( Component.eucalyptus ).getCertificate( );
84
86
      String hexSig = Hashes.getHexSignature( );
85
87
      keyTool.writePem( SubDirectory.KEYS.toString( ) + File.separator + "cloud-cert.pem", systemX509 );
86
 
      FileWriter out = new FileWriter( directory + File.separator + "vtunpass" );
 
88
      out = new FileWriter( directory + File.separator + "vtunpass" );
87
89
      out.write( hexSig );
88
90
      out.flush( );
89
91
      out.close( );
105
107
      }
106
108
    } catch ( Exception eee ) {
107
109
      throw new EucalyptusCloudException( eee );
 
110
    } finally {
 
111
        if(out != null)
 
112
                        try {
 
113
                                out.close();
 
114
                        } catch (IOException e) {
 
115
                                Configuration.LOG.error(e);
 
116
                        }
108
117
    }
109
118
  }
110
119