📄 passwordutils.java
字号:
/*
* OPIAM Suite
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package opiam.admin.applis.demo.utils;
import org.apache.log4j.Logger;
/**
* This class allows to manage the password.
*/
public class PasswordUtils
{
/** Logger de log4j */
private static Logger _logger = Logger.getLogger(PasswordUtils.class);
/** Alphabetical set. */
private static String set1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/** Numeric set. */
private static String set2 = "0123456789";
/** Special characters set. */
private static String set3 = "!@#$%^&*(){}:;<>,.?/\\";
/** All characters set. */
private static String[] charsets = { set1, set2, set3 };
/**
* This method allows to check the password syntax.
* The password must be defined with :
* - at least 6 characters
* - at least a capital
* - at least a special character
* - at least a numeric character.capital
*
* @param value Password to check.
*
* @return true if the password is well-formed, otherwise false.
*/
public static boolean checkPassword(String value)
{
if (value.length() < 6)
{
return false;
}
for (int i = 0; i < 3; i++)
{
boolean found = false;
for (int j = 0; (j < charsets[i].length()) && !found; j++)
{
if (value.indexOf(charsets[i].substring(j, j + 1)) != -1)
{
found = true;
}
}
if (!found)
{
return false;
}
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -