diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/AndroidAnnotationProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/AndroidAnnotationProcessor.java
index be03692b7b..94931e8c4c 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/AndroidAnnotationProcessor.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/AndroidAnnotationProcessor.java
@@ -54,6 +54,7 @@
import com.googlecode.androidannotations.annotations.FragmentByTag;
import com.googlecode.androidannotations.annotations.FromHtml;
import com.googlecode.androidannotations.annotations.Fullscreen;
+import com.googlecode.androidannotations.annotations.HttpsClient;
import com.googlecode.androidannotations.annotations.InstanceState;
import com.googlecode.androidannotations.annotations.ItemClick;
import com.googlecode.androidannotations.annotations.ItemLongClick;
@@ -133,6 +134,7 @@
import com.googlecode.androidannotations.processing.FragmentByTagProcessor;
import com.googlecode.androidannotations.processing.FromHtmlProcessor;
import com.googlecode.androidannotations.processing.FullscreenProcessor;
+import com.googlecode.androidannotations.processing.HttpsClientProcessor;
import com.googlecode.androidannotations.processing.InstanceStateProcessor;
import com.googlecode.androidannotations.processing.ItemClickProcessor;
import com.googlecode.androidannotations.processing.ItemLongClickProcessor;
@@ -190,6 +192,7 @@
import com.googlecode.androidannotations.validation.FragmentByTagValidator;
import com.googlecode.androidannotations.validation.FromHtmlValidator;
import com.googlecode.androidannotations.validation.FullscreenValidator;
+import com.googlecode.androidannotations.validation.HttpsClientValidator;
import com.googlecode.androidannotations.validation.InstanceStateValidator;
import com.googlecode.androidannotations.validation.ItemClickValidator;
import com.googlecode.androidannotations.validation.ItemLongClickValidator;
@@ -291,8 +294,8 @@
FragmentByTag.class, //
BeforeTextChange.class, //
TextChange.class, //
- AfterTextChange.class //
-})
+ AfterTextChange.class, //
+ HttpsClient.class })
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class AndroidAnnotationProcessor extends AnnotatedAbstractProcessor {
@@ -460,6 +463,7 @@ private ModelValidator buildModelValidator(IRClass rClass, AndroidSystemServices
modelValidator.register(new BeforeTextChangeValidator(processingEnv, rClass));
modelValidator.register(new TextChangeValidator(processingEnv, rClass));
modelValidator.register(new AfterTextChangeValidator(processingEnv, rClass));
+ modelValidator.register(new HttpsClientValidator(processingEnv, rClass));
return modelValidator;
}
@@ -538,6 +542,7 @@ private ModelProcessor buildModelProcessor(IRClass rClass, AndroidSystemServices
modelProcessor.register(new TextChangeProcessor(processingEnv, rClass));
modelProcessor.register(new BeforeTextChangeProcessor(processingEnv, rClass));
modelProcessor.register(new AfterTextChangeProcessor(processingEnv, rClass));
+ modelProcessor.register(new HttpsClientProcessor());
return modelProcessor;
}
diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/HttpsClient.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/HttpsClient.java
new file mode 100644
index 0000000000..e0be059f60
--- /dev/null
+++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/HttpsClient.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright (C) 2010-2011 eBusiness Information, Excilys Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed To in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.googlecode.androidannotations.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Use this annotation to get an HttpClient instance with the specified KeyStore
+ * and TrustStore configured to perform an HTTPS request
+ *
+ *
+ * All the parameters are optional
+ *
+ *
+ * trustStore: int, Resource id of your trust store file ex
+ * R.raw.cacerts.bks Typically your servers trusted certificates
+ * (public key, Root Chain Authority etc)
+ *
+ *
+ * trustStorePwd: String, Your trust store password (default is
+ * changeit)
+ *
+ *
+ * keyStore: int, Resource id of your keystore Usually your private key
+ * (client certificate)
+ *
+ *
+ * keyStorePwd: String, Your KeyStore password (default is
+ * changeit)
+ *
+ *
+ * hostnameVerif: boolean, Turn on or off strict hostname verification
+ * (default false) Hostname in certificate (DN) must match the URL.
+ *
+ *
+ * Note:
+ * Until ICS, Android accept [Key|Trust]store only in BKS format
+ * (Bouncycastle Key Store)
+ *
+ * @author Nabil Hachicha
+ */
+@Retention(RetentionPolicy.SOURCE)
+@Target(ElementType.FIELD)
+public @interface HttpsClient {
+ public static final String DEFAULT_PASSWD = "changeit";
+
+ int trustStore() default Id.DEFAULT_VALUE;
+
+ String trustStorePwd() default DEFAULT_PASSWD;
+
+ int keyStore() default Id.DEFAULT_VALUE;
+
+ String keyStorePwd() default DEFAULT_PASSWD;
+
+ boolean hostnameVerif() default false;
+}
\ No newline at end of file
diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/IdValidatorHelper.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/IdValidatorHelper.java
index 45d859fb25..141caf6f60 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/IdValidatorHelper.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/IdValidatorHelper.java
@@ -49,6 +49,13 @@ public void idExists(Element element, Res res, boolean defaultUseName, boolean a
idExists(element, res, defaultUseName, allowDefault, valid, idValue);
}
+ public void idExists(Element element, Res res, boolean defaultUseName, boolean allowDefault, IsValid valid, String methodName) {
+
+ Integer idValue = annotationHelper.extractAnnotationValue(element, methodName);
+
+ idExists(element, res, defaultUseName, allowDefault, valid, idValue);
+ }
+
public void idsExists(Element element, Res res, IsValid valid) {
int[] idsValues = annotationHelper.extractAnnotationValue(element);
diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/TargetAnnotationHelper.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/TargetAnnotationHelper.java
index 90f1b777ed..536e15624d 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/TargetAnnotationHelper.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/TargetAnnotationHelper.java
@@ -48,6 +48,19 @@ public T extractAnnotationValue(Element element) {
}
}
+ @SuppressWarnings("unchecked")
+ public T extractAnnotationValue(Element element, String methodName) {
+ Annotation annotation = element.getAnnotation(target);
+
+ Method method;
+ try {
+ method = annotation.getClass().getMethod(methodName);
+ return (T) method.invoke(annotation);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
public DeclaredType extractAnnotationClassValue(Element element) {
AnnotationMirror annotationMirror = findAnnotationMirror(element, target);
diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/HttpsClientProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/HttpsClientProcessor.java
new file mode 100644
index 0000000000..ea3053226a
--- /dev/null
+++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/HttpsClientProcessor.java
@@ -0,0 +1,188 @@
+/**
+ * Copyright (C) 2010-2011 eBusiness Information, Excilys Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed To in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ * @author Nabil Hachicha
+ */
+package com.googlecode.androidannotations.processing;
+
+import java.lang.annotation.Annotation;
+
+import javax.lang.model.element.Element;
+
+import com.googlecode.androidannotations.annotations.HttpsClient;
+import com.googlecode.androidannotations.annotations.Id;
+import com.sun.codemodel.JBlock;
+import com.sun.codemodel.JCatchBlock;
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JExpression;
+import com.sun.codemodel.JInvocation;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JTryBlock;
+import com.sun.codemodel.JVar;
+
+public class HttpsClientProcessor implements ElementProcessor {
+
+ public HttpsClientProcessor() {
+ }
+
+ @Override
+ public Class extends Annotation> getTarget() {
+ return HttpsClient.class;
+ }
+
+ @Override
+ public void process(Element element, JCodeModel codeModel, EBeansHolder eBeansHolder) {
+ EBeanHolder holder = eBeansHolder.getEnclosingEBeanHolder(element);
+
+ int trustStoreFile = element.getAnnotation(HttpsClient.class).trustStore();
+ String trustStorePwd = element.getAnnotation(HttpsClient.class).trustStorePwd();
+
+ int keyStoreFile = element.getAnnotation(HttpsClient.class).keyStore();
+ String keyStorePwd = element.getAnnotation(HttpsClient.class).keyStorePwd();
+
+ boolean hostnameVerif = element.getAnnotation(HttpsClient.class).hostnameVerif();
+
+ boolean useCustomTrustStore = Id.DEFAULT_VALUE != trustStoreFile ? true : false;
+ boolean useCustomKeyStore = Id.DEFAULT_VALUE != keyStoreFile ? true : false;
+
+ String fieldName = element.getSimpleName().toString();
+ JBlock methodBody = holder.init.body();
+
+ JClass jTypeRetMethod = holder.refClass("org.apache.http.conn.ClientConnectionManager");
+ JClass jTypeDefHttp = holder.refClass("org.apache.http.impl.client.DefaultHttpClient");
+ JClass jTypeKeyStore = holder.refClass("java.security.KeyStore");
+ JClass jTypeRes = holder.refClass("android.content.res.Resources");
+ JClass jTypeInputStream = holder.refClass("java.io.InputStream");
+
+ JDefinedClass jAnonClass = codeModel.anonymousClass(jTypeDefHttp);
+
+ JMethod method = jAnonClass.method(JMod.PROTECTED, jTypeRetMethod, "createClientConnectionManager");
+ method.annotate(Override.class);
+
+ JTryBlock jTryBlock = method.body()._try();
+ JVar jVarTrusted = null;
+ JVar jVarKeystore = null;
+
+ if (useCustomKeyStore) {
+ jVarKeystore = jTryBlock.body().decl(jTypeKeyStore, "keystore");
+ jVarKeystore.init(jTypeKeyStore.staticInvoke("getInstance").arg("BKS"));
+ }
+
+ if (useCustomTrustStore || !useCustomTrustStore && useCustomKeyStore/*
+ * use
+ * default
+ * trust
+ * store
+ */) {
+ jVarTrusted = jTryBlock.body().decl(jTypeKeyStore, "trusted");
+ jVarTrusted.init(jTypeKeyStore.staticInvoke("getInstance").arg("BKS"));
+
+ }
+
+ JVar jVarRes = null;
+ JVar jVarTrstFile = null;
+ JVar jVarKeyFile = null;
+
+ if (useCustomKeyStore || useCustomTrustStore) {
+ jVarRes = jTryBlock.body().decl(jTypeRes, "res", JExpr.invoke("getResources"));
+ }
+
+ if (useCustomKeyStore) {
+ JInvocation jInvRawKey = jVarRes.invoke("openRawResource").arg(JExpr.lit(keyStoreFile));
+ jVarKeyFile = jTryBlock.body().decl(jTypeInputStream, "inKeystore", jInvRawKey);
+ }
+
+ if (useCustomTrustStore) {
+ JInvocation jInvRawTrust = jVarRes.invoke("openRawResource").arg(JExpr.lit(trustStoreFile));
+ jVarTrstFile = jTryBlock.body().decl(jTypeInputStream, "inTrustStore", jInvRawTrust);
+
+ } else if (useCustomKeyStore) {
+ JClass jTypeFileInputStream = holder.refClass("java.io.FileInputStream");
+ jVarTrstFile = jTryBlock.body().decl(jTypeInputStream, "inTrustStore", JExpr._new(jTypeFileInputStream).arg("/system/etc/security/cacerts.bks"));
+ }
+
+ // try load
+ if (useCustomKeyStore || useCustomTrustStore) {
+ JTryBlock jTryLoad = jTryBlock.body()._try();
+
+ if (useCustomKeyStore) {
+ jTryLoad.body().add(JExpr.invoke(jVarKeystore, "load").arg(jVarKeyFile).arg(JExpr.invoke(JExpr.lit(keyStorePwd), "toCharArray")));
+ }
+
+ if (useCustomTrustStore || !useCustomTrustStore && useCustomKeyStore) {
+ jTryLoad.body().add(JExpr.invoke(jVarTrusted, "load").arg(jVarTrstFile).arg(JExpr.invoke(JExpr.lit(trustStorePwd), "toCharArray")));
+ }
+ // finally load
+ JBlock jFinally = jTryLoad._finally();
+ if (useCustomKeyStore) {
+ jFinally.add(JExpr.invoke(jVarKeyFile, "close"));
+ }
+
+ if (useCustomTrustStore || !useCustomTrustStore && useCustomKeyStore) {
+ jFinally.add(JExpr.invoke(jVarTrstFile, "close"));
+ }
+ }
+
+ if (null == jVarKeystore && null == jVarTrusted) {
+ JVar jVarCcm = jTryBlock.body().decl(jTypeRetMethod, "ccm");
+ jVarCcm.init(JExpr._super().invoke("createClientConnectionManager"));
+
+ if (!hostnameVerif) {
+ JClass jTypeSocketFact = holder.refClass("org.apache.http.conn.ssl.SSLSocketFactory");
+ JExpression jCast = JExpr.cast(jTypeSocketFact, jVarCcm.invoke("getSchemeRegistry").invoke("getScheme").arg("https").invoke("getSocketFactory"));
+ JClass jTypeSslFact = holder.refClass("org.apache.http.conn.ssl.SSLSocketFactory");
+ jTryBlock.body().add(jCast.invoke("setHostnameVerifier").arg(jTypeSslFact.staticRef("ALLOW_ALL_HOSTNAME_VERIFIER")));
+ }
+
+ jTryBlock.body()._return(jVarCcm);
+
+ } else {
+ JClass jTypeSslFact = holder.refClass("org.apache.http.conn.ssl.SSLSocketFactory");
+ JClass jTypeScheme = holder.refClass("org.apache.http.conn.scheme.Scheme");
+ JClass jTypeSchemeReg = holder.refClass("org.apache.http.conn.scheme.SchemeRegistry");
+ JClass jTypeSingleConnMgr = holder.refClass("org.apache.http.impl.conn.SingleClientConnManager");
+
+ JVar jVarSslFact = jTryBlock.body().decl(jTypeSslFact, "newSslSocketFactory");
+ jVarSslFact.init(JExpr._new(jTypeSslFact).arg(null == jVarKeystore ? JExpr._null() : jVarKeystore).arg(keyStorePwd).arg(null == jVarTrusted ? JExpr._null() : jVarTrusted));
+
+ if (!hostnameVerif) {
+ jTryBlock.body().add(JExpr.invoke(jVarSslFact, "setHostnameVerifier").arg(jTypeSslFact.staticRef("ALLOW_ALL_HOSTNAME_VERIFIER")));
+ }
+
+ JVar jVarSchemeReg = jTryBlock.body().decl(jTypeSchemeReg, "registry");
+ jVarSchemeReg.init(JExpr._new(jTypeSchemeReg));
+ jTryBlock.body().add(JExpr.invoke(jVarSchemeReg, "register").arg(JExpr._new(jTypeScheme).arg("https").arg(jVarSslFact).arg(JExpr.lit(443))));
+
+ JVar jVarCcm = jTryBlock.body().decl(jTypeRetMethod, "ccm");
+ jVarCcm.init(JExpr._new(jTypeSingleConnMgr).arg(JExpr.invoke("getParams")).arg(jVarSchemeReg));
+ jTryBlock.body()._return(jVarCcm);
+ }
+
+ // catch block
+ JClass jTypeException = holder.refClass("java.lang.Exception");
+ JCatchBlock jCatchBlock = jTryBlock._catch(jTypeException);
+ JVar jVarExceptionParam = jCatchBlock.param("e");
+ jCatchBlock.body().add(jVarExceptionParam.invoke("printStackTrace"));
+ jCatchBlock.body()._return(JExpr._super().invoke("createClientConnectionManager"));
+
+ methodBody.assign(JExpr.ref(fieldName), JExpr._new(jAnonClass));
+
+ }
+
+}
diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/rclass/IRClass.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/rclass/IRClass.java
index 46ca74e137..6cb0b65436 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/rclass/IRClass.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/rclass/IRClass.java
@@ -18,7 +18,7 @@
public interface IRClass {
public enum Res {
- LAYOUT, ID, STRING, ARRAY, COLOR, ANIM, BOOL, DIMEN, DRAWABLE, INTEGER, MOVIE, MENU;
+ LAYOUT, ID, STRING, ARRAY, COLOR, ANIM, BOOL, DIMEN, DRAWABLE, INTEGER, MOVIE, MENU, RAW;
public String rName() {
return toString().toLowerCase();
}
diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/HttpsClientValidator.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/HttpsClientValidator.java
new file mode 100644
index 0000000000..be977908a1
--- /dev/null
+++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/HttpsClientValidator.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (C) 2010-2011 eBusiness Information, Excilys Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed To in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ * @author Nabil Hachicha
+ */
+package com.googlecode.androidannotations.validation;
+
+import java.lang.annotation.Annotation;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+
+import com.googlecode.androidannotations.annotations.HttpsClient;
+import com.googlecode.androidannotations.helper.IdAnnotationHelper;
+import com.googlecode.androidannotations.helper.IdValidatorHelper;
+import com.googlecode.androidannotations.model.AnnotationElements;
+import com.googlecode.androidannotations.rclass.IRClass;
+import com.googlecode.androidannotations.rclass.IRClass.Res;
+
+public class HttpsClientValidator implements ElementValidator {
+
+ private IdValidatorHelper validatorHelper;
+
+ public HttpsClientValidator(ProcessingEnvironment processingEnv, IRClass rClass) {
+ IdAnnotationHelper annotationHelper = new IdAnnotationHelper(processingEnv, getTarget(), rClass);
+ validatorHelper = new IdValidatorHelper(annotationHelper);
+ }
+
+ @Override
+ public Class extends Annotation> getTarget() {
+ return HttpsClient.class;
+ }
+
+ @Override
+ public boolean validate(Element element, AnnotationElements validatedElements) {
+
+ IsValid valid = new IsValid();
+
+ validatorHelper.enclosingElementHasEnhancedComponentAnnotation(element, validatedElements, valid);
+
+ validatorHelper.idExists(element, Res.RAW, false, true, valid, "keyStore");
+ validatorHelper.idExists(element, Res.RAW, false, true, valid, "trustStore");
+
+ validatorHelper.isNotPrivate(element, valid);
+
+ return valid.isValid();
+ }
+
+}
diff --git a/AndroidAnnotations/functional-test-1-5-tests/pom.xml b/AndroidAnnotations/functional-test-1-5-tests/pom.xml
index a08842b740..4979f3a950 100644
--- a/AndroidAnnotations/functional-test-1-5-tests/pom.xml
+++ b/AndroidAnnotations/functional-test-1-5-tests/pom.xml
@@ -46,6 +46,13 @@
junit
test
+
+
+ bouncycastle
+ bcprov-jdk16
+ 140
+
+
diff --git a/AndroidAnnotations/functional-test-1-5-tests/src/test/java/com/googlecode/androidannotations/test15/SSLConnectionTest.java b/AndroidAnnotations/functional-test-1-5-tests/src/test/java/com/googlecode/androidannotations/test15/SSLConnectionTest.java
new file mode 100644
index 0000000000..6c6713c674
--- /dev/null
+++ b/AndroidAnnotations/functional-test-1-5-tests/src/test/java/com/googlecode/androidannotations/test15/SSLConnectionTest.java
@@ -0,0 +1,70 @@
+package com.googlecode.androidannotations.test15;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.security.Security;
+
+import junit.framework.Assert;
+
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SocketFactory;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidAnnotationsTestRunner.class)
+public class SSLConnectionTest {
+
+ private SSLConnection_ activity;
+
+ @BeforeClass
+ public static void addSecurityProvider () {
+ Security.addProvider(new BouncyCastleProvider());
+ }
+
+ @Before
+ public void setup () {
+ activity = new SSLConnection_();
+ activity.onCreate(null);
+ }
+
+ @Test
+ public void truststoreProvided () {
+ assertNotNull(activity.mHttpsClientTest1);
+ ClientConnectionManager ccm = activity.mHttpsClientTest1.getConnectionManager();
+ assertNotNull(ccm);
+
+ Scheme httpsScheme = ccm.getSchemeRegistry().getScheme("https");
+ assertNotNull(httpsScheme);
+
+ assertEquals(443, httpsScheme.getDefaultPort());
+ SocketFactory socketFactHttps = httpsScheme.getSocketFactory();
+
+ if (!(socketFactHttps instanceof SSLSocketFactory)) {
+ Assert.fail("wrong instance should be org.apache.http.conn.ssl.SSLSocketFactory, getting " + socketFactHttps);
+ }
+ assertEquals(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER, ((SSLSocketFactory)socketFactHttps).getHostnameVerifier ());
+ }
+
+ @Test
+ public void strictHostnameVerifier () {
+ assertNotNull(activity.mHttpsClientTest2);
+ ClientConnectionManager ccm = activity.mHttpsClientTest2.getConnectionManager();
+ Scheme httpsScheme = ccm.getSchemeRegistry().getScheme("https");
+ SSLSocketFactory socketFactHttps = (SSLSocketFactory)httpsScheme.getSocketFactory();
+
+ assertEquals(SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER, ((SSLSocketFactory)socketFactHttps).getHostnameVerifier ());
+ }
+
+ @Test
+ public void noOptions () {
+ assertNotNull(activity.mHttpsClientTest3);
+ ClientConnectionManager ccm = activity.mHttpsClientTest3.getConnectionManager();
+ assertNotNull(ccm);
+ }
+}
diff --git a/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml b/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml
index 015f6ff043..0a7f9d9802 100644
--- a/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml
+++ b/AndroidAnnotations/functional-test-1-5/AndroidManifest.xml
@@ -63,6 +63,7 @@
+
diff --git a/AndroidAnnotations/functional-test-1-5/res/raw/cacerts.bks b/AndroidAnnotations/functional-test-1-5/res/raw/cacerts.bks
new file mode 100644
index 0000000000..ca45764aff
Binary files /dev/null and b/AndroidAnnotations/functional-test-1-5/res/raw/cacerts.bks differ
diff --git a/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/SSLConnection.java b/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/SSLConnection.java
new file mode 100644
index 0000000000..ed91d6dd8b
--- /dev/null
+++ b/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/SSLConnection.java
@@ -0,0 +1,22 @@
+package com.googlecode.androidannotations.test15;
+
+import org.apache.http.client.HttpClient;
+
+import android.app.Activity;
+
+import com.googlecode.androidannotations.annotations.EActivity;
+import com.googlecode.androidannotations.annotations.HttpsClient;
+
+@EActivity
+public class SSLConnection extends Activity {
+ @HttpsClient(trustStore = R.raw.cacerts)
+ HttpClient mHttpsClientTest1;
+
+ @HttpsClient(trustStore = R.raw.cacerts,
+ hostnameVerif=true)
+ HttpClient mHttpsClientTest2;
+
+ @HttpsClient
+ HttpClient mHttpsClientTest3;
+
+}
diff --git a/androidannotations-dependencies/.classpath b/androidannotations-dependencies/.classpath
index d05ca50cfe..539a980637 100644
--- a/androidannotations-dependencies/.classpath
+++ b/androidannotations-dependencies/.classpath
@@ -3,6 +3,6 @@
-
+