1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/ssl/StrictHostnameVerifier.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +/* 1.5 + * ==================================================================== 1.6 + * Licensed to the Apache Software Foundation (ASF) under one 1.7 + * or more contributor license agreements. See the NOTICE file 1.8 + * distributed with this work for additional information 1.9 + * regarding copyright ownership. The ASF licenses this file 1.10 + * to you under the Apache License, Version 2.0 (the 1.11 + * "License"); you may not use this file except in compliance 1.12 + * with the License. You may obtain a copy of the License at 1.13 + * 1.14 + * http://www.apache.org/licenses/LICENSE-2.0 1.15 + * 1.16 + * Unless required by applicable law or agreed to in writing, 1.17 + * software distributed under the License is distributed on an 1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1.19 + * KIND, either express or implied. See the License for the 1.20 + * specific language governing permissions and limitations 1.21 + * under the License. 1.22 + * ==================================================================== 1.23 + * 1.24 + * This software consists of voluntary contributions made by many 1.25 + * individuals on behalf of the Apache Software Foundation. For more 1.26 + * information on the Apache Software Foundation, please see 1.27 + * <http://www.apache.org/>. 1.28 + * 1.29 + */ 1.30 + 1.31 +package ch.boye.httpclientandroidlib.conn.ssl; 1.32 + 1.33 +import javax.net.ssl.SSLException; 1.34 + 1.35 +import ch.boye.httpclientandroidlib.annotation.Immutable; 1.36 + 1.37 +/** 1.38 + * The Strict HostnameVerifier works the same way as Sun Java 1.4, Sun 1.39 + * Java 5, Sun Java 6-rc. It's also pretty close to IE6. This 1.40 + * implementation appears to be compliant with RFC 2818 for dealing with 1.41 + * wildcards. 1.42 + * <p/> 1.43 + * The hostname must match either the first CN, or any of the subject-alts. 1.44 + * A wildcard can occur in the CN, and in any of the subject-alts. The 1.45 + * one divergence from IE6 is how we only check the first CN. IE6 allows 1.46 + * a match against any of the CNs present. We decided to follow in 1.47 + * Sun Java 1.4's footsteps and only check the first CN. (If you need 1.48 + * to check all the CN's, feel free to write your own implementation!). 1.49 + * <p/> 1.50 + * A wildcard such as "*.foo.com" matches only subdomains in the same 1.51 + * level, for example "a.foo.com". It does not match deeper subdomains 1.52 + * such as "a.b.foo.com". 1.53 + * 1.54 + * 1.55 + * @since 4.0 1.56 + */ 1.57 +@Immutable 1.58 +public class StrictHostnameVerifier extends AbstractVerifier { 1.59 + 1.60 + public final void verify( 1.61 + final String host, 1.62 + final String[] cns, 1.63 + final String[] subjectAlts) throws SSLException { 1.64 + verify(host, cns, subjectAlts, true); 1.65 + } 1.66 + 1.67 + @Override 1.68 + public final String toString() { 1.69 + return "STRICT"; 1.70 + } 1.71 + 1.72 +}