Search in sources :

Example 1 with UserData

use of com.b2international.snowowl.snomed.cis.rest.model.UserData in project snow-owl by b2ihealthcare.

the class CisAuthenticationService method authenticate.

@Operation(summary = "Validates a token, checking if it's assigned to a current session, and retrieves user data.")
@ApiResponses({ @ApiResponse(responseCode = "400", description = "Error"), @ApiResponse(responseCode = "401", description = "Unauthorized") })
@PostMapping(value = "/authenticate")
public UserData authenticate(@Parameter(description = "The security access token.", required = true) @RequestBody Token token) {
    String username = verify(token.getToken());
    if (Strings.isNullOrEmpty(username)) {
        throw new UnauthorizedException("Token does not validate.");
    } else {
        final UserData userData = new UserData();
        userData.setUsername(username);
        return userData;
    }
}
Also used : UserData(com.b2international.snowowl.snomed.cis.rest.model.UserData) UnauthorizedException(com.b2international.commons.exceptions.UnauthorizedException) PostMapping(org.springframework.web.bind.annotation.PostMapping) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

UnauthorizedException (com.b2international.commons.exceptions.UnauthorizedException)1 UserData (com.b2international.snowowl.snomed.cis.rest.model.UserData)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1