Class AuthorizationPolicyDeployer


  • @Startup
    @ApplicationScoped
    public class AuthorizationPolicyDeployer
    extends Object
    An Uberfire's startup bean that scans the classpath looking for an authorization policy to deploy (a file named security-policy.properties).

    If located, the policy file is loaded and passed along the AuthorizationPolicyStorage. The deployment process is only executed once, so if a policy instance has been already stored then the deployment is left out. The AuthorizationPolicyMarshaller class is used to read and convert the entries defined at the security-policy.properties file into an AuthorizationPolicy instance.

    It is also possible to split the policy into multiple files. The security-policy.properties file is always mandatory as it serves as a marker file. Alongside that file, several security-module-?.properties files can be created. The split mechanism allows either for the provision of just a single full standalone policy file or multiple module files each of them containing different entries. The way those files are defined is always up to the application developer.

    • Constructor Detail

      • AuthorizationPolicyDeployer

        public AuthorizationPolicyDeployer()
      • AuthorizationPolicyDeployer

        @Inject
        public AuthorizationPolicyDeployer​(org.uberfire.backend.authz.AuthorizationPolicyStorage authzPolicyStorage,
                                           org.uberfire.security.authz.PermissionManager permissionManager,
                                           javax.enterprise.event.Event<org.uberfire.backend.events.AuthorizationPolicyDeployedEvent> deployedEvent)
    • Method Detail

      • deployPolicy

        public void deployPolicy()
      • getPolicyDir

        public Path getPolicyDir()
      • deployPolicy

        public void deployPolicy​(Path policyDir)
      • loadPolicy

        public org.uberfire.security.authz.AuthorizationPolicy loadPolicy​(Path policyDir)
      • readPolicyProperties

        public NonEscapedProperties readPolicyProperties​(Path policyDir)
                                                  throws IOException
        Put all the policy files together into a single properties instance.
        Parameters:
        policyDir - The source directory where to read the policy files from.
        Returns:
        An NonEscapedProperties instance containing all the properties read from the policy files found
        Throws:
        IOException - When an IO error occurs reading any of the policy files
      • isPolicyFile

        public boolean isPolicyFile​(Path p)