View Javadoc
1   package org.oxerr.commons.ws.rs.exceptionmapper;
2   
3   import javax.inject.Singleton;
4   import javax.ws.rs.core.Response;
5   import javax.ws.rs.ext.ExceptionMapper;
6   import javax.ws.rs.ext.Provider;
7   
8   /**
9    * Maps {@link SecurityException} to {@link Response}.
10   */
11  @Provider
12  @Singleton
13  public class SecurityExceptionMapper
14  	implements ExceptionMapper<SecurityException> {
15  
16  	/**
17  	 * {@inheritDoc}
18  	 */
19  	@Override
20  	public Response toResponse(SecurityException exception) {
21  		return Response.status(Response.Status.UNAUTHORIZED)
22  			.entity(new ErrorEntity(null, exception.getMessage()))
23  			.build();
24  	}
25  
26  }