~ubuntu-branches/ubuntu/maverick/eucalyptus/maverick

« back to all changes in this revision

Viewing changes to clc/modules/authentication/src/main/java/com/eucalyptus/auth/SystemCredentialProvider.java

  • Committer: Bazaar Package Importer
  • Author(s): Dave Walker (Daviey)
  • Date: 2010-07-21 17:27:10 UTC
  • mfrom: (1.1.38 upstream)
  • Revision ID: james.westby@ubuntu.com-20100721172710-7xv07dmdqgivc3t9
Tags: 2.0~bzr1211-0ubuntu1
* New major upstream version merge, 2.0 (r1211).
* debian/patches/:
  - 01-wsdl-stubs.patch, debian/wsdl.md5sums: wsdl stubs updated.
  - 02-Makefile.patch: Updated to reflect new code layout.
  - 07-local_support_euca_conf-in.patch: Updated to reflect new code layout.
  - 08-ubuntu-default-networking.patch: Refreshed.
  - 09-small-128-192MB.patch: Updated to point to new location.
  - 10-disable-iscsi.patch: Refreshed.
  - 11-state-cleanup-memleakfix.patch: Removed, fixed upstream.
  - 15-fix-default-ramdisk.patch: Updated to point to new location.
  - 16-kvm_libvirt_xml_default_use_kvm.patch: Updated to reflect changes.
  - 17-fix_walrus_OOM_errors.patch: Removed, fixed upstream.
  - 18-priv_security.patch: Updated to reflect upstream changes.
  - 20-brute-force-webui.patch: Updated to reflect upstream changes. 
  - 21-eucalyptus-1.7-with-gwt-1.6.4.patch: New patch, allows 
    eucalyptus-1.7 to be built against gwt 1.6.4. Based on patch courtesy 
    of Dmitrii Zagorodnov, upstream. (LP: #597330)
* debian/eucalyptus-java-common.links: 
  - Changed symlink for groovy, point to groovy.all.jar, making compatiable 
    with groovy versions >1.7. (LP: #595421)
  - Added ant.jar & jetty-rewrite-handler.jar as they are now required.
* debian/control
  - & debian/build-jars: Added libjavassist-java and libjetty-extra-java as 
    build dependencies.
  - Added libjetty-extra-java as a dependency of eucalyptus-java-common
* The binary resulting jar's have been renamed from eucalyptus-*-1.6.2.jar
  to eucalyptus-*-main.jar:    
  - debian/eucalyptus-cc.upstart
  - debian/eucalyptus-cloud.install
  - debian/eucalyptus-common.eucalyptus.upstart
  - debian/eucalyptus-java-common.install
  - debian/eucalyptus-network.upstart
  - debian/eucalyptus-sc.install
  - debian/eucalyptus-walrus.install
* debian/eucalyptus-java-common.install: New upstream jars that have been
  installed:
  - eucalyptus-db-hsqldb-ext-main.jar
  - eucalyptus-component-main.jar
* debian/control:
  - Updated Standards Version to 3.8.4 (no change)
  - Updated the upstream Homepage to: http://open.eucalyptus.com/
  - Changed Vcs-Bzr to reflect new location of Ubuntu hosted development branch.
  - Made the Build Dependency of groovy and the binary eucalyptus-java-common
    package depend on version >=1.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
import java.security.cert.X509Certificate;
69
69
import java.util.concurrent.ConcurrentHashMap;
70
70
import java.util.concurrent.ConcurrentMap;
71
 
 
72
71
import org.apache.log4j.Logger;
73
 
 
 
72
import com.eucalyptus.auth.crypto.Certs;
74
73
import com.eucalyptus.auth.util.EucaKeyStore;
75
 
import com.eucalyptus.auth.util.KeyTool;
 
74
import com.eucalyptus.auth.util.PEMFiles;
 
75
import com.eucalyptus.bootstrap.Bootstrap;
76
76
import com.eucalyptus.bootstrap.Bootstrapper;
77
77
import com.eucalyptus.bootstrap.Component;
78
 
import com.eucalyptus.bootstrap.Depends;
 
78
import com.eucalyptus.bootstrap.DependsLocal;
79
79
import com.eucalyptus.bootstrap.Provides;
80
 
import com.eucalyptus.bootstrap.Resource;
81
 
import com.eucalyptus.util.EucalyptusProperties;
 
80
import com.eucalyptus.bootstrap.RunDuring;
 
81
import com.eucalyptus.bootstrap.Bootstrap.Stage;
 
82
import com.eucalyptus.system.SubDirectory;
82
83
 
83
 
@Provides( resource = Resource.SystemCredentials )
84
 
@Depends( local = Component.eucalyptus )
 
84
@Provides( Component.any )
 
85
@RunDuring( Bootstrap.Stage.SystemCredentialsInit )
 
86
@DependsLocal( Component.eucalyptus )
85
87
public class SystemCredentialProvider extends Bootstrapper {
86
88
  private static Logger                                    LOG      = Logger.getLogger( SystemCredentialProvider.class );
87
89
  private static ConcurrentMap<Component, X509Certificate> certs    = new ConcurrentHashMap<Component, X509Certificate>( );
153
155
  }
154
156
 
155
157
  private void createSystemCredentialProviderKey( Component name ) throws Exception {
156
 
    KeyTool keyTool = new KeyTool( );
157
158
    try {
158
 
      KeyPair sysKp = keyTool.getKeyPair( );
159
 
      X509Certificate sysX509 = keyTool.getCertificate( sysKp, EucalyptusProperties.getDName( name.name( ) ) );
 
159
      KeyPair sysKp = Certs.generateKeyPair( );
 
160
      X509Certificate sysX509 = Certs.generateServiceCertificate( sysKp, name.name( ) );
 
161
      if( Component.eucalyptus.equals( name ) ) {
 
162
        PEMFiles.write( SubDirectory.KEYS.toString( ) + "/cloud-cert.pem", sysX509 );
 
163
        PEMFiles.write( SubDirectory.KEYS.toString( ) + "/cloud-pk.pem", sysKp.getPrivate( ) );
 
164
      }
160
165
      SystemCredentialProvider.certs.put( name, sysX509 );
161
166
      SystemCredentialProvider.keypairs.put( name, sysKp );
162
167
      // TODO: might need separate keystore for euca/hsqldb/ssl/jetty/etc.
171
176
  }
172
177
 
173
178
  @Override
174
 
  public boolean load( Resource current ) throws Exception {
 
179
  public boolean load( Stage current ) throws Exception {
175
180
    try {
176
 
      Credentials.init( );
 
181
      if ( !SystemCredentialProvider.check( Component.eucalyptus ) ) {
 
182
        SystemCredentialProvider.init( Component.eucalyptus );
 
183
      }
177
184
      for ( Component c : Component.values( ) ) {
178
185
        try {
179
 
          if ( !SystemCredentialProvider.check( c ) ) SystemCredentialProvider.init( c );
 
186
          if ( !SystemCredentialProvider.check( c ) ) {
 
187
            SystemCredentialProvider.init( c );
 
188
          }
180
189
        } catch ( Exception e ) {
181
 
          LOG.error( e );
 
190
          LOG.error( e, e );
182
191
          return false;
183
192
        }
184
193
      }
185
194
    } catch ( Exception e ) {
186
195
      LOG.error( e, e );
 
196
      return false;
187
197
    }
188
198
    return true;
189
199
  }