Class SecurePingResource


  • @Path("ping")
    public class SecurePingResource
    extends Object
    This JAX-RS resource class acts as a HTTP facade for calls to the EJB tier. Declarative encryption and authentication requirements are specified by the web.xml. This class primarily implements the structural URIs and proxies the user calls/responses to/from the EJBs. Note we could have made this a stateless session EJB and added @RolesAllowed to be enfored here. A pure JAX-RS resource class does not honor those declarative annotations.
    • Field Detail

      • logger

        private static final org.slf4j.Logger logger
      • ctx

        @Context
        private javax.ws.rs.core.SecurityContext ctx
      • uriInfo

        @Context
        private javax.ws.rs.core.UriInfo uriInfo
    • Constructor Detail

      • SecurePingResource

        public SecurePingResource()
    • Method Detail

      • whoAmI

        @Path("whoAmI")
        @GET
        @Produces("text/plain")
        public javax.ws.rs.core.Response whoAmI()
      • isCallerInRole

        @Path("roles/{role}")
        @GET
        @Produces("text/plain")
        public javax.ws.rs.core.Response isCallerInRole​(@PathParam("role")
                                                        String role)
      • anonymous

        @Path("unsecured")
        public SecurePingResource.Pinger anonymous()
        This method will return a sub-resource that is the same as the "secure" path except this path is configured to not require any identity or encryption.
        Returns:
      • authenticated

        @Path("secured")
        public SecurePingResource.Pinger authenticated()
        This method returns a sub-resource and will require that sub-resource to be envoked with HTTPS and an authenticated user in either the "admin" or "user" role base on the web.xml.
        Returns:
      • makeExceptionResponse

        private javax.ws.rs.core.Response.ResponseBuilder makeExceptionResponse​(Exception ex)
        This method is used to report an unexpected error condition in the endpoints.
        Parameters:
        ex -
        Returns:
        error message
      • makeResourcePayload

        private PingResult makeResourcePayload​(String ejbResponse)
        This helper method builds a DTO to be marshaled back to the caller.
        Parameters:
        ejbResponse -
        Returns:
        dto filled in