Fields Summary |
---|
public static final String | EMPTY_VALUE |
public static final String | EAP_KEY |
public static final String | PHASE2_KEY |
public static final String | IDENTITY_KEY |
public static final String | ANON_IDENTITY_KEY |
public static final String | PASSWORD_KEY |
public static final String | SUBJECT_MATCH_KEY |
public static final String | OPP_KEY_CACHING |
public static final String | ENGINE_ID_KEYSTOREString representing the keystore OpenSSL ENGINE's ID. |
public static final String | KEYSTORE_URIString representing the keystore URI used for wpa_supplicant. |
public static final String | ENGINE_ENABLEString to set the engine value to when it should be enabled. |
public static final String | ENGINE_DISABLEString to set the engine value to when it should be disabled. |
public static final String | CA_CERT_PREFIX |
public static final String | CLIENT_CERT_PREFIX |
public static final String | CLIENT_CERT_KEY |
public static final String | CA_CERT_KEY |
public static final String | ENGINE_KEY |
public static final String | ENGINE_ID_KEY |
public static final String | PRIVATE_KEY_ID_KEY |
private HashMap | mFields |
private X509Certificate | mCaCert |
private PrivateKey | mClientPrivateKey |
private X509Certificate | mClientCertificate |
public static final Creator | CREATOR |
Methods Summary |
---|
private java.lang.String | convertToQuotedString(java.lang.String string)
return "\"" + string + "\"";
|
public int | describeContents()
return 0;
|
public java.lang.String | getAnonymousIdentity()Get the anonymous identity
return getFieldValue(ANON_IDENTITY_KEY, "");
|
public java.security.cert.X509Certificate | getCaCertificate()Get CA certificate
return mCaCert;
|
public java.lang.String | getCaCertificateAlias()Get CA certificate alias
return getFieldValue(CA_CERT_KEY, CA_CERT_PREFIX);
|
public java.security.cert.X509Certificate | getClientCertificate()Get client certificate
return mClientCertificate;
|
public java.lang.String | getClientCertificateAlias()Get client certificate alias
return getFieldValue(CLIENT_CERT_KEY, CLIENT_CERT_PREFIX);
|
public java.security.PrivateKey | getClientPrivateKey()
return mClientPrivateKey;
|
public int | getEapMethod()Get the eap method.
String eapMethod = mFields.get(EAP_KEY);
return getStringIndex(Eap.strings, eapMethod, Eap.NONE);
|
public java.lang.String | getFieldValue(java.lang.String key, java.lang.String prefix)Returns the field value for the key.
String value = mFields.get(key);
// Uninitialized or known to be empty after reading from supplicant
if (TextUtils.isEmpty(value) || EMPTY_VALUE.equals(value)) return "";
value = removeDoubleQuotes(value);
if (value.startsWith(prefix)) {
return value.substring(prefix.length());
} else {
return value;
}
|
public java.util.HashMap | getFields()Internal use only
return mFields;
|
public java.lang.String | getIdentity()Get the identity
return getFieldValue(IDENTITY_KEY, "");
|
java.lang.String | getKeyId(android.net.wifi.WifiEnterpriseConfig current)See {@link WifiConfiguration#getKeyIdForCredentials} @hide
String eap = mFields.get(EAP_KEY);
String phase2 = mFields.get(PHASE2_KEY);
// If either eap or phase2 are not initialized, use current config details
if (TextUtils.isEmpty((eap))) {
eap = current.mFields.get(EAP_KEY);
}
if (TextUtils.isEmpty(phase2)) {
phase2 = current.mFields.get(PHASE2_KEY);
}
return eap + "_" + phase2;
|
public java.lang.String | getPassword()Get the password.
Returns locally set password value. For networks fetched from
framework, returns "*".
return getFieldValue(PASSWORD_KEY, "");
|
public int | getPhase2Method()Get the phase 2 authentication method.
String phase2Method = removeDoubleQuotes(mFields.get(PHASE2_KEY));
// Remove auth= prefix
if (phase2Method.startsWith(Phase2.PREFIX)) {
phase2Method = phase2Method.substring(Phase2.PREFIX.length());
}
return getStringIndex(Phase2.strings, phase2Method, Phase2.NONE);
|
private int | getStringIndex(java.lang.String[] arr, java.lang.String toBeFound, int defaultIndex)Returns the index at which the toBeFound string is found in the array.
if (TextUtils.isEmpty(toBeFound)) return defaultIndex;
for (int i = 0; i < arr.length; i++) {
if (toBeFound.equals(arr[i])) return i;
}
return defaultIndex;
|
public java.lang.String | getSubjectMatch()Get subject match
return getFieldValue(SUBJECT_MATCH_KEY, "");
|
private java.lang.String | removeDoubleQuotes(java.lang.String string)
if (TextUtils.isEmpty(string)) return "";
int length = string.length();
if ((length > 1) && (string.charAt(0) == '"")
&& (string.charAt(length - 1) == '"")) {
return string.substring(1, length - 1);
}
return string;
|
public void | resetCaCertificate()
mCaCert = null;
|
public void | resetClientKeyEntry()
mClientPrivateKey = null;
mClientCertificate = null;
|
public void | setAnonymousIdentity(java.lang.String anonymousIdentity)Set anonymous identity. This is used as the unencrypted identity with
certain EAP types
setFieldValue(ANON_IDENTITY_KEY, anonymousIdentity, "");
|
public void | setCaCertificate(java.security.cert.X509Certificate cert)Specify a X.509 certificate that identifies the server.
A default name is automatically assigned to the certificate and used
with this configuration. The framework takes care of installing the
certificate when the config is saved and removing the certificate when
the config is removed.
if (cert != null) {
if (cert.getBasicConstraints() >= 0) {
mCaCert = cert;
} else {
throw new IllegalArgumentException("Not a CA certificate");
}
} else {
mCaCert = null;
}
|
public void | setCaCertificateAlias(java.lang.String alias)Set CA certificate alias.
See the {@link android.security.KeyChain} for details on installing or choosing
a certificate
setFieldValue(CA_CERT_KEY, alias, CA_CERT_PREFIX);
|
public void | setClientCertificateAlias(java.lang.String alias)Set Client certificate alias.
See the {@link android.security.KeyChain} for details on installing or choosing
a certificate
setFieldValue(CLIENT_CERT_KEY, alias, CLIENT_CERT_PREFIX);
setFieldValue(PRIVATE_KEY_ID_KEY, alias, Credentials.USER_PRIVATE_KEY);
// Also, set engine parameters
if (TextUtils.isEmpty(alias)) {
mFields.put(ENGINE_KEY, ENGINE_DISABLE);
mFields.put(ENGINE_ID_KEY, EMPTY_VALUE);
} else {
mFields.put(ENGINE_KEY, ENGINE_ENABLE);
mFields.put(ENGINE_ID_KEY, convertToQuotedString(ENGINE_ID_KEYSTORE));
}
|
public void | setClientKeyEntry(java.security.PrivateKey privateKey, java.security.cert.X509Certificate clientCertificate)Specify a private key and client certificate for client authorization.
A default name is automatically assigned to the key entry and used
with this configuration. The framework takes care of installing the
key entry when the config is saved and removing the key entry when
the config is removed.
if (clientCertificate != null) {
if (clientCertificate.getBasicConstraints() != -1) {
throw new IllegalArgumentException("Cannot be a CA certificate");
}
if (privateKey == null) {
throw new IllegalArgumentException("Client cert without a private key");
}
if (privateKey.getEncoded() == null) {
throw new IllegalArgumentException("Private key cannot be encoded");
}
}
mClientPrivateKey = privateKey;
mClientCertificate = clientCertificate;
|
public void | setEapMethod(int eapMethod)Set the EAP authentication method.
switch (eapMethod) {
/** Valid methods */
case Eap.TLS:
setPhase2Method(Phase2.NONE);
/* fall through */
case Eap.PEAP:
case Eap.PWD:
case Eap.TTLS:
case Eap.SIM:
case Eap.AKA:
mFields.put(EAP_KEY, Eap.strings[eapMethod]);
mFields.put(OPP_KEY_CACHING, "1");
break;
default:
throw new IllegalArgumentException("Unknown EAP method");
}
|
public void | setFieldValue(java.lang.String key, java.lang.String value, java.lang.String prefix)Set a value with an optional prefix at key
if (TextUtils.isEmpty(value)) {
mFields.put(key, EMPTY_VALUE);
} else {
mFields.put(key, convertToQuotedString(prefix + value));
}
|
public void | setFieldValue(java.lang.String key, java.lang.String value)Set a value with an optional prefix at key
if (TextUtils.isEmpty(value)) {
mFields.put(key, EMPTY_VALUE);
} else {
mFields.put(key, convertToQuotedString(value));
}
|
public void | setIdentity(java.lang.String identity)Set the identity
setFieldValue(IDENTITY_KEY, identity, "");
|
public void | setPassword(java.lang.String password)Set the password.
setFieldValue(PASSWORD_KEY, password, "");
|
public void | setPhase2Method(int phase2Method)Set Phase 2 authentication method. Sets the inner authentication method to be used in
phase 2 after setting up a secure channel
switch (phase2Method) {
case Phase2.NONE:
mFields.put(PHASE2_KEY, EMPTY_VALUE);
break;
/** Valid methods */
case Phase2.PAP:
case Phase2.MSCHAP:
case Phase2.MSCHAPV2:
case Phase2.GTC:
mFields.put(PHASE2_KEY, convertToQuotedString(
Phase2.PREFIX + Phase2.strings[phase2Method]));
break;
default:
throw new IllegalArgumentException("Unknown Phase 2 method");
}
|
public void | setSubjectMatch(java.lang.String subjectMatch)Set subject match. This is the substring to be matched against the subject of the
authentication server certificate.
setFieldValue(SUBJECT_MATCH_KEY, subjectMatch, "");
|
public java.lang.String | toString()
StringBuffer sb = new StringBuffer();
for (String key : mFields.keySet()) {
sb.append(key).append(" ").append(mFields.get(key)).append("\n");
}
return sb.toString();
|
private void | writeCertificate(android.os.Parcel dest, java.security.cert.X509Certificate cert)
if (cert != null) {
try {
byte[] certBytes = cert.getEncoded();
dest.writeInt(certBytes.length);
dest.writeByteArray(certBytes);
} catch (CertificateEncodingException e) {
dest.writeInt(0);
}
} else {
dest.writeInt(0);
}
|
public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mFields.size());
for (Map.Entry<String, String> entry : mFields.entrySet()) {
dest.writeString(entry.getKey());
dest.writeString(entry.getValue());
}
writeCertificate(dest, mCaCert);
if (mClientPrivateKey != null) {
String algorithm = mClientPrivateKey.getAlgorithm();
byte[] userKeyBytes = mClientPrivateKey.getEncoded();
dest.writeInt(userKeyBytes.length);
dest.writeByteArray(userKeyBytes);
dest.writeString(algorithm);
} else {
dest.writeInt(0);
}
writeCertificate(dest, mClientCertificate);
|