Skip to content

Commit

Permalink
Merge pull request #2292 from constantine2nd/develop
Browse files Browse the repository at this point in the history
A few tweaks
  • Loading branch information
simonredfern authored Oct 13, 2023
2 parents c771333 + 9ed77a4 commit 13a07f4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 27 deletions.
2 changes: 1 addition & 1 deletion obp-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
<dependency>
<groupId>org.iban4j</groupId>
<artifactId>iban4j</artifactId>
<version>3.2.3-RELEASE</version>
<version>3.2.7-RELEASE</version>
</dependency>

<!--macro cache-->
Expand Down
3 changes: 3 additions & 0 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -1257,3 +1257,6 @@ show_ip_address_change_warning=false

#the default expected Open Futures Per Service for the BackOffFactor parameter
expectedOpenFuturesPerService=100

# Enable /Disable IBAN validation
validate_iban=false
6 changes: 3 additions & 3 deletions obp-api/src/main/scala/code/api/util/ConsentUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,9 @@ object Consent {
val jsonWebTokenAsCaseClass: Box[ConsentJWT] = JwtUtil.getSignedPayloadAsJson(consent.jsonWebToken)
.map(parse(_).extract[ConsentJWT])
jsonWebTokenAsCaseClass match {
case Full(consentJWT) => consentJWT.entitlements.exists(_.bank_id.isEmpty()) // System roles
case Full(consentJWT) => consentJWT.entitlements.map(_.bank_id).contains(bankId.value) // Bank level roles
case Full(consentJWT) => consentJWT.views.map(_.bank_id).contains(bankId.value)
case Full(consentJWT) if consentJWT.entitlements.exists(_.bank_id.isEmpty()) => true// System roles
case Full(consentJWT) if consentJWT.entitlements.map(_.bank_id).contains(bankId.value) => true // Bank level roles
case Full(consentJWT) if consentJWT.views.map(_.bank_id).contains(bankId.value) => true
case _ => false
}
}
Expand Down
23 changes: 14 additions & 9 deletions obp-api/src/main/scala/code/api/v2_1_0/APIMethods210.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,28 @@ trait APIMethods210 {
UserHasMissingRoles,
UnknownError
),
List(apiTagSandbox, apiTagOldStyle),
List(apiTagSandbox),
Some(List(canCreateSandbox)))


lazy val sandboxDataImport: OBPEndpoint = {
// Import data into the sandbox
case "sandbox" :: "data-import" :: Nil JsonPost json -> _ => {
cc =>
cc => implicit val ec = EndpointContext(Some(cc))
for {
importData <- tryo {json.extract[SandboxDataImport]} ?~! {InvalidJsonFormat}
u <- cc.user ?~! UserNotLoggedIn
allowDataImportProp <- APIUtil.getPropsValue("allow_sandbox_data_import") ~> APIFailure(DataImportDisabled, 403)
_ <- Helper.booleanToBox(allowDataImportProp == "true") ~> APIFailure(DataImportDisabled, 403)
_ <- NewStyle.function.ownEntitlement("", u.userId, canCreateSandbox, cc.callContext)
_ <- OBPDataImport.importer.vend.importData(importData)
(Full(u), callContext) <- authenticatedAccess(cc)
importData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $SandboxDataImport ", 400, cc.callContext) {
json.extract[SandboxDataImport]
}
_ <- Helper.booleanToFuture(s"$DataImportDisabled", 403, callContext) {
APIUtil.getPropsAsBoolValue("allow_sandbox_data_import", defaultValue = false)
}
_ <- NewStyle.function.hasEntitlement("", u.userId, canCreateSandbox, cc.callContext)
_ <- Helper.booleanToFuture(s"Cannot import the sandbox data", 400, callContext) {
OBPDataImport.importer.vend.importData(importData).isDefined
}
} yield {
successJsonResponse(Extraction.decompose(successMessage), 201)
(successMessage, HttpCode.`201`(callContext))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,26 @@ object LocalMappedConnector extends Connector with MdcLoggable {
import org.iban4j.InvalidCheckDigitException
import org.iban4j.UnsupportedCountryException

// Validate Iban
try { // 1st try
IbanUtil.validate(iban) // IBAN as String: "DE89370400440532013000"
(Full(IbanChecker(true, None)), callContext) // valid
} catch {
case error@(_: IbanFormatException | _: InvalidCheckDigitException | _: UnsupportedCountryException) =>
// invalid
try { // 2nd try
IbanUtil.validate(iban, IbanFormat.Default) // IBAN as formatted String: "DE89 3704 0044 0532 0130 00"
(Full(IbanChecker(true, None)), callContext) // valid
} catch {
case error@(_: IbanFormatException | _: InvalidCheckDigitException | _: UnsupportedCountryException) =>
(Full(IbanChecker(false, None)), callContext) // invalid
}
if(getPropsAsBoolValue("validate_iban", false)) {
// Validate Iban
try { // 1st try
IbanUtil.validate(iban) // IBAN as String: "DE89370400440532013000"
(Full(IbanChecker(true, None)), callContext) // valid
} catch {
case error@(_: IbanFormatException | _: InvalidCheckDigitException | _: UnsupportedCountryException) =>
// invalid
try { // 2nd try
IbanUtil.validate(iban, IbanFormat.Default) // IBAN as formatted String: "DE89 3704 0044 0532 0130 00"
(Full(IbanChecker(true, None)), callContext) // valid
} catch {
case error@(_: IbanFormatException | _: InvalidCheckDigitException | _: UnsupportedCountryException) =>
(Full(IbanChecker(false, None)), callContext) // invalid
}
}
} else {
(Full(IbanChecker(true, None)), callContext)
}

}

// Gets current challenge level for transaction request
Expand Down

0 comments on commit 13a07f4

Please sign in to comment.