com.atlassian.jira.jql.permission
Class DefaultClausePermissionHandler

java.lang.Object
  extended by com.atlassian.jira.jql.permission.DefaultClausePermissionHandler
All Implemented Interfaces:
ClausePermissionChecker, ClausePermissionHandler, ClauseSanitiser

public class DefaultClausePermissionHandler
extends Object
implements ClausePermissionHandler

The default implementation of a ClausePermissionHandler. To fulfill the responsibilities of the composite interfaces ClauseSanitiser and ClausePermissionChecker, this class simply holds one reference to each interface, and delegates to those instances.

Since:
v4.0

Field Summary
static DefaultClausePermissionHandler NOOP_CLAUSE_PERMISSION_HANDLER
           
 
Constructor Summary
DefaultClausePermissionHandler(ClausePermissionChecker permissionChecker)
           
DefaultClausePermissionHandler(ClausePermissionChecker permissionChecker, ClauseSanitiser sanitiser)
           
DefaultClausePermissionHandler(ClauseSanitiser sanitiser)
           
 
Method Summary
 boolean equals(Object o)
           
 int hashCode()
           
 boolean hasPermissionToUseClause(com.atlassian.crowd.embedded.api.User user)
          Checks to see that the provided user is able to use the clause.
 boolean hasPermissionToUseClause(com.atlassian.crowd.embedded.api.User searcher, Set<FieldLayout> fieldLayouts)
          Checks to see that the provided user is able to use the clause.
 Clause sanitise(com.atlassian.crowd.embedded.api.User user, TerminalClause clause)
          Given a user and a clause, will return a sanitised clause that when possible will not contain any information that the specified user does not have permission to see.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NOOP_CLAUSE_PERMISSION_HANDLER

public static final DefaultClausePermissionHandler NOOP_CLAUSE_PERMISSION_HANDLER
Constructor Detail

DefaultClausePermissionHandler

public DefaultClausePermissionHandler(ClausePermissionChecker permissionChecker)

DefaultClausePermissionHandler

public DefaultClausePermissionHandler(ClauseSanitiser sanitiser)

DefaultClausePermissionHandler

public DefaultClausePermissionHandler(ClausePermissionChecker permissionChecker,
                                      ClauseSanitiser sanitiser)
Method Detail

hasPermissionToUseClause

public boolean hasPermissionToUseClause(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: ClausePermissionChecker
Checks to see that the provided user is able to use the clause. This may be as simple as determining if the user has permission to see the field that the clause represents.

Specified by:
hasPermissionToUseClause in interface ClausePermissionChecker
Parameters:
user - to check permissions against.
Returns:
true if the user can use this clause, false otherwise.

hasPermissionToUseClause

public boolean hasPermissionToUseClause(com.atlassian.crowd.embedded.api.User searcher,
                                        Set<FieldLayout> fieldLayouts)
Description copied from interface: ClausePermissionChecker
Checks to see that the provided user is able to use the clause. This method provides all the FieldLayouts visible to the given user as a shortcut otherwise individual checkers can end up looking this up dozens or even hundreds of times with causes slow downs in our search (see JRADEV-15665).

Specified by:
hasPermissionToUseClause in interface ClausePermissionChecker
Parameters:
searcher - to check permissions against.
fieldLayouts - The field Layouts available to the given user (value of FieldManager.getVisibleFieldLayouts(User).
Returns:
true if the user can use this clause, false otherwise.

sanitise

public Clause sanitise(com.atlassian.crowd.embedded.api.User user,
                       TerminalClause clause)
Description copied from interface: ClauseSanitiser

Given a user and a clause, will return a sanitised clause that when possible will not contain any information that the specified user does not have permission to see. For example, if the given clause names a project that the user cannot browse, a sanitiser might return a new clause with the name of the project replaced with the id.

It is important that the returned clause is equivalent to the input clause, within the constraints of the permissible clauses for the specified user.

Specified by:
sanitise in interface ClauseSanitiser
Parameters:
user - the user performing the search
clause - the clause to be sanitised
Returns:
the sanitised clause; never null.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2014 Atlassian. All Rights Reserved.