All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.picketlink.idm.permission.acl.spi.StringPermissionHandler Maven / Gradle / Ivy

There is a newer version: 5.0.0-2013Jan16
Show newest version
package org.picketlink.idm.permission.acl.spi;

import java.io.Serializable;
import java.util.Collections;
import java.util.Set;

/**
 * An extremely trivial permission handler that allows permissions to be assigned to String resources
 *
 * @author Shane Bryzak
 */
public class StringPermissionHandler implements PermissionHandler {
    @Override
    public boolean canHandle(Class resourceClass) {
        return String.class.equals(resourceClass);
    }

    @Override
    public Serializable getIdentifier(Object resource) {
        checkResourceValid(resource);
        return (String) resource;
    }

    @Override
    public Class unwrapResourceClass(Object resource) {
        checkResourceValid(resource);
        return String.class;
    }

    private void checkResourceValid(Object resource) {
        if (!(resource instanceof String)) {
            throw new IllegalArgumentException("Resource [" + resource + "] must be instance of String");
        }
    }

    @Override
    public Set listClassOperations(Class resourceClass) {
        return Collections.emptySet();
    }

    @Override
    public Set listInstanceOperations(Class resourceClass) {
        return Collections.emptySet();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy