Skip to content

AnnotationProcessor which generates static shiro permission check objects

Notifications You must be signed in to change notification settings

sdorra/shiro-static-permissions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shiro Static Permissions

Build Status Quality Gates Coverage Technical Debt JitPack

Shiro Static Permissions consists of two parts an AnnotationProcessor and a small library. The AnnotationProcessor generates classes for static permission checks with Apache Shrio which allows checks like the following:

// check for repository create permission
if (RepositoryPermissions.create().isPermitted()) {
    // create repository
}

// throw exception if the user lacks create permission
RepositoryPermissions.create().check();

// check for repository 123 delete permission
if (RepositoryPermissions.delete("123").isPermitted()) {
    // delete repository
}

// throw exception if the user lacks delete permission for repository 123
RepositoryPermissions.delete(new Repository("123")).check();

Usage

<dependency>
    <groupId>com.github.sdorra</groupId>
    <artifactId>ssp-lib</artifactId>
    <version>x.y.z</version>
</dependency>

<dependency>
    <groupId>com.github.sdorra</groupId>
    <artifactId>ssp-processor</artifactId>
    <version>x.y.z</version>
    <optional>true</optional>
</dependency>
@StaticPermissions("repositories")
public class Repository implements PermissionObject {

  private final String id;
  
  public Repository(String id) {
    this.id = id;
  }
  
  @Override
  public String getId() {
    return id;
  }

}

Real world example

SCM-Manager: