本文整理汇总了Java中be.objectify.deadbolt.core.models.Role类的典型用法代码示例。如果您正苦于以下问题:Java Role类的具体用法?Java Role怎么用?Java Role使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Role类属于be.objectify.deadbolt.core.models包,在下文中一共展示了Role类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UserAccountFormData
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
/**
* Creates a form data holder from a {@link IUserAccount}.
*
* @param userAccount
* the user account
*/
public UserAccountFormData(IUserAccount userAccount) {
this.administratorDefinedPassword = false;
this.uid = userAccount.getUid();
this.firstName = userAccount.getFirstName();
this.lastName = userAccount.getLastName();
this.mail = userAccount.getMail();
this.accountType = userAccount.getAccountType().name();
// Set the permissions
for (Role role : userAccount.getRoles()) {
this.permissions.add(role.getName());
}
// Set the roles
for (String systemLevelRoleTypes : userAccount.getSystemLevelRoleTypeNames()) {
this.systemLevelRoleTypes.add(systemLevelRoleTypes);
}
this.preferredLanguage = userAccount.getPreferredLanguage() != null ? userAccount.getPreferredLanguage().toLowerCase() : null;
}
示例2: getSubject
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public Promise<Optional<Subject>> getSubject(final Http.Context context) {
if (context.session().get("username") != null && !context.session().get("username").isEmpty()) {
// return an anonymous user
return Promise.pure(Optional.of(new Subject() {
@Override
public List<? extends Role> getRoles() {
return Collections.emptyList();
}
@Override
public List<? extends Permission> getPermissions() {
return Collections.emptyList();
}
@Override
public String getIdentifier() {
return context.session().get("username");
}
}));
} else {
return Promise.pure(Optional.empty());
}
}
示例3: isAllowed
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
public boolean isAllowed(String name, String meta, DeadboltHandler deadboltHandler, Http.Context context)
{
boolean retVal = false;
Subject roleHolder = deadboltHandler.getSubject(context);
if (roleHolder != null && User.class.isAssignableFrom(roleHolder.getClass())) {
List<? extends Role> roles = ((User) roleHolder).getRoles();
UserRole role = UserRoles.forName(name);
retVal = ((User) roleHolder).getRoles().contains(UserRoles.forName(name));
} else if (roleHolder != null) {
Logger.warn("Encountered unknown role holder entity: " + roleHolder);
}
return retVal;
}
示例4: getSelectableRoles
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
/**
* This returns a list of {@link Role} which names are actually based on
* {@link SystemPermission} names.
*/
@Override
public List<? extends Role> getSelectableRoles() {
List<? extends Role> sorterRoles = Collections.synchronizedList(new ArrayList<>(this.selectableRoles));
Collections.sort(sorterRoles, new Comparator<Role>() {
@Override
public int compare(Role role1, Role role2) {
return role1.getName().compareTo(role2.getName());
}
});
return sorterRoles;
}
示例5: getSystemPermissionNames
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public List<String> getSystemPermissionNames() {
ArrayList<String> systemPermissions = new ArrayList<String>();
for (Role deadBoltRole : getRoles()) {
systemPermissions.add(deadBoltRole.getName());
}
return systemPermissions;
}
示例6: getRoles
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public List<? extends Role> getRoles()
{
if (this.roleLevel == null) {
this.roleLevel = UserRoles.GUEST_ROLE.getLevel();
}
if (this.cachedRoles == null) {
this.cachedRoles = UserRoles.forLevel(this.roleLevel);
}
return this.cachedRoles;
}
示例7: getPermissions
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
public List<UserPermission> getPermissions() {
List<UserPermission> result = new ArrayList<>();
// childrens permissions (recursion)
for(Role child : children) {
result.addAll(((SecurityRole)child).getPermissions());
}
// this permission
result.addAll(permissions);
return result;
}
示例8: getRoles
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
/**
* This returns a list of {@link Role} which names are actually based on
* {@link SystemPermission} names.
*/
@Override
public List<? extends Role> getRoles() {
return this.roles;
}
示例9: addGroup
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public void addGroup(Role role) {
if (role != null) {
this.roles.add(role);
}
}
示例10: addSelectableGroup
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public void addSelectableGroup(Role role) {
if (role != null) {
this.selectableRoles.add(role);
}
}
示例11: getRoles
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public List<? extends Role> getRoles()
{
return roles;
}
示例12: getRoles
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public List<? extends Role> getRoles() {
return this.roles;
}
示例13: getRoles
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
@Override
public List<? extends Role> getRoles() {
return roles;
}
示例14: addGroup
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
/**
* Add a role (actually the name of a {@link SystemPermission})
*/
public void addGroup(Role role);
示例15: addSelectableGroup
import be.objectify.deadbolt.core.models.Role; //导入依赖的package包/类
/**
* Add a selectable role (actually the name of a {@link SystemPermission})
*/
public void addSelectableGroup(Role role);