Declarative Security
Application Platform enables you to add declarative security to POJOs that are published as OSGi services by using the @Service annotation. To add security to POJOs that are published as OSGi services, you can use the @Secure annotation, together with a set of common Java EE security annotations. Application Platform supports the following common Java EE security annotations, which you can use at the class or method level:
@DenyAll @PermitAll @RolesAllowed The following sample code shows an implementation of declarative security in an OSGi service. The @Secure annotation indicates that the AdderService service is secure. By default, invocation of the service methods is denied with the @DenyAll annotation. The @RolesAllowed annotation allows invocation of the add method by users with Admin or Developer role.
@Service
@Secure
@DenyAll
public class AdderService {
@RolesAllowed({"Admin", "Developer"})
public float add(float x, float y) {
return x + y;
}
}