From 2115cad19675c7c8984a01b230d64da6da43c42a Mon Sep 17 00:00:00 2001 From: Christian Pape Date: Sat, 31 Aug 2024 10:02:32 +0200 Subject: [PATCH] Neue Gastaccounts --- src/main/java/de/hsfulda/informatik/LdapSync.java | 8 ++++++++ src/test/java/de/hsfulda/informatik/LdapSyncTest.java | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/de/hsfulda/informatik/LdapSync.java b/src/main/java/de/hsfulda/informatik/LdapSync.java index fc2f8d7..d46b44e 100644 --- a/src/main/java/de/hsfulda/informatik/LdapSync.java +++ b/src/main/java/de/hsfulda/informatik/LdapSync.java @@ -27,6 +27,7 @@ public class LdapSync { private final Properties properties = new Properties(); private final static Pattern legacyPattern = Pattern.compile("^fd([a-z][a-z])?([0-9]*?)$"); private final static Pattern newPattern = Pattern.compile("^fd([0-9][0-9][0-9][0-9][0-9][0-9][0-9])$"); + private final static Pattern newGuestPattern = Pattern.compile("^fdg([0-9][0-9][0-9][0-9][0-9])$"); private Map userDefinedMappings = Collections.emptyMap(); public LdapSync() throws IOException, LDAPException, GeneralSecurityException { @@ -157,6 +158,13 @@ public class LdapSync { return 270000000 + Integer.parseInt(x.group(1)); } + final Matcher y = newGuestPattern.matcher(cn); + + if (y.find()) { + return 300000000 + Integer.parseInt(y.group(1)); + } + + final Matcher m = legacyPattern.matcher(cn); if (m.find()) { diff --git a/src/test/java/de/hsfulda/informatik/LdapSyncTest.java b/src/test/java/de/hsfulda/informatik/LdapSyncTest.java index 3f7ee27..52ce44a 100644 --- a/src/test/java/de/hsfulda/informatik/LdapSyncTest.java +++ b/src/test/java/de/hsfulda/informatik/LdapSyncTest.java @@ -122,6 +122,8 @@ public class LdapSyncTest { assertEquals(10149999, (int) LdapSync.computeUid("fdaa9999", mappings)); assertEquals(262641000, (int) LdapSync.computeUid("fdzz1000", mappings)); assertEquals(262649999, (int) LdapSync.computeUid("fdzz9999", mappings)); + assertEquals(300000000, (int) LdapSync.computeUid("fdg00000", mappings)); + assertEquals(300099999, (int) LdapSync.computeUid("fdg99999", mappings)); mappings = LdapSync.parseUserDefinedMappings("aaabbb"); assertEquals(0, mappings.size());