Umstellung des checkSonderzeichen
parent
21eab99bc5
commit
fce33b6ba4
|
|
@ -3,22 +3,31 @@ import java.util.Scanner;
|
|||
public class Passwort_Check {
|
||||
|
||||
public static boolean checkLaenge(String passwort) {
|
||||
if (passwort == null){
|
||||
return false;
|
||||
}
|
||||
// Abfrage mind. Anzahl
|
||||
return passwort.length() >= 20;
|
||||
}
|
||||
|
||||
public static boolean checkKleinBuchstaben(String passwort) {
|
||||
// Abfrage der Kleinbuchstaben
|
||||
if (passwort == null){
|
||||
return false;
|
||||
}// Abfrage der Kleinbuchstaben
|
||||
return passwort.matches(".*[a-z].*[a-z].*[a-z].*");
|
||||
}
|
||||
|
||||
public static boolean checkGrossBuchstaben(String passwort) {
|
||||
// Abfrage der Grossbuchstaben
|
||||
if (passwort == null){
|
||||
return false;
|
||||
}// Abfrage der Grossbuchstaben
|
||||
return passwort.matches(".*[A-Z].*[A-Z].*[A-Z].*");
|
||||
}
|
||||
|
||||
public static boolean checkZiffer(String passwort) {
|
||||
// Abfrage der Ziffern
|
||||
if (passwort == null){
|
||||
return false;
|
||||
}// Abfrage der Ziffern
|
||||
|
||||
return passwort.matches(".*[0-9].*[0-9].*[0-9].*");
|
||||
}
|
||||
|
|
@ -31,8 +40,11 @@ public class Passwort_Check {
|
|||
// [^/r] schließt Carriage Return aus
|
||||
// [^/n] schließt Line Feed aus
|
||||
// [^A-Za-z0-9\\x00-\\x1F\\x7F] [^A-Za-z0-9\t\r\n]
|
||||
|
||||
return passwort.matches(".*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*");
|
||||
String reg = "[\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E]";
|
||||
return passwort.matches(".*"+reg+".*"+reg+".*"+reg+".*");
|
||||
//String negReg = "[^A-Za-z0-9\\x00-\\x1F\\x7F]";
|
||||
//return passwort.matches(".*"+negReg+".*"+negReg+".*"+negReg+".*");
|
||||
//return passwort.matches(".*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*[^A-Za-z0-9\\x00-\\x1F\\x7F].*");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
// import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
|
|
|||
Loading…
Reference in New Issue