org.androidannotations.annotations
Annotation Type HttpsClient


@Retention(value=CLASS)
@Target(value=FIELD)
public @interface HttpsClient

Use this annotation to inject an HttpClient instance with the specified KeyStore and TrustStore configured to perform an HTTPS request.

All the parameters are optional:

Note: Prior to ICS, Android accepts [Key|Trust]store only in BKS format (Bouncycastle Key Store)

Example :
 @EBean
 public class MyBean {
        @HttpsClient(trustStore = R.raw.cacerts, //
        trustStorePwd = "changeit", //
        keyStore = R.raw.client, //
        keyStorePwd = "secret", //
        allowAllHostnames = false)
        HttpClient httpsClient;
 
        @AfterInject
        @Background
        public void securedRequest() {
                try {
                        HttpGet httpget = new HttpGet("https://www.verisign.com/");
                        HttpResponse response = httpsClient.execute(httpget);
                        doSomethingWithResponse(response);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
 
        @UiThread
        public void doSomethingWithResponse(HttpResponse resp) {
                Toast.makeText(this, "HTTP status " + resp.getStatusLine().getStatusCode(), Toast.LENGTH_LONG).show();
        }
 }
 


Optional Element Summary
 boolean allowAllHostnames
           
 int keyStore
           
 String keyStorePwd
           
 int trustStore
           
 String trustStorePwd
           
 

trustStore

public abstract int trustStore
Default:
-1

trustStorePwd

public abstract String trustStorePwd
Default:
"changeit"

keyStore

public abstract int keyStore
Default:
-1

keyStorePwd

public abstract String keyStorePwd
Default:
"changeit"

allowAllHostnames

public abstract boolean allowAllHostnames
Default:
true


Copyright © 2010-2014. All Rights Reserved.