am 22759bac
: Handle complex chars policy correctly
* commit '22759bacd95385d95d3d9321f490763df1aba89d': Handle complex chars policy correctly
This commit is contained in:
commit
b959d9b9b2
@ -222,7 +222,11 @@ public class PolicySet implements Parcelable {
|
|||||||
case PASSWORD_MODE_SIMPLE:
|
case PASSWORD_MODE_SIMPLE:
|
||||||
return DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
|
return DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
|
||||||
case PASSWORD_MODE_STRONG:
|
case PASSWORD_MODE_STRONG:
|
||||||
return DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC;
|
if (mPasswordComplexChars == 0) {
|
||||||
|
return DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC;
|
||||||
|
} else {
|
||||||
|
return DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return DevicePolicyManager .PASSWORD_QUALITY_UNSPECIFIED;
|
return DevicePolicyManager .PASSWORD_QUALITY_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,13 @@ public class SecurityPolicy {
|
|||||||
policies.getDPManagerPasswordExpirationTimeout());
|
policies.getDPManagerPasswordExpirationTimeout());
|
||||||
// password history length (number of previous passwords that may not be reused)
|
// password history length (number of previous passwords that may not be reused)
|
||||||
dpm.setPasswordHistoryLength(mAdminName, policies.mPasswordHistory);
|
dpm.setPasswordHistoryLength(mAdminName, policies.mPasswordHistory);
|
||||||
// password minimum complex characters
|
// password minimum complex characters.
|
||||||
|
// Note, in Exchange, "complex chars" simply means "non alpha", but in the DPM,
|
||||||
|
// setting the quality to complex also defaults min symbols=1 and min numeric=1.
|
||||||
|
// We always / safely clear minSymbols & minNumeric to zero (there is no policy
|
||||||
|
// configuration in which we explicitly require a minimum number of digits or symbols.)
|
||||||
|
dpm.setPasswordMinimumSymbols(mAdminName, 0);
|
||||||
|
dpm.setPasswordMinimumNumeric(mAdminName, 0);
|
||||||
dpm.setPasswordMinimumNonLetter(mAdminName, policies.mPasswordComplexChars);
|
dpm.setPasswordMinimumNonLetter(mAdminName, policies.mPasswordComplexChars);
|
||||||
// encryption required
|
// encryption required
|
||||||
dpm.setStorageEncryption(mAdminName, policies.mRequireEncryption);
|
dpm.setStorageEncryption(mAdminName, policies.mRequireEncryption);
|
||||||
|
@ -688,4 +688,33 @@ public class SecurityPolicyTests extends ProviderTestCase2<EmailProvider> {
|
|||||||
assertEquals(policyExpect, p3Result);
|
assertEquals(policyExpect, p3Result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the code that converts from exchange-style quality to DPM/Lockscreen style quality.
|
||||||
|
*/
|
||||||
|
public void testGetDPManagerPasswordQuality() {
|
||||||
|
// PolicySet.PASSWORD_MODE_NONE -> DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED
|
||||||
|
PolicySet p1 = new PolicySet(0, PolicySet.PASSWORD_MODE_NONE,
|
||||||
|
0, 0, false, 0, 0, 0, false, false);
|
||||||
|
assertEquals(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED,
|
||||||
|
p1.getDPManagerPasswordQuality());
|
||||||
|
|
||||||
|
// PASSWORD_MODE_SIMPLE -> PASSWORD_QUALITY_NUMERIC
|
||||||
|
PolicySet p2 = new PolicySet(4, PolicySet.PASSWORD_MODE_SIMPLE,
|
||||||
|
0, 0, false, 0, 0, 0, false, false);
|
||||||
|
assertEquals(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC,
|
||||||
|
p2.getDPManagerPasswordQuality());
|
||||||
|
|
||||||
|
// PASSWORD_MODE_STRONG -> PASSWORD_QUALITY_ALPHANUMERIC
|
||||||
|
PolicySet p3 = new PolicySet(4, PolicySet.PASSWORD_MODE_STRONG,
|
||||||
|
0, 0, false, 0, 0, 0, false, false);
|
||||||
|
assertEquals(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC,
|
||||||
|
p3.getDPManagerPasswordQuality());
|
||||||
|
|
||||||
|
// PASSWORD_MODE_STRONG + complex chars -> PASSWORD_QUALITY_COMPLEX
|
||||||
|
PolicySet p4 = new PolicySet(4, PolicySet.PASSWORD_MODE_STRONG,
|
||||||
|
0, 0, false, 0, 0 , 2, false, false);
|
||||||
|
assertEquals(DevicePolicyManager.PASSWORD_QUALITY_COMPLEX,
|
||||||
|
p4.getDPManagerPasswordQuality());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user