Search in sources :

Example 6 with User

use of io.openems.api.security.User in project openems by OpenEMS.

the class OpenemsEnroler method enrole.

@Override
public void enrole(ClientInfo clientInfo) {
    String username = clientInfo.getUser().getIdentifier();
    User user;
    try {
        user = User.getUserByName(username);
        // 
        clientInfo.getRoles().add(// 
        Role.get(Application.getCurrent(), user.getRole().name().toLowerCase()));
    } catch (OpenemsException e) {
    /* ignore, just don't enrole user in any group */
    }
}
Also used : User(io.openems.api.security.User) OpenemsException(io.openems.common.exceptions.OpenemsException)

Aggregations

User (io.openems.api.security.User)6 JsonObject (com.google.gson.JsonObject)4 OpenemsException (io.openems.common.exceptions.OpenemsException)4 JsonParser (com.google.gson.JsonParser)1 BigInteger (java.math.BigInteger)1 SecureRandom (java.security.SecureRandom)1 UUID (java.util.UUID)1 ResourceException (org.restlet.resource.ResourceException)1