HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2015-12-28 3a704c322a272e5800d216c3bde144e7640711af
extend validation of user and database names
4 files modified
1 files added
32 ■■■■ changed files
hsarback/src/de/hsadmin/mods/db/Database.java 2 ●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/db/DatabaseUser.java 4 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/email/EMailAlias.java 2 ●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/user/UnixUser.java 4 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/validate/PacName.java 20 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/db/Database.java
@@ -48,7 +48,7 @@
    @Column(name = "engine", columnDefinition = "character varying(12)", updatable=false)
    private String instance;
    @AnnFieldIO(validation="[a-z0-9\\_]*", rw=ReadWriteAccess.WRITEONCE)
    @AnnFieldIO(validation="[a-z0-9]{5}_[a-z0-9_]{1,}", rw=ReadWriteAccess.WRITEONCE)
    @Column(name = "name", columnDefinition = "character varying(24)", updatable=false)
    private String name;
hsarback/src/de/hsadmin/mods/db/DatabaseUser.java
@@ -43,11 +43,11 @@
    @Column(name = "dbuser_id", columnDefinition = "integer", updatable=false, insertable=false)
    private long id;
    @AnnFieldIO(validation="[a-z0-9\\_]*", rw=ReadWriteAccess.WRITEONCE)
    @AnnFieldIO(validation="[a-z0-9]{5}_[a-z0-9_]{1,}", rw=ReadWriteAccess.WRITEONCE)
    @Column(name = "name", columnDefinition = "character varying(24)", updatable=false)
    private String name;
    @AnnFieldIO(validation="[^']*", rw=ReadWriteAccess.WRITEONLY)
    @AnnFieldIO(validation="[^']{6,}", rw=ReadWriteAccess.WRITEONLY)
    @Transient
    private String password;
hsarback/src/de/hsadmin/mods/email/EMailAlias.java
@@ -48,7 +48,7 @@
    @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.READONLY)
    private Pac pac;
    @AnnFieldIO(validation="[a-z0-9\\_\\-\\.\\+]*", rw=ReadWriteAccess.WRITEONCE)
    @AnnFieldIO(validation="[a-z0-9]{5}-[a-z0-9\\.\\_\\+]{1,}", rw=ReadWriteAccess.WRITEONCE)
    @Column(updatable=false)
    private String name;
hsarback/src/de/hsadmin/mods/user/UnixUser.java
@@ -40,11 +40,11 @@
    @Column(name="userid", columnDefinition="integer", nullable=false, updatable=false)
    private long userId;
    @AnnFieldIO(validation="[a-z0-9\\_\\-\\.]*", rw=ReadWriteAccess.WRITEONCE)
    @AnnFieldIO(validation="[a-z0-9]{5}-[a-z0-9\\.\\_]{1,}", rw=ReadWriteAccess.WRITEONCE)
    @Column(name="name", columnDefinition = "character varying(24)", unique=true, updatable=false)
    private String name;
    @AnnFieldIO(validation="[^:]*", rw=ReadWriteAccess.WRITEONLY)
    @AnnFieldIO(validation="[^:]{6,}", rw=ReadWriteAccess.WRITEONLY)
    @Transient
    private String password;
hsarback/test/de/hsadmin/validate/PacName.java
New file
@@ -0,0 +1,20 @@
package de.hsadmin.validate;
import java.util.regex.Pattern;
public class PacName {
    public static void main(String[] args) {
        Pattern pattern = Pattern.compile("[a-z0-9]{5}-[a-z0-9\\.\\_]{1,}");
        System.out.println("xyz00-a.b " + pattern.matcher("xyz00-a.b").matches());
        System.out.println("xyz00-a-b " + pattern.matcher("xyz00-a-b").matches());
        System.out.println("xyz00-a.B " + pattern.matcher("xyz00-a.B").matches());
        System.out.println("xyz00- " + pattern.matcher("xyz00-").matches());
        System.out.println("xyz00 " + pattern.matcher("xyz00").matches());
        System.out.println("xyz0 " + pattern.matcher("xyz0").matches());
        System.out.println("xyz00_a " + pattern.matcher("xyz00_a").matches());
        System.out.println("xyz00-a.b:c " + pattern.matcher("xyz00-a.b:c").matches());
    }
}