List<Roles> userRoleList = new ArrayList<Roles>(); Users currentUser = new Users(); currentUser.setUserId(userId); currentUser.setUsername(email); currentUser.setPassword(password); Roles userRole = new Roles(); userRole.setRoleId("2"); userRoleList.add(userRole); currentUser.setRolesCollection(userRoleList); getUsersFacade().create(currentUser);
private Roles createRoles(EList<Permission> permissions) { List<String> roleNames = new ArrayList<String>(permissions.size()); for (Permission permission : permissions) { roleNames.add(permission.getName()); } return new Roles(roleNames.toArray(new String[permissions.size()])); }
Roles r = new Roles(); r.setIdRoles(new Short("2")); List<Roles> roleList = new ArrayList<Roles>(); roleList.add(r);
@Override public Roles getRoles() { Roles roles = new Roles(); if (isSignedIn()) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); for (GrantedAuthority authority : authentication.getAuthorities()) { roles.add(authority.getAuthority()); } } return roles; }
@Override public Roles getRoles() { Roles roles = new Roles(); if (isSignedIn()) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); for (GrantedAuthority authority : authentication.getAuthorities()) { roles.add(authority.getAuthority()); } } return roles; }
@Override public synchronized Roles getRoles() { if (!isSignedIn()) { return null; } final List<String> roles = authenticationSession.getRoles(); return new Roles(roles.toArray(new String[roles.size()])); }
@Override public Roles getRoles() { if (isSignedIn() && roles == null && auth != null) { roles = new Roles(auth.keySet().toArray(new String[] {})); roles.add(Constants.ROLE_AUTHENTICATED); } return roles; }
@Override public Roles getRoles() { Roles roles = new Roles(); if (isSignedIn()) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); for (GrantedAuthority authority : authentication.getAuthorities()) { roles.add(authority.getAuthority()); } } return roles; } }
private boolean isResourceAnnotationSatisfied(AuthorizeResource annotation) { if (annotation != null) { // we have an annotation => we must check for the required roles return hasAny(new Roles(annotation.value())); } else { // no annotation => no required roles => this resource can be accessed return true; } } }
private boolean isResourceAnnotationSatisfied(AuthorizeResource annotation) { if (annotation != null) { // we have an annotation => we must check for the required roles return hasAny(new Roles(annotation.value())); } else { // no annotation => no required roles => this resource can be accessed return true; } } }
/** * Check if annotated instantiation is allowed. * * @param authorizeInstantiationAnnotation * The annotations information * @return False if the instantiation is not authorized */ private <T extends IRequestableComponent> boolean check( final AuthorizeInstantiation authorizeInstantiationAnnotation) { // We are authorized unless we are found not to be boolean authorized = true; // Check class annotation first because it is more specific than package annotation if (authorizeInstantiationAnnotation != null) { authorized = hasAny(new Roles(authorizeInstantiationAnnotation.value())); } return authorized; }
/** * Check if annotated instantiation is allowed. * * @param authorizeInstantiationAnnotation * The annotations information * @return False if the instantiation is not authorized */ private <T extends IRequestableComponent> boolean check( final AuthorizeInstantiation authorizeInstantiationAnnotation) { // We are authorized unless we are found not to be boolean authorized = true; // Check class annotation first because it is more specific than package annotation if (authorizeInstantiationAnnotation != null) { authorized = hasAny(new Roles(authorizeInstantiationAnnotation.value())); } return authorized; }
/** * Constructor. * * @param title IModel used to represent the title of the tab. Must contain a string * @param roles authorized roles */ public ITabComponent(final IModel<String> title, final String... roles) { super(UUID.randomUUID().toString()); this.title = title; final ActionPermissions permissions = new ActionPermissions(); setMetaData(MetaDataRoleAuthorizationStrategy.ACTION_PERMISSIONS, permissions); if (roles == null || roles.length == 0) { permissions.authorizeAll(RENDER); } else { permissions.authorize(RENDER, new Roles(roles)); } }
/** * Authorizes the given role to perform the given action on the given component. * * @param component * The component that is subject to the authorization * @param action * The action to authorize * @param roles * The comma separated roles to authorize */ public static void authorize(final Component component, final Action action, final String roles) { ActionPermissions permissions = component.getMetaData(ACTION_PERMISSIONS); if (permissions == null) { permissions = new ActionPermissions(); component.setMetaData(ACTION_PERMISSIONS, permissions); } permissions.authorize(action, new Roles(roles)); }
@Override public Roles getRoles() { Roles ret = new Roles(); if(isSignedIn()) { Set<? extends OSecurityRole> roles = getUser().getRoles(); for (OSecurityRole oRole : roles) { ret.add(oRole.getName()); OSecurityRole parent = oRole.getParentRole(); while(parent!=null && !ret.contains(parent.getName())) { ret.add(parent.getName()); parent = parent.getParentRole(); } } } return ret; }
@Override public Roles getRoles() { Roles ret = new Roles(); if(isSignedIn()) { Set<? extends OSecurityRole> roles = getUser().getRoles(); for (OSecurityRole oRole : roles) { ret.add(oRole.getName()); OSecurityRole parent = oRole.getParentRole(); while(parent!=null && !ret.contains(parent.getName())) { ret.add(parent.getName()); parent = parent.getParentRole(); } } } return ret; }