org.revenj.security.UserPrincipal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of revenj-core Show documentation
Show all versions of revenj-core Show documentation
DSL Platform compatible backend (https://dsl-platform.com)
The newest version!
package org.revenj.security;
import java.security.Principal;
import java.util.Set;
import java.util.function.Function;
public final class UserPrincipal implements Principal {
private final String name;
private final Function isInRole;
public UserPrincipal(String name, Function isInRole) {
this.name = name;
this.isInRole = isInRole;
}
public UserPrincipal(String name, Set roles) {
this.name = name;
this.isInRole = roles::contains;
}
@Override
public String getName() {
return name;
}
public boolean implies(String role) {
return name.equals(role) || isInRole.apply(role);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy