Skip to content

sdorra/shiro-static-permissions

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

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:

About

AnnotationProcessor which generates static shiro permission check objects

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published