// LocalAdminUserRealm localAdminRealm = new LocalAdminUserRealm("local-accounts");
// localAdminRealm.setCredentialsMatcher(new HashedCredentialsMatcher("SHA2"));
// setupLocalUser(api, localAdminRealm, app);
Realm serverRestInterfaceRealm = injector.getInstance(ServerRestInterfaceRealm.class);
final DefaultSecurityManager securityManager =
new DefaultSecurityManager(
Lists.newArrayList(serverRestInterfaceRealm)
);
// disable storing sessions (TODO we might want to write a session store bridge to play's session cookie)
final DefaultSessionStorageEvaluator sessionStorageEvaluator = new DefaultSessionStorageEvaluator();
sessionStorageEvaluator.setSessionStorageEnabled(false);
final DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
subjectDAO.setSessionStorageEvaluator(sessionStorageEvaluator);
securityManager.setSubjectDAO(subjectDAO);
final Authenticator authenticator = securityManager.getAuthenticator();
if (authenticator instanceof ModularRealmAuthenticator) {
ModularRealmAuthenticator a = (ModularRealmAuthenticator) authenticator;
a.setAuthenticationStrategy(new RethrowingFirstSuccessfulStrategy());
a.setAuthenticationListeners(
Lists.<AuthenticationListener>newArrayList(new PlayAuthenticationListener())