IllegalTokenExceptionMapper.java

1
/**
2
   Copyright 2018 Carlos Macasaet
3
4
   Licensed under the Apache License, Version 2.0 (the "License");
5
   you may not use this file except in compliance with the License.
6
   You may obtain a copy of the License at
7
8
       https://www.apache.org/licenses/LICENSE-2.0
9
10
   Unless required by applicable law or agreed to in writing, software
11
   distributed under the License is distributed on an "AS IS" BASIS,
12
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
   See the License for the specific language governing permissions and
14
   limitations under the License.
15
 */
16
package com.macasaet.fernet.jaxrs.exception;
17
18
import javax.ws.rs.NotAuthorizedException;
19
import javax.ws.rs.core.Response;
20
import javax.ws.rs.ext.ExceptionMapper;
21
import javax.ws.rs.ext.Provider;
22
23
import com.macasaet.fernet.IllegalTokenException;
24
25
/**
26
 * An {@link ExceptionMapper} that translates Fernet token creation exceptions into HTTP semantics.
27
 *
28
 * <p>Copyright &copy; 2018 Carlos Macasaet.</p>
29
 *
30
 * @author Carlos Macasaet
31
 */
32
@Provider
33
public class IllegalTokenExceptionMapper implements ExceptionMapper<IllegalTokenException> {
34
35
    public Response toResponse(final IllegalTokenException exception) {
36 1 1. toResponse : mutated return of Object value for com/macasaet/fernet/jaxrs/exception/IllegalTokenExceptionMapper::toResponse to ( if (x != null) null else throw new RuntimeException ) → KILLED
        return new NotAuthorizedException("Bearer error=\"invalid_token\", error_description=\"mal-formed token\"").getResponse();
37
    }
38
39
}

Mutations

36

1.1
Location : toResponse
Killed by : com.macasaet.fernet.jersey.example.secretinjection.SecretInjectionIT.verifyInvalidTokenReturnsNotAuthorized(com.macasaet.fernet.jersey.example.secretinjection.SecretInjectionIT)
mutated return of Object value for com/macasaet/fernet/jaxrs/exception/IllegalTokenExceptionMapper::toResponse to ( if (x != null) null else throw new RuntimeException ) → KILLED

Active mutators

Tests examined


Report generated by PIT 1.4.10