Browse Source

Neue Gastaccounts

main
Christian Pape 3 months ago
committed by Dustin Frisch
parent
commit
2115cad196
No known key found for this signature in database GPG Key ID: B4C3BF012D9B26BE
  1. 8
      src/main/java/de/hsfulda/informatik/LdapSync.java
  2. 2
      src/test/java/de/hsfulda/informatik/LdapSyncTest.java

8
src/main/java/de/hsfulda/informatik/LdapSync.java

@ -27,6 +27,7 @@ public class LdapSync {
private final Properties properties = new Properties(); private final Properties properties = new Properties();
private final static Pattern legacyPattern = Pattern.compile("^fd([a-z][a-z])?([0-9]*?)$"); 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 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<String, Integer> userDefinedMappings = Collections.emptyMap(); private Map<String, Integer> userDefinedMappings = Collections.emptyMap();
public LdapSync() throws IOException, LDAPException, GeneralSecurityException { public LdapSync() throws IOException, LDAPException, GeneralSecurityException {
@ -157,6 +158,13 @@ public class LdapSync {
return 270000000 + Integer.parseInt(x.group(1)); 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); final Matcher m = legacyPattern.matcher(cn);
if (m.find()) { if (m.find()) {

2
src/test/java/de/hsfulda/informatik/LdapSyncTest.java

@ -122,6 +122,8 @@ public class LdapSyncTest {
assertEquals(10149999, (int) LdapSync.computeUid("fdaa9999", mappings)); assertEquals(10149999, (int) LdapSync.computeUid("fdaa9999", mappings));
assertEquals(262641000, (int) LdapSync.computeUid("fdzz1000", mappings)); assertEquals(262641000, (int) LdapSync.computeUid("fdzz1000", mappings));
assertEquals(262649999, (int) LdapSync.computeUid("fdzz9999", 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"); mappings = LdapSync.parseUserDefinedMappings("aaabbb");
assertEquals(0, mappings.size()); assertEquals(0, mappings.size());

Loading…
Cancel
Save