|
| 1 | +package org.brapi.test.BrAPITestServer.auth.oldTokens; |
| 2 | + |
| 3 | +import io.swagger.model.core.ServerInfoResponse; |
| 4 | +import io.swagger.annotations.ApiOperation; |
| 5 | +import io.swagger.annotations.ApiResponse; |
| 6 | +import io.swagger.annotations.ApiResponses; |
| 7 | +import io.swagger.annotations.Authorization; |
| 8 | +import org.brapi.test.BrAPITestServer.controller.core.BrAPIController; |
| 9 | +import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException; |
| 10 | +import org.slf4j.Logger; |
| 11 | +import org.slf4j.LoggerFactory; |
| 12 | +import org.springframework.http.HttpStatus; |
| 13 | +import org.springframework.http.ResponseEntity; |
| 14 | +import org.springframework.stereotype.Controller; |
| 15 | +import org.springframework.web.bind.annotation.CrossOrigin; |
| 16 | +import org.springframework.web.bind.annotation.RequestBody; |
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 18 | +import org.springframework.web.bind.annotation.RequestMethod; |
| 19 | + |
| 20 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 21 | + |
| 22 | +import javax.servlet.http.HttpServletRequest; |
| 23 | + |
| 24 | +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]") |
| 25 | +@Controller |
| 26 | +public class TokenController extends BrAPIController { |
| 27 | + |
| 28 | + private static final Logger log = LoggerFactory.getLogger(TokenController.class); |
| 29 | + |
| 30 | + private final HttpServletRequest request; |
| 31 | + |
| 32 | + @org.springframework.beans.factory.annotation.Autowired |
| 33 | + public TokenController(HttpServletRequest request) { |
| 34 | + this.request = request; |
| 35 | + } |
| 36 | + |
| 37 | + @ApiOperation(value = "Get the list of implemented Calls", nickname = "tokenPost", response = ServerInfoResponse.class, authorizations = { |
| 38 | + @Authorization(value = "AuthorizationToken") }, tags = { "Server Info", }) |
| 39 | + @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ServerInfoResponse.class), |
| 40 | + @ApiResponse(code = 400, message = "Bad Request", response = String.class), |
| 41 | + @ApiResponse(code = 401, message = "Unauthorized", response = String.class), |
| 42 | + @ApiResponse(code = 403, message = "Forbidden", response = String.class) }) |
| 43 | + @RequestMapping(value = "/token", produces = { "application/json" }, method = RequestMethod.POST) |
| 44 | + @CrossOrigin |
| 45 | + public ResponseEntity<TokenResponse> tokenPost(@RequestBody TokenRequest body) |
| 46 | + throws BrAPIServerException { |
| 47 | + |
| 48 | + log.debug("Request: " + request.getRequestURI()); |
| 49 | + validateSecurityContext(request, "ROLE_ANONYMOUS", "ROLE_USER"); |
| 50 | + validateAcceptHeader(request); |
| 51 | + |
| 52 | + return new ResponseEntity<TokenResponse>(new TokenResponse(), HttpStatus.OK); |
| 53 | + } |
| 54 | + |
| 55 | + private class TokenResponse{ |
| 56 | + @JsonProperty("access_token") |
| 57 | + private final String accessToken = "YYYY"; |
| 58 | + } |
| 59 | +} |
0 commit comments