Example usage for javax.security.sasl AuthenticationException getMessage

List of usage examples for javax.security.sasl AuthenticationException getMessage

Introduction

In this page you can find the example usage for javax.security.sasl AuthenticationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.jevis.rest.services.AttributeService.java

/**
 * Returns an list of all attributes under the given JEVisClass
 *
 * @param context/*from   www . ja va  2  s .c  o  m*/
 * @param httpHeaders
 * @param id
 * @return
 * @throws JEVisException
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAll(@Context HttpHeaders httpHeaders, @PathParam("id") long id) {

    JEVisDataSource ds = null;
    try {
        Logger.getLogger(AttributeService.class.getName()).log(Level.INFO, "GET Attributes for Object: " + id);

        ds = Config.getJEVisDS(httpHeaders);

        JEVisObject obj = ds.getObject(id);
        if (obj == null) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        List<JsonAttribute> atts = JsonFactory.buildAttributes(obj.getAttributes());
        JsonAttribute[] returnList = atts.toArray(new JsonAttribute[atts.size()]);

        return Response.ok(returnList).build();
    } catch (JEVisException jex) {
        return Response.serverError().entity(ExceptionUtils.getStackTrace(jex)).build();
    } catch (AuthenticationException ex) {
        return Response.status(Response.Status.UNAUTHORIZED).entity(ex.getMessage()).build();
    } finally {
        Config.CloseDS(ds);
    }
}

From source file:org.jevis.rest.services.AttributeService.java

/**
 * Returns an specific attribute/*from   w  ww. j a  v  a 2s.  c  o  m*/
 *
 * @param context
 * @param httpHeaders
 * @param id
 * @param attribute
 * @return
 * @throws JEVisException
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{attribute}")
public Response getAttribute(@Context HttpHeaders httpHeaders, @PathParam("id") long id,
        @PathParam("attribute") String attribute) throws JEVisException {
    System.out.println("getAttribute: " + attribute);

    JEVisDataSource ds = null;
    try {
        Logger.getLogger(AttributeService.class.getName()).log(Level.INFO,
                "GET Attribute " + attribute + "for Object: " + id);
        ds = Config.getJEVisDS(httpHeaders);

        JEVisObject obj = ds.getObject(id);
        JsonAttribute att = JsonFactory.buildAttribute(obj.getAttribute(attribute));

        return Response.ok(att).build();

    } catch (JEVisException jex) {
        return Response.serverError().entity(ExceptionUtils.getStackTrace(jex)).build();
    } catch (AuthenticationException ex) {
        return Response.status(Response.Status.UNAUTHORIZED).entity(ex.getMessage()).build();
    } finally {
        Config.CloseDS(ds);
    }

}