FileDocCategorySizeDatePackage
ProtocolVersion.javaAPI DocAndroid 1.5 API4406Wed May 06 22:41:06 BST 2009org.apache.harmony.xnet.provider.jsse

ProtocolVersion

public class ProtocolVersion extends Object
Represents Protocol Version

Fields Summary
public final String
name
Protocol name
public final byte[]
version
Protocol version as byte array
public static final String[]
supportedProtocols
Protocols supported by this provider implementaton
private static Hashtable
protocolsByName
public static ProtocolVersion
SSLv3
SSL 3.0 protocol version
public static ProtocolVersion
TLSv1
TLS 1.0 protocol version
Constructors Summary
private ProtocolVersion(String name, byte[] version)


         
        this.name = name;
        this.version = version;
    
Methods Summary
public booleanequals(java.lang.Object o)
Compares this ProtocolVersion to the specified object.

        if (o instanceof ProtocolVersion
                && this.version[0] == ((ProtocolVersion) o).version[0]
                && this.version[1] == ((ProtocolVersion) o).version[1]) {
            return true;
        }
        return false;
    
public static org.apache.harmony.xnet.provider.jsse.ProtocolVersiongetByName(java.lang.String name)
Returns ProtocolVersion

param
name
return

        return (ProtocolVersion) protocolsByName.get(name);
    
public static org.apache.harmony.xnet.provider.jsse.ProtocolVersiongetByVersion(byte[] version)
Returns ProtocolVersion

param
version
return

        if (version[0] == 3) {
            if (version[1] == 1) {
                return TLSv1;
            }
            if (version[1] == 0) {
                return SSLv3;
            }
        }
        return null;
    
public static org.apache.harmony.xnet.provider.jsse.ProtocolVersiongetLatestVersion(java.lang.String[] protocols)
Highest protocol version supported by provider implementation

param
protocols
return

        if (protocols == null || protocols.length == 0) {
            return null;
        }
        ProtocolVersion latest = getByName(protocols[0]);
        ProtocolVersion current;
        for (int i = 1; i < protocols.length; i++) {
            current = getByName(protocols[i]);
            if (current == null) {
                continue;
            }
            if ((latest == null)
                    || (latest.version[0] < current.version[0])
                    || (latest.version[0] == current.version[0] && latest.version[1] < current.version[1])) {
                latest = current;
            }
        }
        return latest;

    
public static booleanisSupported(byte[] version)
Returns true if protocol version is supported

param
version

        if (version[0] != 3 || (version[1] != 0 && version[1] != 1)) {
            return false;
        }
        return true;
    
public static booleanisSupported(java.lang.String name)
Returns true if provider supports protocol version

param
name
return

        return protocolsByName.containsKey(name);