~tritone-team/tritone/eucalyptus

« back to all changes in this revision

Viewing changes to clc/modules/image-manager/src/main/java/com/eucalyptus/images/util/ImageUtil.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:
129
129
    try {
130
130
      Signature sigVerifier = Signature.getInstance( "SHA1withRSA" );
131
131
      X509Certificate cert = CredentialProvider.getCertificate( alias );
132
 
      PublicKey publicKey = cert.getPublicKey( );
133
 
      sigVerifier.initVerify( publicKey );
134
 
      sigVerifier.update( pad.getBytes( ) );
135
 
      ret = sigVerifier.verify( Hashes.hexToBytes( signature ) );
 
132
      if(cert != null) {
 
133
        PublicKey publicKey = cert.getPublicKey( );
 
134
        sigVerifier.initVerify( publicKey );
 
135
        sigVerifier.update( pad.getBytes( ) );
 
136
        ret = sigVerifier.verify( Hashes.hexToBytes( signature ) );
 
137
      }
136
138
    } catch ( Exception ex ) {
137
139
      LOG.warn( ex.getMessage( ) );
138
140
    }
206
208
      try {
207
209
        signature = ( String ) xpath.evaluate( "/manifest/signature/text()", inputSource, XPathConstants.STRING );
208
210
      } catch ( XPathExpressionException e ) {}
209
 
      if ( !imgInfo.getSignature( ).equals( signature ) ) throw new EucalyptusCloudException(
 
211
      if ( imgInfo.getSignature( ) != null && !imgInfo.getSignature( ).equals( signature ) ) throw new EucalyptusCloudException(
210
212
        "Manifest signature has changed since registration." );
211
213
      ImageManager.LOG.info( "Checking image: " + imgInfo.getImageLocation( ) );
212
214
      WalrusUtil.checkValid( imgInfo );
354
356
    String userName = null;
355
357
    if ( !request.isAdministrator( ) ) {
356
358
      GetBucketAccessControlPolicyResponseType reply = WalrusUtil.getBucketAcl( request, imagePathParts );
357
 
      
358
 
      if ( !request.getUserId( ).equals( reply.getAccessControlPolicy( ).getOwner( ).getDisplayName( ) ) ) throw new EucalyptusCloudException(
 
359
      if(reply != null) {
 
360
        if ( !request.getUserId( ).equals( reply.getAccessControlPolicy( ).getOwner( ).getDisplayName( ) ) ) throw new EucalyptusCloudException(
359
361
        "Image registration failed: you must own the bucket containing the image." );
360
 
      userName = reply.getAccessControlPolicy( ).getOwner( ).getDisplayName( );
 
362
        userName = reply.getAccessControlPolicy( ).getOwner( ).getDisplayName( );
 
363
      }
361
364
    }
362
365
  }
363
366