diff --git a/LaunchServer/source/auth/handler/FileAuthHandler.java b/LaunchServer/source/auth/handler/FileAuthHandler.java index 0e951ee..1913cd6 100644 --- a/LaunchServer/source/auth/handler/FileAuthHandler.java +++ b/LaunchServer/source/auth/handler/FileAuthHandler.java @@ -34,7 +34,7 @@ private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); // Storage - private final Map authsMap = new HashMap<>(IOHelper.BUFFER_SIZE); + private final Map entryMap = new HashMap<>(IOHelper.BUFFER_SIZE); private final Map usernamesMap = new HashMap<>(IOHelper.BUFFER_SIZE); @LauncherAPI @@ -59,7 +59,7 @@ lock.writeLock().lock(); try { UUID uuid = usernameToUUID(username); - Entry entry = authsMap.get(uuid); + Entry entry = entryMap.get(uuid); // Not registered? Fix it! if (entry == null) { @@ -67,7 +67,7 @@ // Generate UUID uuid = genUUIDFor(username); - authsMap.put(uuid, entry); + entryMap.put(uuid, entry); usernamesMap.put(CommonHelper.low(username), uuid); } @@ -84,7 +84,7 @@ lock.readLock().lock(); try { UUID uuid = usernameToUUID(username); - Entry entry = authsMap.get(uuid); + Entry entry = entryMap.get(uuid); // Check server (if has such account of course) return entry != null && entry.checkServer(username, serverID) ? uuid : null; @@ -97,7 +97,7 @@ public final void flush() throws IOException { lock.readLock().lock(); try { - LogHelper.info("Writing auth handler file (%d entries)", authsMap.size()); + LogHelper.info("Writing auth handler file (%d entries)", entryMap.size()); writeAuthFile(); } finally { lock.readLock().unlock(); @@ -108,7 +108,7 @@ public final boolean joinServer(String username, String accessToken, String serverID) { lock.writeLock().lock(); try { - Entry entry = authsMap.get(usernameToUUID(username)); + Entry entry = entryMap.get(usernameToUUID(username)); return entry != null && entry.joinServer(username, accessToken, serverID); } finally { lock.writeLock().unlock(); @@ -129,7 +129,7 @@ public final String uuidToUsername(UUID uuid) { lock.readLock().lock(); try { - Entry entry = authsMap.get(uuid); + Entry entry = entryMap.get(uuid); return entry == null ? null : entry.username; } finally { lock.readLock().unlock(); @@ -138,14 +138,14 @@ @LauncherAPI public final Set> entrySet() { - return Collections.unmodifiableMap(authsMap).entrySet(); + return Collections.unmodifiableMap(entryMap).entrySet(); } @LauncherAPI protected final void addAuth(UUID uuid, Entry entry) throws IOException { lock.writeLock().lock(); try { - Entry previous = authsMap.put(uuid, entry); + Entry previous = entryMap.put(uuid, entry); if (previous != null) { // In case of username changing usernamesMap.remove(CommonHelper.low(previous.username)); } @@ -164,7 +164,7 @@ private UUID genUUIDFor(String username) { if (offlineUUIDs) { UUID md5UUID = PlayerProfile.offlineUUID(username); - if (!authsMap.containsKey(md5UUID)) { + if (!entryMap.containsKey(md5UUID)) { return md5UUID; } LogHelper.warning("Offline UUID collision, using random: '%s'", username); @@ -174,7 +174,7 @@ UUID uuid; do { uuid = new UUID(random.nextLong(), random.nextLong()); - } while (authsMap.containsKey(uuid)); + } while (entryMap.containsKey(uuid)); return uuid; } diff --git a/LaunchServer/source/auth/provider/FileAuthProvider.java b/LaunchServer/source/auth/provider/FileAuthProvider.java index c0d1c81..e9e3121 100644 --- a/LaunchServer/source/auth/provider/FileAuthProvider.java +++ b/LaunchServer/source/auth/provider/FileAuthProvider.java @@ -22,7 +22,7 @@ private final Path file; // Cache - private final Map auths = new HashMap<>(8192); + private final Map entries = new HashMap<>(IOHelper.BUFFER_SIZE); private final Object cacheLock = new Object(); private FileTime cacheLastModified; @@ -40,15 +40,15 @@ @Override public String auth(String login, String password) throws IOException { - Auth auth; + Entry entry; synchronized (cacheLock) { updateCache(); - auth = auths.get(CommonHelper.low(login)); + entry = entries.get(CommonHelper.low(login)); } // Verify digest and return true username - verifyDigest(auth.password, password); - return auth.username; + verifyDigest(entry.password, password); + return entry.username; } @Override @@ -69,8 +69,8 @@ authFile = TextConfigReader.read(reader, false); } - // Read auths from config block - auths.clear(); + // Read entries from config block + entries.clear(); Set>> entrySet = authFile.getValue().entrySet(); for (Map.Entry> entry : entrySet) { String login = entry.getKey(); @@ -78,8 +78,8 @@ String.format("Illegal config entry type: '%s'", login)); // Add auth entry - Auth auth = new Auth((BlockConfigEntry) value); - VerifyHelper.putIfAbsent(auths, CommonHelper.low(login), auth, + Entry auth = new Entry((BlockConfigEntry) value); + VerifyHelper.putIfAbsent(entries, CommonHelper.low(login), auth, String.format("Duplicate login: '%s'", login)); } @@ -87,11 +87,11 @@ cacheLastModified = lastModified; } - private static final class Auth extends ConfigObject { + private static final class Entry extends ConfigObject { private final String username; private final String password; - private Auth(BlockConfigEntry block) { + private Entry(BlockConfigEntry block) { super(block); this.username = VerifyHelper.verifyUsername(block.getEntryValue("username", StringConfigEntry.class)); this.password = VerifyHelper.verify(block.getEntryValue("password", StringConfigEntry.class),