Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Fabric3 includes an extensible security framework that implements authentication and authorization. Authentication is typically specified as a policy intent on a binding part of binding (remote communications) configuration to perform client, server, or mutual authentication. When a client is authenticated, a security subject is associated with messages sent by the client. This security subject can then be used to authorize access to service operations based on roles.

Info

The bindings chapters contain examples of how to configure authentication since specifics vary by binding type.

The security provider varies by runtime. The Standalone, Maven, and Ant runtimes are configured by default to use a basic security provider. The Tomcat runtime is configured with a provider that delegates to Tomcat security realms. There Similarly, the WebLogic runtime delegates to WebLogic's security infrastructure.

Note there is also a Fabric3 extension that uses Spring Security, which can be installed in any of the Fabric3 runtimes.

Using Authentication and Authorization in Application Code

Authentication is typically enabled on a binding configuration. Please refer to the binding chapters for specific examples.

The Fabric3 API includes the org.fabric3.api.annotation.security.RolesAllowed annotation, which is used to specify roles required to execute a portion of code. The RolesAllowed annotation can be placed on a method or class (in which case it will be applied to all methods contained in the class) to restrict access to security subjects with certain roles as follows:

...


import org.fabric3.api.annotation.security.RolesAllowed;

public class SecureRolesServiceImpl implements SecureService {

   @RolesAllowed({"role1", "role2"})
   public void call() \{
      // ...
   }
}

Note that the current security subject can be injected using the SCA @Context annotation on a field or setter method that takes the SCA RequestContext type. Alternatively, additional security information including roles can be accessed by using the org.fabric3.api.Fabric3RequestContext type in place of the SCA RequestContext type.

...

.

...