mirror of
https://github.com/valitydev/anapi-v2.git
synced 2024-11-06 08:35:19 +00:00
Cleanup
This commit is contained in:
parent
b4070bd5d4
commit
ce482e96d3
2
pom.xml
2
pom.xml
@ -74,7 +74,7 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>magista-proto</artifactId>
|
||||
<version>SNAPSHOT</version>
|
||||
<version>1.18-e470bc7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
|
@ -2,7 +2,6 @@ package com.rbkmoney.anapi.v2;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
|
||||
@ServletComponentScan
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.rbkmoney.anapi.v2.controller;
|
||||
|
||||
import com.rbkmoney.anapi.v2.exception.AuthorizationException;
|
||||
import com.rbkmoney.anapi.v2.exception.BadRequestException;
|
||||
import com.rbkmoney.anapi.v2.exception.DeadlineException;
|
||||
import com.rbkmoney.openapi.anapi_v2.model.DefaultLogicError;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
@ -63,6 +65,18 @@ public class ErrorControllerAdvice {
|
||||
.message(e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler({AccessDeniedException.class})
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public void handleAccessDeniedException(AccessDeniedException e) {
|
||||
log.warn("<- Res [403]: Request denied access", e);
|
||||
}
|
||||
|
||||
@ExceptionHandler({AuthorizationException.class})
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public void handleAccessDeniedException(AuthorizationException e) {
|
||||
log.warn("<- Res [403]: Request denied access", e);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public void handleException(Exception e) {
|
||||
|
@ -74,6 +74,7 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
@Min(1L) @Valid Long paymentAmountTo,
|
||||
@Valid List<String> excludedShops,
|
||||
@Valid String continuationToken) {
|
||||
log.info("-> Req: xRequestID={}", xRequestID);
|
||||
checkDeadline(xRequestDeadline, xRequestID);
|
||||
shopIDs = accessService
|
||||
.getAccessibleShops("searchPayments", partyID, merge(shopID, shopIDs), paymentInstitutionRealm);
|
||||
@ -105,6 +106,7 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
excludedShops,
|
||||
continuationToken);
|
||||
InlineResponse20010 response = searchService.findPayments(query);
|
||||
log.info("<- Res [200]: xRequestID={}", xRequestID);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@ -118,7 +120,8 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
@Size(min = 1, max = 40) @Valid String shopID,
|
||||
@Valid List<String> shopIDs,
|
||||
@Valid String paymentInstitutionRealm,
|
||||
@Min(0L) @Valid Integer offset,
|
||||
//Not used by magista
|
||||
@Min(0L) @Valid @Deprecated Integer offset,
|
||||
@Size(min = 1, max = 40) @Valid String invoiceID,
|
||||
@Size(min = 1, max = 40) @Valid String paymentID,
|
||||
@Size(min = 1, max = 40) @Valid String chargebackID,
|
||||
@ -126,6 +129,7 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
@Valid List<String> chargebackStages,
|
||||
@Valid List<String> chargebackCategories,
|
||||
@Valid String continuationToken) {
|
||||
log.info("-> Req: xRequestID={}", xRequestID);
|
||||
checkDeadline(xRequestDeadline, xRequestID);
|
||||
shopIDs = accessService
|
||||
.getAccessibleShops("searchChargebacks", partyID, merge(shopID, shopIDs), paymentInstitutionRealm);
|
||||
@ -143,6 +147,7 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
continuationToken);
|
||||
InlineResponse2008 response = searchService
|
||||
.findChargebacks(query);
|
||||
log.info("<- Res [200]: xRequestID={}", xRequestID);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@ -162,8 +167,10 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
@Size(min = 1, max = 40) @Valid String externalID,
|
||||
@Min(1L) @Valid Long invoiceAmountFrom,
|
||||
@Min(1L) @Valid Long invoiceAmountTo,
|
||||
@Valid List<String> excludedShops,
|
||||
//Not used by magista
|
||||
@Valid @Deprecated List<String> excludedShops,
|
||||
@Valid String continuationToken) {
|
||||
log.info("-> Req: xRequestID={}", xRequestID);
|
||||
checkDeadline(xRequestDeadline, xRequestID);
|
||||
shopIDs = accessService
|
||||
.getAccessibleShops("searchInvoices", partyID, merge(shopID, shopIDs), paymentInstitutionRealm);
|
||||
@ -180,6 +187,7 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
invoiceAmountTo,
|
||||
continuationToken);
|
||||
InlineResponse2009 response = searchService.findInvoices(query);
|
||||
log.info("<- Res [200]: xRequestID={}", xRequestID);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@ -193,11 +201,14 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
@Size(min = 1, max = 40) @Valid String shopID,
|
||||
@Valid List<String> shopIDs,
|
||||
@Valid String paymentInstitutionRealm,
|
||||
@Min(0L) @Valid Integer offset,
|
||||
//Not used by magista
|
||||
@Min(0L) @Valid @Deprecated Integer offset,
|
||||
@Size(min = 1, max = 40) @Valid String payoutID,
|
||||
@Valid String payoutToolType,
|
||||
@Valid List<String> excludedShops,
|
||||
//Not used by magista
|
||||
@Valid @Deprecated List<String> excludedShops,
|
||||
@Valid String continuationToken) {
|
||||
log.info("-> Req: xRequestID={}", xRequestID);
|
||||
checkDeadline(xRequestDeadline, xRequestID);
|
||||
shopIDs = accessService
|
||||
.getAccessibleShops("searchPayouts", partyID, merge(shopID, shopIDs), paymentInstitutionRealm);
|
||||
@ -210,6 +221,7 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
payoutToolType,
|
||||
continuationToken);
|
||||
InlineResponse20011 response = searchService.findPayouts(query);
|
||||
log.info("<- Res [200]: xRequestID={}", xRequestID);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@ -223,15 +235,18 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
@Size(min = 1, max = 40) @Valid String shopID,
|
||||
@Valid List<String> shopIDs,
|
||||
@Valid String paymentInstitutionRealm,
|
||||
@Min(0L) @Valid Integer offset,
|
||||
//Not used by magista
|
||||
@Min(0L) @Valid @Deprecated Integer offset,
|
||||
@Valid List<String> invoiceIDs,
|
||||
@Size(min = 1, max = 40) @Valid String invoiceID,
|
||||
@Size(min = 1, max = 40) @Valid String paymentID,
|
||||
@Size(min = 1, max = 40) @Valid String refundID,
|
||||
@Size(min = 1, max = 40) @Valid String externalID,
|
||||
@Valid String refundStatus,
|
||||
@Valid List<String> excludedShops,
|
||||
//Not used by magista
|
||||
@Valid @Deprecated List<String> excludedShops,
|
||||
@Valid String continuationToken) {
|
||||
log.info("-> Req: xRequestID={}", xRequestID);
|
||||
checkDeadline(xRequestDeadline, xRequestID);
|
||||
shopIDs = accessService
|
||||
.getAccessibleShops("searchRefunds", partyID, merge(shopID, shopIDs), paymentInstitutionRealm);
|
||||
@ -248,6 +263,7 @@ public class SearchController implements PaymentsApi, ChargebacksApi, InvoicesAp
|
||||
refundStatus,
|
||||
continuationToken);
|
||||
InlineResponse20012 response = searchService.findRefunds(query);
|
||||
log.info("<- Res [200]: xRequestID={}", xRequestID);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ public class AccessService {
|
||||
}
|
||||
|
||||
return new ArrayList<>(shopIds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private AnapiBouncerContext buildAnapiBouncerContext(String operationId, String partyId, List<String> shopIds) {
|
||||
|
@ -17,15 +17,15 @@ public class VortigonService {
|
||||
|
||||
@SneakyThrows
|
||||
public List<String> getShopIds(String partyId, String realm) {
|
||||
return vortigonClient.getShopsIds(partyId, mapToRealm(realm));
|
||||
return vortigonClient.getShopsIds(partyId, mapRealm(realm));
|
||||
}
|
||||
|
||||
private PaymentInstitutionRealm mapToRealm(String realm) {
|
||||
return switch (realm) {
|
||||
case "live" -> PaymentInstitutionRealm.live;
|
||||
case "test" -> PaymentInstitutionRealm.test;
|
||||
default -> throw new BadRequestException(
|
||||
private PaymentInstitutionRealm mapRealm(String realm) {
|
||||
try {
|
||||
return PaymentInstitutionRealm.valueOf(realm);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadRequestException(
|
||||
String.format("Realm %s cannot be processed", realm));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ management:
|
||||
|
||||
service:
|
||||
magista:
|
||||
url: http://magista:8022/stat
|
||||
url: http://localhost:8022/change_it
|
||||
networkTimeout: 5000
|
||||
vortigon:
|
||||
url: http://hellgate:8022/v1/processing/partymgmt
|
||||
url: http://localhost:8022/change_it
|
||||
networkTimeout: 5000
|
||||
orgManagement:
|
||||
url: http://localhost:8022/change_it
|
||||
|
@ -10,9 +10,6 @@ import java.security.PrivateKey;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @since 04.07.17
|
||||
**/
|
||||
public class JwtTokenBuilder {
|
||||
|
||||
public static final String DEFAULT_USERNAME = "Darth Vader";
|
||||
@ -38,18 +35,6 @@ public class JwtTokenBuilder {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String generateJwtWithRoles(String issuer, String... roles) {
|
||||
long iat = Instant.now().getEpochSecond();
|
||||
long exp = iat + 60 * 10;
|
||||
|
@ -29,10 +29,6 @@ public abstract class AbstractKeycloakOpenIdAsWiremockConfig {
|
||||
keycloakOpenIdStub.givenStub();
|
||||
}
|
||||
|
||||
protected String generateJwt(long iat, long exp, String... roles) {
|
||||
return keycloakOpenIdStub.generateJwt(iat, exp, roles);
|
||||
}
|
||||
|
||||
protected String generateInvoicesReadJwt() {
|
||||
return keycloakOpenIdStub.generateJwt("invoices:read");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user