Product SiteDocumentation Site

⁠2.5.2. User-defined Security Level

As previously discussed, PicketLink provides a default Level implementation provided by the DefaultLevel type. However, you may want to represent your levels in a different way and using your own type.
To provide your own representation of security levels, you need to create an implementation of the Level interface and then an implementation of a factory. For example:
​public class CustomLevel implements Level {
​	
​    private int level;
​	
​    public CustomLevel(int level) {
​    	this.level = level;
​    }
​	
​    @Override
​    public int compareTo(Level level) {
​        // logic to compare levels
​    }
​}
​
​@PicketLink
​public class CustomLevelFactory implements LevelFactory{
​    @Override
​    public Level createLevel(String level) {
​    	return new CustomLevel(Integer.parseInt(level));
​    }
​}