public Role getRole(String roleId) throws NoSuchRoleException { for (Role role : this.listRoles()) { if (role.getRoleId().equals(roleId)) { return role; } } throw new NoSuchRoleException("Role '" + roleId + "' not found."); }
/** * Removes a security role. * * @param roleId Id of the role to be removed. */ @Override @DELETE @ResourceMethodSignature(pathParams = {@PathParam("roleId")}) public void delete(Context context, Request request, Response response) throws ResourceException { try { AuthorizationManager authzManager = getSecuritySystem().getAuthorizationManager(ROLE_SOURCE); authzManager.deleteRole(getRoleId(request)); } catch (NoSuchRoleException e) { throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e.getMessage()); } catch (NoSuchAuthorizationManagerException e) { this.getLogger().warn("Could not found AuthorizationManager: " + ROLE_SOURCE, e); // we should not ever get here throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Authorization Manager for: " + ROLE_SOURCE + " could not be found."); } }
/** * Removes a security role. * * @param roleId Id of the role to be removed. */ @Override @DELETE @ResourceMethodSignature( pathParams = { @PathParam( "roleId" ) } ) public void delete( Context context, Request request, Response response ) throws ResourceException { try { AuthorizationManager authzManager = getSecuritySystem().getAuthorizationManager( ROLE_SOURCE ); authzManager.deleteRole( getRoleId( request ) ); } catch ( NoSuchRoleException e ) { throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND, e.getMessage() ); } catch ( NoSuchAuthorizationManagerException e ) { this.getLogger().warn( "Could not found AuthorizationManager: " + ROLE_SOURCE, e ); // we should not ever get here throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Authorization Manager for: " + ROLE_SOURCE + " could not be found." ); } }
public Role getRole( String roleId ) throws NoSuchRoleException { for ( Role role : this.listRoles() ) { if ( role.getRoleId().equals( roleId ) ) { return role; } } throw new NoSuchRoleException( "Role '" + roleId + "' not found." ); }
/** * Returns the request security role. * * @param roleId Id of the role. */ @Override @GET @ResourceMethodSignature(output = RoleResourceResponse.class, pathParams = {@PathParam("roleId")}) public Object get(Context context, Request request, Response response, Variant variant) throws ResourceException { RoleResourceResponse result = new RoleResourceResponse(); try { AuthorizationManager authzManager = getSecuritySystem().getAuthorizationManager(ROLE_SOURCE); result.setData(securityToRestModel(authzManager.getRole(getRoleId(request)), request, false)); } catch (NoSuchRoleException e) { throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e.getMessage()); } catch (NoSuchAuthorizationManagerException e) { this.getLogger().warn("Could not found AuthorizationManager: " + ROLE_SOURCE, e); // we should not ever get here throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Authorization Manager for: " + ROLE_SOURCE + " could not be found."); } return result; }
public CRole readRole( String id ) throws NoSuchRoleException { CRole role = getConfiguration().getRoleById( id ); if ( role != null ) { return role; } else { throw new NoSuchRoleException( id ); } }
/** * Returns the request security role. * * @param roleId Id of the role. */ @Override @GET @ResourceMethodSignature( output = RoleResourceResponse.class, pathParams = { @PathParam( "roleId" ) } ) public Object get( Context context, Request request, Response response, Variant variant ) throws ResourceException { RoleResourceResponse result = new RoleResourceResponse(); try { AuthorizationManager authzManager = getSecuritySystem().getAuthorizationManager( ROLE_SOURCE ); result.setData( securityToRestModel( authzManager.getRole( getRoleId( request ) ), request, false ) ); } catch ( NoSuchRoleException e ) { throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND, e.getMessage() ); } catch ( NoSuchAuthorizationManagerException e ) { this.getLogger().warn( "Could not found AuthorizationManager: " + ROLE_SOURCE, e ); // we should not ever get here throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Authorization Manager for: " + ROLE_SOURCE + " could not be found." ); } return result; }
@Override public Role getRole(String roleId) throws NoSuchRoleException { try { String roleName = this.ldapManager.getGroupName(roleId); if (roleName == null) { throw new NoSuchRoleException("Role: " + roleId + " was not found in LDAP."); } Role role = new Role(); role.setName(roleId); role.setRoleId(roleId); role.setSource(this.getSource()); return role; } catch (LdapDAOException e) { throw new NoSuchRoleException("Role: " + roleId + " was not found in LDAP.", e); } catch (NoSuchLdapGroupException e) { throw new NoSuchRoleException("Role: " + roleId + " was not found in LDAP.", e); } }
throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND, e.getMessage() );
public Role getRole( String roleId ) throws NoSuchRoleException { try { String roleName = this.ldapManager.getGroupName( roleId ); if ( roleName == null ) { throw new NoSuchRoleException( "Role: " + roleId + " was not found in LDAP." ); } Role role = new Role(); role.setName( roleId ); role.setRoleId( roleId ); role.setSource( this.getSource() ); return role; } catch ( LdapDAOException e ) { throw new NoSuchRoleException( "Role: " + roleId + " was not found in LDAP.", e ); } catch ( NoSuchLdapGroupException e ) { throw new NoSuchRoleException( "Role: " + roleId + " was not found in LDAP.", e ); } }
throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e.getMessage());
protected void deleteRole( String id, boolean clean ) throws NoSuchRoleException { boolean found = getConfiguration().removeRoleById( id ); if ( !found ) { throw new NoSuchRoleException( id ); } if ( clean ) { cleanRemovedRole( id ); } }
public Role getRole( String roleId ) throws NoSuchRoleException { if ( this.getPlexusRoleLocator() == null ) { this.logger.warn( "LegacyAuthorizationManager is not configured, it should be removed." ); throw new NoSuchRoleException( "LegacyAuthorizationManager is not configured, it should be removed." ); } for ( PlexusRole plexusRole : this.getPlexusRoleLocator().listRoles() ) { return this.toRole( plexusRole ); } throw new NoSuchRoleException( "Failed to find role :" + roleId + " from legacy PlexusRoleLocator: " + this.getPlexusRoleLocator().getSource() ); }