All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.revenj.security.UserPrincipal Maven / Gradle / Ivy

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