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

« back to all changes in this revision

Viewing changes to clc/modules/wsstack/src/main/java/com/eucalyptus/ws/handlers/WalrusSoapUserAuthenticationHandler.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:
81
81
import org.w3c.dom.Node;
82
82
import org.w3c.dom.NodeList;
83
83
 
84
 
import com.eucalyptus.auth.CredentialProvider;
85
 
import com.eucalyptus.auth.User;
 
84
import com.eucalyptus.auth.Users;
 
85
import com.eucalyptus.auth.crypto.Hmac;
 
86
import com.eucalyptus.auth.login.AuthenticationException;
 
87
import com.eucalyptus.auth.principal.User;
86
88
import com.eucalyptus.auth.util.Hashes;
87
 
import com.eucalyptus.util.HoldMe;
 
89
import com.eucalyptus.binding.HoldMe;
 
90
import com.eucalyptus.context.Contexts;
 
91
import com.eucalyptus.http.MappingHttpRequest;
88
92
import com.eucalyptus.util.WalrusProperties;
89
 
import com.eucalyptus.ws.AuthenticationException;
90
 
import com.eucalyptus.ws.MappingHttpRequest;
91
93
 
92
94
@ChannelPipelineCoverage("one")
93
95
public class WalrusSoapUserAuthenticationHandler extends MessageStackHandler {
147
149
        private void authenticate(MappingHttpRequest httpRequest, String accessKeyID, String signature, String data) throws AuthenticationException {
148
150
                signature = signature.replaceAll("=", "");
149
151
                try {
150
 
                        String queryKey = CredentialProvider.getSecretKey(accessKeyID);
 
152
      User user = Users.lookupQueryId( accessKeyID );  
 
153
      String queryKey = user.getSecretKey( );
151
154
                        String authSig = checkSignature( queryKey, data );
152
155
                        if (!authSig.equals(signature))
153
156
                                throw new AuthenticationException( "User authentication failed. Could not verify signature" );
154
 
                        String userName = CredentialProvider.getUserName( accessKeyID );
155
 
                        User user = CredentialProvider.getUser( userName );  
156
 
                        httpRequest.setUser( user );
 
157
      Contexts.lookup( httpRequest.getCorrelationId( ) ).setUser( user );
157
158
                } catch(Exception ex) {
158
159
                        throw new AuthenticationException( "User authentication failed. Unable to obtain query key" );
159
160
                }
167
168
 
168
169
        protected String checkSignature( final String queryKey, final String subject ) throws AuthenticationException
169
170
        {
170
 
                SecretKeySpec signingKey = new SecretKeySpec( queryKey.getBytes(), Hashes.Mac.HmacSHA1.toString() );
 
171
                SecretKeySpec signingKey = new SecretKeySpec( queryKey.getBytes(), Hmac.HmacSHA1.toString() );
171
172
                try
172
173
                {
173
 
                        Mac mac = Mac.getInstance( Hashes.Mac.HmacSHA1.toString() );
 
174
                        Mac mac = Hmac.HmacSHA1.getInstance();
174
175
                        mac.init( signingKey );
175
176
                        byte[] rawHmac = mac.doFinal( subject.getBytes() );
176
177
                        return new String(Base64.encode( rawHmac )).replaceAll( "=", "" );