Created
August 11, 2014 16:33
-
-
Save knd/490cd143aea32fbf22e3 to your computer and use it in GitHub Desktop.
AccessManager Contructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings("unchecked") | |
private AccessManager(String backingStore, int accessTokenTtl, | |
TimeUnit accessTokenTtlUnit) { | |
this.backingStore = backingStore; | |
this.tokenManager = AccessTokenManager.create( | |
accessTokenTtl, accessTokenTtlUnit); | |
ByteBuffer tableBytes = FileSystem.readBytes(backingStore); | |
ByteArrayInputStream bais = new ByteArrayInputStream( | |
ByteBuffers.toByteArray(tableBytes)); | |
try { | |
BufferedInputStream bis = new BufferedInputStream(bais); | |
ObjectInput input = new ObjectInputStream(bis); | |
credentials = (Table<Short, String, Object>) input.readObject(); | |
} catch (IOException e) { | |
throw Throwables.propagate(e); | |
} catch (ClassNotFoundException e) { | |
throw Throwables.propagate(e); | |
} | |
// If there are no credentials (which implies this is a new server) add | |
// the default admin username/password | |
if(credentials.isEmpty()) { | |
createUser(ByteBuffers.decodeFromHex(ADMIN_USERNAME), | |
ByteBuffers.decodeFromHex(ADMIN_PASSWORD)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment