API Reference 0.7.0rikulo_security_pluginDummyAuthenticator

DummyAuthenticator class

A dummy implementation for testing Rikulo Security. It is definitely not a good idea to use this class in the production.

class DummyAuthenticator extends Authenticator {
 final Map<String, _DummyUserInfo> _userInfos = new Map();

 ///Adds a user.
 void addUser(String username, String password, Iterable<String> roles) {
   _userInfos[username] = new _DummyUserInfo(new SimpleUser(username, roles), password);
 }

 @override
 Future<SimpleUser> login(HttpConnect connect, String username, String password) {
   final userInfo = _userInfos[username];
   if (userInfo != null && userInfo.password == password)
     return new Future.value(userInfo.user);
   throw new AuthenticationException("Incorrect username or password");
 }

}

Extends

Authenticator > DummyAuthenticator

Methods

void addUser(String username, String password, Iterable<String> roles) #

Adds a user.

void addUser(String username, String password, Iterable<String> roles) {
 _userInfos[username] = new _DummyUserInfo(new SimpleUser(username, roles), password);
}

Future<SimpleUser> login(HttpConnect connect, String username, String password) #

Authenticates the given username and password. The returned Future object shall carry the user object if successful. If failed, throw an instance of AuthenticationException:

Future login(HttpConnect connect, String username, String password) {
  //...
  if (failed)
    throw new AuthenticationException("the cause");
  return new Future.value(new User(username, roles)); //any non-null object
});
docs inherited from Authenticator
@override
Future<SimpleUser> login(HttpConnect connect, String username, String password) {
 final userInfo = _userInfos[username];
 if (userInfo != null && userInfo.password == password)
   return new Future.value(userInfo.user);
 throw new AuthenticationException("Incorrect username or password");
}

Future<Map> logout(HttpConnect connect, user) #

inherited from Authenticator

Logout.

The default implementation does nothing but returns new Future.value(). You can override it for housekeeping if necessary.

  • user - the current user being logged out.
  • Returns a Future instance carrying the data you'd like to preserve in the new session after logout. If it carries null, nothing is preserved.

Future<Map> logout(HttpConnect connect, user) => new Future.value();