Skip to content

Commit

Permalink
Rename hasRole() to allowsProcedureWith()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mats-SX committed Aug 31, 2016
1 parent 00bb8f3 commit 63ff323
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Expand Up @@ -586,7 +586,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional


override def callReadOnlyProcedure(name: QualifiedProcedureName, args: Seq[Any], allowed: String) = { override def callReadOnlyProcedure(name: QualifiedProcedureName, args: Seq[Any], allowed: String) = {
val revertable = transactionalContext.accessMode match { val revertable = transactionalContext.accessMode match {
case a: AuthSubject if a.hasRole(allowed) => case a: AuthSubject if a.allowsProcedureWith(allowed) =>
Some(transactionalContext.restrictCurrentTransaction(AccessMode.Static.OVERRIDE_READ)) Some(transactionalContext.restrictCurrentTransaction(AccessMode.Static.OVERRIDE_READ))
case _ => None case _ => None
} }
Expand All @@ -595,7 +595,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional


override def callReadWriteProcedure(name: QualifiedProcedureName, args: Seq[Any], allowed: String) = { override def callReadWriteProcedure(name: QualifiedProcedureName, args: Seq[Any], allowed: String) = {
val revertable = transactionalContext.accessMode match { val revertable = transactionalContext.accessMode match {
case a: AuthSubject if a.hasRole(allowed) => case a: AuthSubject if a.allowsProcedureWith(allowed) =>
Some(transactionalContext.restrictCurrentTransaction(AccessMode.Static.OVERRIDE_WRITE)) Some(transactionalContext.restrictCurrentTransaction(AccessMode.Static.OVERRIDE_WRITE))
case _ => None case _ => None
} }
Expand All @@ -606,7 +606,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional


override def callSchemaWriteProcedure(name: QualifiedProcedureName, args: Seq[Any], allowed: String) = { override def callSchemaWriteProcedure(name: QualifiedProcedureName, args: Seq[Any], allowed: String) = {
val revertable = transactionalContext.accessMode match { val revertable = transactionalContext.accessMode match {
case a: AuthSubject if a.hasRole(allowed) => case a: AuthSubject if a.allowsProcedureWith(allowed) =>
Some(transactionalContext.restrictCurrentTransaction(AccessMode.Static.OVERRIDE_SCHEMA)) Some(transactionalContext.restrictCurrentTransaction(AccessMode.Static.OVERRIDE_SCHEMA))
case _ => None case _ => None
} }
Expand Down
Expand Up @@ -39,7 +39,13 @@ public interface AuthSubject extends AccessMode
*/ */
void setPassword( String password ) throws IOException, InvalidArgumentsException; void setPassword( String password ) throws IOException, InvalidArgumentsException;


boolean hasRole( String roleName ) throws InvalidArgumentsException; /**
* Determines whether this subject is allowed to execute a procedure with the parameter string in its procedure annotation.
* @param roleName
* @return
* @throws InvalidArgumentsException
*/
boolean allowsProcedureWith( String roleName ) throws InvalidArgumentsException;


/** /**
* Implementation to use when authentication has not yet been performed. Allows nothing. * Implementation to use when authentication has not yet been performed. Allows nothing.
Expand All @@ -64,7 +70,7 @@ public void setPassword( String password ) throws IOException, InvalidArgumentsE
} }


@Override @Override
public boolean hasRole( String roleName ) public boolean allowsProcedureWith( String roleName )
{ {
return false; return false;
} }
Expand Down Expand Up @@ -164,7 +170,7 @@ public void setPassword( String password ) throws IOException, InvalidArgumentsE
} }


@Override @Override
public boolean hasRole( String roleName ) public boolean allowsProcedureWith( String roleName )
{ {
return true; return true;
} }
Expand Down
Expand Up @@ -98,7 +98,7 @@ public void setPassword( String password ) throws IOException, InvalidArgumentsE
} }


@Override @Override
public boolean hasRole( String roleName ) public boolean allowsProcedureWith( String roleName )
{ {
return false; return false;
} }
Expand Down
Expand Up @@ -76,7 +76,7 @@ public void setPassword( String password ) throws IOException, InvalidArgumentsE
} }


@Override @Override
public boolean hasRole( String roleName ) throws InvalidArgumentsException public boolean allowsProcedureWith( String roleName ) throws InvalidArgumentsException
{ {
return getUserManager().getRoleNamesForUser( name() ).contains( roleName ); return getUserManager().getRoleNamesForUser( name() ).contains( roleName );
} }
Expand Down

0 comments on commit 63ff323

Please sign in to comment.