Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1425: Prefer specialized RequestMapping annotations #1426

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ApplicationController(ApplicationService applicationService) {
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_ALREADY_EXISTS"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(method = RequestMethod.POST)
@PostMapping
public ObjectResponse<CreateApplicationResponse> createApplication(@Valid @RequestBody ObjectRequest<CreateApplicationRequest> request) throws ApplicationAlreadyExistsException {
logger.info("Received createApplication request, application name: {}", request.getRequestObject().getApplicationName());
final CreateApplicationResponse response = applicationService.createApplication(request.getRequestObject());
Expand All @@ -95,7 +95,7 @@ public ObjectResponse<CreateApplicationResponse> createApplication(@Valid @Reque
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_NOT_FOUND"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(method = RequestMethod.PUT)
@PutMapping
public ObjectResponse<UpdateApplicationResponse> updateApplication(@Valid @RequestBody ObjectRequest<UpdateApplicationRequest> request) throws ApplicationNotFoundException {
logger.info("Received updateApplication request, application name: {}", request.getRequestObject().getApplicationName());
final UpdateApplicationResponse response = applicationService.updateApplication(request.getRequestObject());
Expand All @@ -115,7 +115,7 @@ public ObjectResponse<UpdateApplicationResponse> updateApplication(@Valid @Reque
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_NOT_FOUND"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "update", method = RequestMethod.POST)
@PostMapping("update")
public ObjectResponse<UpdateApplicationResponse> updateApplicationPost(@Valid @RequestBody ObjectRequest<UpdateApplicationRequest> request) throws ApplicationNotFoundException {
logger.info("Received updateApplicationPost request, application name: {}", request.getRequestObject().getApplicationName());
final UpdateApplicationResponse response = applicationService.updateApplication(request.getRequestObject());
Expand All @@ -134,7 +134,7 @@ public ObjectResponse<UpdateApplicationResponse> updateApplicationPost(@Valid @R
@ApiResponse(responseCode = "400", description = "Invalid request"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(method = RequestMethod.GET)
@GetMapping
public ObjectResponse<GetApplicationListResponse> getApplicationList(@RequestParam boolean includeRemoved) {
logger.info("Received getApplicationList request");
GetApplicationListRequest request = new GetApplicationListRequest();
Expand All @@ -155,7 +155,7 @@ public ObjectResponse<GetApplicationListResponse> getApplicationList(@RequestPar
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "list", method = RequestMethod.POST)
@PostMapping("list")
public ObjectResponse<GetApplicationListResponse> getApplicationListPost(@Valid @RequestBody ObjectRequest<GetApplicationListRequest> request) {
logger.info("Received getApplicationListPost request");
final GetApplicationListResponse response = applicationService.getApplicationList(request.getRequestObject());
Expand All @@ -175,7 +175,7 @@ public ObjectResponse<GetApplicationListResponse> getApplicationListPost(@Valid
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_NOT_FOUND"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "delete", method = RequestMethod.POST)
@PostMapping("delete")
public ObjectResponse<DeleteApplicationResponse> deleteApplication(@Valid @RequestBody ObjectRequest<DeleteApplicationRequest> request) throws ApplicationNotFoundException {
logger.info("Received deleteApplication request, application name: {}", request.getRequestObject().getApplicationName());
final DeleteApplicationResponse response = applicationService.deleteApplication(request.getRequestObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public AuthMethodController(AuthMethodService authMethodService) {
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, AUTH_METHOD_ALREADY_EXISTS"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method", method = RequestMethod.POST)
@PostMapping("auth-method")
public ObjectResponse<CreateAuthMethodResponse> createAuthMethod(@Valid @RequestBody ObjectRequest<CreateAuthMethodRequest> request) throws AuthMethodAlreadyExistsException {
logger.info("Received createAuthMethod request, authentication method: {}", request.getRequestObject().getAuthMethod());
final CreateAuthMethodResponse response = authMethodService.createAuthMethod(request.getRequestObject());
Expand All @@ -97,7 +97,7 @@ public ObjectResponse<CreateAuthMethodResponse> createAuthMethod(@Valid @Request
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method", method = RequestMethod.GET)
@GetMapping("auth-method")
public ObjectResponse<GetAuthMethodsResponse> getAuthMethodList() throws InvalidConfigurationException {
logger.info("Received getAuthMethodList request");
final List<AuthMethodDetail> authMethods = authMethodService.listAuthMethods();
Expand All @@ -124,7 +124,7 @@ public ObjectResponse<GetAuthMethodsResponse> getAuthMethodList() throws Invalid
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method/list", method = RequestMethod.POST)
@PostMapping("auth-method/list")
public ObjectResponse<GetAuthMethodsResponse> getAuthMethodListPost(@Valid @RequestBody ObjectRequest<GetAuthMethodListRequest> request) throws InvalidConfigurationException {
logger.info("Received getAuthMethodListPost request");
final List<AuthMethodDetail> authMethods = authMethodService.listAuthMethods();
Expand All @@ -151,7 +151,7 @@ public ObjectResponse<GetAuthMethodsResponse> getAuthMethodListPost(@Valid @Requ
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method", method = RequestMethod.GET)
@GetMapping("user/auth-method")
public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUser(@RequestParam @Nullable @Size(min = 1, max = 256) String userId) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getAuthMethodsEnabledForUser request, user ID: {}", userId);
Expand All @@ -176,7 +176,7 @@ public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUser(@
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/list", method = RequestMethod.POST)
@PostMapping("user/auth-method/list")
public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUserPost(@Valid @RequestBody ObjectRequest<GetUserAuthMethodsRequest> request) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getAuthMethodsEnabledForUserPost request, user ID: {}", request.getRequestObject().getUserId());
Expand Down Expand Up @@ -204,7 +204,7 @@ public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUserPo
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method", method = RequestMethod.POST)
@PostMapping("user/auth-method")
public ObjectResponse<GetUserAuthMethodsResponse> enableAuthMethodForUser(@Valid @RequestBody ObjectRequest<UpdateAuthMethodRequest> request) throws InvalidRequestException, InvalidConfigurationException {
logger.info("Received enableAuthMethodForUser request, user ID: {}, authentication method: {}", request.getRequestObject().getUserId(), request.getRequestObject().getAuthMethod().toString());
final UpdateAuthMethodRequest requestObject = request.getRequestObject();
Expand Down Expand Up @@ -241,7 +241,7 @@ public ObjectResponse<GetUserAuthMethodsResponse> enableAuthMethodForUser(@Valid
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/delete", method = RequestMethod.POST)
@PostMapping("user/auth-method/delete")
public ObjectResponse<GetUserAuthMethodsResponse> disableAuthMethodForUser(@Valid @RequestBody ObjectRequest<UpdateAuthMethodRequest> request) throws InvalidRequestException, InvalidConfigurationException {
return disableAuthMethodForUserImpl(request);
}
Expand Down Expand Up @@ -281,7 +281,7 @@ private ObjectResponse<GetUserAuthMethodsResponse> disableAuthMethodForUserImpl(
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/enabled", method = RequestMethod.GET)
@GetMapping("user/auth-method/enabled")
public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodList(@RequestParam @NotBlank @Size(min = 1, max = 256) String userId, @RequestParam @NotBlank @Size(min = 2, max = 256) String operationName) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getEnabledMethodList request, user ID: {}", userId);
Expand All @@ -305,7 +305,7 @@ public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodList(@Reques
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/enabled/list", method = RequestMethod.POST)
@PostMapping("user/auth-method/enabled/list")
public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodListPost(@Valid @RequestBody ObjectRequest<GetEnabledMethodListRequest> request) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getEnabledMethodListPost request, user ID: {}", request.getRequestObject().getUserId());
Expand All @@ -327,7 +327,7 @@ public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodListPost(@Va
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, AUTH_METHOD_NOT_FOUND, DELETE_NOT_ALLOWED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method/delete", method = RequestMethod.POST)
@PostMapping("auth-method/delete")
public ObjectResponse<DeleteAuthMethodResponse> deleteAuthMethod(@Valid @RequestBody ObjectRequest<DeleteAuthMethodRequest> request) throws AuthMethodNotFoundException, DeleteNotAllowedException {
logger.info("Received deleteAuthMethod request, authentication method: {}", request.getRequestObject().getAuthMethod());
final DeleteAuthMethodResponse response = authMethodService.deleteAuthMethod(request.getRequestObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ public AuthenticationController(AuthenticationService authenticationService) {
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, USER_IDENTITY_NOT_FOUND, OPERATION_NOT_FOUND, CREDENTIAL_NOT_FOUND, CREDENTIAL_DEFINITION_NOT_FOUND, INVALID_CONFIGURATION, OPERATION_ALREADY_FINISHED, OPERATION_ALREADY_CANCELED, OPERATION_ALREADY_FAILED, OPERATION_NOT_VALID, AUTH_METHOD_NOT_FOUND, ENCRYPTION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "credential", method = RequestMethod.POST)
@PostMapping("credential")
public ObjectResponse<CredentialAuthenticationResponse> authenticateWithCredential(@Valid @RequestBody ObjectRequest<CredentialAuthenticationRequest> request) throws InvalidRequestException, UserNotFoundException, OperationNotFoundException, CredentialNotFoundException, CredentialDefinitionNotFoundException, InvalidConfigurationException, OperationAlreadyFinishedException, OperationAlreadyCanceledException, OperationAlreadyFailedException, OperationNotValidException, AuthMethodNotFoundException, EncryptionException {
logger.info("Received authenticateWithCredential request, user ID: {}, operation ID: {}", request.getRequestObject().getUserId(), request.getRequestObject().getOperationId());
final CredentialAuthenticationResponse response = authenticationService.authenticateWithCredential(request.getRequestObject());
Expand Down Expand Up @@ -117,7 +117,7 @@ public ObjectResponse<CredentialAuthenticationResponse> authenticateWithCredenti
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, AUTH_METHOD_NOT_FOUND, OPERATION_ALREADY_FAILED, OPERATION_ALREADY_FINISHED, OPERATION_ALREADY_CANCELED, INVALID_CONFIGURATION, CREDENTIAL_NOT_FOUND, OPERATION_NOT_FOUND, OTP_NOT_FOUND, OPERATION_NOT_VALID, ENCRYPTION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "otp", method = RequestMethod.POST)
@PostMapping("otp")
public ObjectResponse<OtpAuthenticationResponse> authenticateWithOtp(@Valid @RequestBody ObjectRequest<OtpAuthenticationRequest> request) throws InvalidRequestException, AuthMethodNotFoundException, OperationAlreadyFailedException, OperationAlreadyFinishedException, OperationAlreadyCanceledException, InvalidConfigurationException, CredentialNotFoundException, OperationNotFoundException, OtpNotFoundException, OperationNotValidException, EncryptionException {
logger.info("Received authenticateWithOtp request, OTP ID: {}, operation ID: {}", request.getRequestObject().getOtpId(), request.getRequestObject().getOperationId());
final OtpAuthenticationResponse response = authenticationService.authenticateWithOtp(request.getRequestObject());
Expand Down Expand Up @@ -148,7 +148,7 @@ public ObjectResponse<OtpAuthenticationResponse> authenticateWithOtp(@Valid @Req
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, AUTH_METHOD_NOT_FOUND, INVALID_CONFIGURATION, USER_IDENTITY_NOT_FOUND, OPERATION_ALREADY_FINISHED, OPERATION_ALREADY_CANCELED, OPERATION_ALREADY_FAILED, CREDENTIAL_NOT_FOUND, OPERATION_NOT_FOUND, OTP_NOT_FOUND, OPERATION_NOT_VALID, ENCRYPTION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "combined", method = RequestMethod.POST)
@PostMapping("combined")
public ObjectResponse<CombinedAuthenticationResponse> authenticateCombined(@Valid @RequestBody ObjectRequest<CombinedAuthenticationRequest> request) throws InvalidRequestException, AuthMethodNotFoundException, InvalidConfigurationException, UserNotFoundException, OperationAlreadyFinishedException, OperationAlreadyCanceledException, OperationAlreadyFailedException, CredentialNotFoundException, OperationNotFoundException, OtpNotFoundException, OperationNotValidException, EncryptionException {
logger.info("Received authenticateCombined request, user ID: {}, OTP ID: {}, operation ID: {}", request.getRequestObject().getUserId(), request.getRequestObject().getOperationId(), request.getRequestObject().getOtpId());
final CombinedAuthenticationResponse response = authenticationService.authenticateCombined(request.getRequestObject());
Expand Down
Loading