Revision 25881fb3

b/src/com/rackspace/cloud/files/api/client/CustomHttpClient.java
1 1
package com.rackspace.cloud.files.api.client;
2 2

  
3 3
import android.content.Context;
4
import android.util.Log;
5

  
4 6
import org.apache.http.conn.ClientConnectionManager;
5 7
import org.apache.http.conn.scheme.PlainSocketFactory;
6 8
import org.apache.http.conn.scheme.Scheme;
......
14 16
import java.io.InputStream;
15 17
import java.security.KeyStore;
16 18

  
19

  
17 20
/**
18 21
 * 
19 22
 * @author Chmouel Boudjnah <chmouel.boudjnah@rackspace.co.uk>
......
24 27
 *         other version than 2.3.1.
25 28
 */
26 29
public class CustomHttpClient extends DefaultHttpClient {
27

  
28
	final Context context;
29

  
30
	
31
	private static KeyStore trusted;
32
	final Context context; 
33
	 
30 34
	public CustomHttpClient(Context context) {
35
		super();
31 36
		this.context = context;
32 37
	}
33

  
38
	
34 39
	@Override
35 40
	protected ClientConnectionManager createClientConnectionManager() {
36 41
		SchemeRegistry registry = new SchemeRegistry();
37
		registry.register(new Scheme("http", PlainSocketFactory
38
				.getSocketFactory(), 80));
42
		registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
39 43
		registry.register(new Scheme("https", newSslSocketFactory(), 443));
40
		return new SingleClientConnManager(getParams(), registry);
44
		ClientConnectionManager m =  new SingleClientConnManager(getParams(), registry);
45
		return m;
41 46
	}
42 47

  
43 48
	private SSLSocketFactory newSslSocketFactory() {
44 49
		try {
45
			KeyStore trusted = KeyStore.getInstance("BKS");
46
			InputStream in = context.getResources().openRawResource(
47
					R.raw.android231);
48
			try {
49
				trusted.load(in, "changeit".toCharArray());
50
			} finally {
51
				in.close();
50
			if (trusted == null) {
51
				trusted = KeyStore.getInstance("BKS");
52
				InputStream in = context.getResources().openRawResource(R.raw.android231); 
53
				try {
54
					trusted.load(in, "changeit".toCharArray());
55
				} finally {
56
					in.close();
57
				}
52 58
			}
53 59
			return new SSLSocketFactory(trusted);
54 60
		} catch (Exception e) {
55 61
			throw new AssertionError(e);
56 62
		}
57 63
	}
58
}
64
}
b/src/com/rackspacecloud/android/ContainerObjectsActivity.java
660 660
			return (row);
661 661
		}
662 662
	}
663

  
663
		
664 664
	private class LoadFilesTask extends
665 665
	AsyncTask<String, Void, ArrayList<ContainerObjects>> {
666 666

  
667 667
		private CloudServersException exception;
668 668
		protected void onPreExecute(){
669 669
			showDialog();
670
			loadingFiles = true;
670
			loadingFiles = true; 
671 671
		}
672 672

  
673 673
		@Override
......
686 686
		@Override
687 687
		protected void onPostExecute(ArrayList<ContainerObjects> result) {
688 688
			hideDialog();
689
			
690 689
			if (exception != null) {
691 690
				showAlert("Error", exception.getMessage());
692 691
			}
b/src/com/rackspacecloud/android/ListAccountsActivity.java
419 419
    	}
420 420
    	authenticating = false;
421 421
    }
422

  
422
       
423 423
	private class AuthenticateTask extends AsyncTask<Void, Void, Boolean> {
424 424
    	
425 425
		@Override
426 426
		protected void onPreExecute(){
427
			Log.d("info", "auth show called");
428 427
			showDialog();
429 428
		}
430 429
		
b/src/com/rackspacecloud/android/ListContainerActivity.java
139 139
			e.printStackTrace();
140 140
		}
141 141
	}
142

  
142
	
143
	
143 144
	private class LoadContainersTask extends
144 145
			AsyncTask<Void, Void, ArrayList<Container>> {
145 146

  
......
206 207

  
207 208
		@Override
208 209
		protected void onPostExecute(ArrayList<Container> result) {
209
			Log.v("listcontainerActivity", "onPostExecute loadCDNcontainerTask");
210 210
			if (exception != null) {
211 211
				showAlert("Error", exception.getMessage());
212 212
			}
b/src/com/rackspacecloud/android/ListServersActivity.java
133 133
    		e.printStackTrace();
134 134
    	}
135 135
    }
136
    
137
    
136
            
138 137
    private class LoadServersTask extends AsyncTask<Void, Void, ArrayList<Server>> {
139 138
    	
140 139
    	private CloudServersException exception;

Also available in: Unified diff