No known key found for this signature in database
GPG Key ID: B4C3BF012D9B26BE
2 changed files with
11 additions and
2 deletions
-
src/main/java/de/hsfulda/informatik/LdapSync.java
-
src/test/java/de/hsfulda/informatik/LdapSyncTest.java
|
@ -25,7 +25,8 @@ import java.util.stream.Collectors; |
|
|
*/ |
|
|
*/ |
|
|
public class LdapSync { |
|
|
public class LdapSync { |
|
|
private final Properties properties = new Properties(); |
|
|
private final Properties properties = new Properties(); |
|
|
private final static Pattern pattern = 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 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 { |
|
@ -150,7 +151,13 @@ public class LdapSync { |
|
|
return mappings.get(cn); |
|
|
return mappings.get(cn); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
final Matcher m = pattern.matcher(cn); |
|
|
|
|
|
|
|
|
final Matcher x = newPattern.matcher(cn); |
|
|
|
|
|
|
|
|
|
|
|
if (x.find()) { |
|
|
|
|
|
return 270000000 + Integer.parseInt(x.group(1)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final Matcher m = legacyPattern.matcher(cn); |
|
|
|
|
|
|
|
|
if (m.find()) { |
|
|
if (m.find()) { |
|
|
int a = 0; |
|
|
int a = 0; |
|
|
|
@ -96,6 +96,8 @@ public class LdapSyncTest { |
|
|
assertEquals(10149999, (int) LdapSync.computeUid("fdaa9999")); |
|
|
assertEquals(10149999, (int) LdapSync.computeUid("fdaa9999")); |
|
|
assertEquals(262641000, (int) LdapSync.computeUid("fdzz1000")); |
|
|
assertEquals(262641000, (int) LdapSync.computeUid("fdzz1000")); |
|
|
assertEquals(262649999, (int) LdapSync.computeUid("fdzz9999")); |
|
|
assertEquals(262649999, (int) LdapSync.computeUid("fdzz9999")); |
|
|
|
|
|
assertEquals(270000001, (int) LdapSync.computeUid("fd0000001")); |
|
|
|
|
|
assertEquals(279999999, (int) LdapSync.computeUid("fd9999999")); |
|
|
|
|
|
|
|
|
// test user defined mappings |
|
|
// test user defined mappings |
|
|
Map<String, Integer> mappings; |
|
|
Map<String, Integer> mappings; |
|
|