Props.get replaced with APIUtil.getPropsValue

This commit is contained in:
constantine2nd 2018-03-06 16:22:08 +01:00
parent b960d556ef
commit d401bb0911
55 changed files with 281 additions and 291 deletions

View File

@ -160,7 +160,7 @@ class Boot extends MdcLoggable {
if (!DB.jndiJdbcConnAvailable_?) {
val driver =
Props.mode match {
case Props.RunModes.Production | Props.RunModes.Staging | Props.RunModes.Development => Props.get("db.driver") openOr "org.h2.Driver"
case Props.RunModes.Production | Props.RunModes.Staging | Props.RunModes.Development => APIUtil.getPropsValue("db.driver") openOr "org.h2.Driver"
case _ => "org.h2.Driver"
}
val vendor =
@ -168,7 +168,7 @@ class Boot extends MdcLoggable {
case Props.RunModes.Production | Props.RunModes.Staging | Props.RunModes.Development =>
new StandardDBVendor(driver,
APIUtil.getPropsValue("db.url") openOr "jdbc:h2:lift_proto.db;AUTO_SERVER=TRUE",
Props.get("db.user"), APIUtil.getPropsValue("db.password"))
APIUtil.getPropsValue("db.user"), APIUtil.getPropsValue("db.password"))
case _ =>
new StandardDBVendor(
driver,
@ -184,8 +184,8 @@ class Boot extends MdcLoggable {
print("Enter the Password for the SSL Certificate Stores: ")
//As most IDEs do not provide a Console, we fall back to readLine
code.api.util.APIUtil.initPasswd = if (Props.get("kafka.use.ssl").getOrElse("") == "true" ||
Props.get("jwt.use.ssl").getOrElse("") == "true") {
code.api.util.APIUtil.initPasswd = if (APIUtil.getPropsValue("kafka.use.ssl").getOrElse("") == "true" ||
APIUtil.getPropsValue("jwt.use.ssl").getOrElse("") == "true") {
try {
System.console.readPassword().toString
} catch {
@ -194,7 +194,7 @@ class Boot extends MdcLoggable {
} else {"notused"}
// ensure our relational database's tables are created/fit the schema
val connector = Props.get("connector").openOrThrowException("no connector set")
val connector = APIUtil.getPropsValue("connector").openOrThrowException("no connector set")
if(connector != "mongodb")
schemifyAll()
@ -458,12 +458,12 @@ class Boot extends MdcLoggable {
val currentTime = now.toString
val stackTrace = new String(outputStream.toByteArray)
val error = currentTime + ": " + stackTrace
val host = Props.get("hostname", "unknown host")
val host = APIUtil.getPropsValue("hostname", "unknown host")
val mailSent = for {
from <- Props.get("mail.exception.sender.address") ?~ "Could not send mail: Missing props param for 'from'"
from <- APIUtil.getPropsValue("mail.exception.sender.address") ?~ "Could not send mail: Missing props param for 'from'"
// no spaces, comma separated e.g. mail.api.consumer.registered.notification.addresses=notify@example.com,notify2@example.com,notify3@example.com
toAddressesString <- Props.get("mail.exception.registered.notification.addresses") ?~ "Could not send mail: Missing props param for 'to'"
toAddressesString <- APIUtil.getPropsValue("mail.exception.registered.notification.addresses") ?~ "Could not send mail: Missing props param for 'to'"
} yield {
//technically doesn't work for all valid email addresses so this will mess up if someone tries to send emails to "foo,bar"@example.com

View File

@ -1,18 +1,18 @@
package code.actorsystem
import code.api.util.APIUtil
import code.util.Helper
import net.liftweb.util.Props
object ObpActorConfig {
val remoteHostname = Props.get("remotedata.hostname").openOr("127.0.0.1")
val remotePort = Props.get("remotedata.port").openOr("2662")
val remoteHostname = APIUtil.getPropsValue("remotedata.hostname").openOr("127.0.0.1")
val remotePort = APIUtil.getPropsValue("remotedata.port").openOr("2662")
val localHostname = "127.0.0.1"
val localPort = Helper.findAvailablePort()
val akka_loglevel = Props.get("remotedata.loglevel").openOr("INFO")
val akka_loglevel = APIUtil.getPropsValue("remotedata.loglevel").openOr("INFO")
val commonConf =
"""

View File

@ -90,7 +90,7 @@ object GatewayLogin extends RestHelper with MdcLoggable {
case true =>
Algorithm.RSA256(CertificateUtil.publicKey, CertificateUtil.privateKey)
case false =>
val secretKey = Props.get("gateway.token_secret", "Cannot get the secret")
val secretKey = APIUtil.getPropsValue("gateway.token_secret", "Cannot get the secret")
Algorithm.HMAC256(secretKey)
}
jwt = JWT.create.
@ -143,7 +143,7 @@ object GatewayLogin extends RestHelper with MdcLoggable {
case true =>
Algorithm.RSA256(CertificateUtil.publicKey, CertificateUtil.privateKey)
case false =>
val secretKey = Props.get("gateway.token_secret", "Cannot get the secret")
val secretKey = APIUtil.getPropsValue("gateway.token_secret", "Cannot get the secret")
Algorithm.HMAC256(secretKey)
}
val verifier = JWT.

View File

@ -249,7 +249,7 @@ trait OBPRestHelper extends RestHelper with MdcLoggable {
}
} else if (APIUtil.getPropsAsBoolValue("allow_gateway_login", false) && hasGatewayHeader(authorization)) {
logger.info("allow_gateway_login-getRemoteIpAddress: " + getRemoteIpAddress() )
Props.get("gateway.host") match {
APIUtil.getPropsValue("gateway.host") match {
case Full(h) if h.split(",").toList.exists(_.equalsIgnoreCase(getRemoteIpAddress()) == true) => // Only addresses from white list can use this feature
val s = S
val (httpCode, message, parameters) = GatewayLogin.validator(s.request)

View File

@ -194,7 +194,7 @@ object SwaggerJSONFactory {
val infoContact = InfoContactJson("TESOBE Ltd. / Open Bank Project", "https://openbankproject.com" ,"contact@tesobe.com")
val infoApiVersion = requestedApiVersion
val info = InfoJson(infoTitle, infoDescription, infoContact, infoApiVersion.toString)
val host = Props.get("hostname", "unknown host").replaceFirst("http://", "").replaceFirst("https://", "")
val host = APIUtil.getPropsValue("hostname", "unknown host").replaceFirst("http://", "").replaceFirst("https://", "")
val basePath = "/"
val schemas = List("http", "https")
// Paths Object

View File

@ -1,18 +1,17 @@
package code.api
import code.api.util.ErrorMessages
import code.api.util.{APIUtil, ErrorMessages}
import code.util.Helper.MdcLoggable
import net.liftweb.util.Props
// Note: Import this with: import code.api.Constant._
object Constant extends MdcLoggable {
logger.info("Instantiating Constants")
final val HostName = Props.get("hostname").openOrThrowException(ErrorMessages.HostnameNotSpecified)
final val HostName = APIUtil.getPropsValue("hostname").openOrThrowException(ErrorMessages.HostnameNotSpecified)
// This is the part before the version. Do not change this default!
final val ApiPathZero = Props.get("apiPathZero", "obp")
final val ApiPathZero = APIUtil.getPropsValue("apiPathZero", "obp")
}

View File

@ -30,18 +30,19 @@ import java.net.HttpURLConnection
import java.util.Date
import javax.net.ssl.HttpsURLConnection
import code.token.Tokens
import code.api.util.APIUtil
import code.api.util.APIUtil._
import code.model.User
import code.model.dataAccess.{AuthUser, ResourceUser}
import code.token.Tokens
import code.util.Helper.MdcLoggable
import net.liftweb.common._
import net.liftweb.http._
import net.liftweb.json
import net.liftweb.json.{JObject, JValue}
import net.liftweb.mapper.By
import net.liftweb.util.Helpers
import net.liftweb.util.Helpers._
import net.liftweb.util.{Helpers, Props}
import code.util.Helper.MdcLoggable
import scala.compat.Platform
@ -63,14 +64,14 @@ case class OpenIdConnectConfig( clientSecret: String,
object OpenIdConnectConfig {
def get() = {
OpenIdConnectConfig(
Props.get("openidconnect.clientSecret").openOrThrowException("no openidconnect.clientSecret set"),
Props.get("openidconnect.clientId").openOrThrowException("no openidconnect.clientId set"),
Props.get("openidconnect.callbackURL").openOrThrowException("no openidconnect.callbackURL set"),
Props.get("openidconnect.domain").openOrThrowException("no openidconnect.domain set"),
Props.get("openidconnect.url.userinfo").openOrThrowException("no openidconnect.url.userinfo set"),
Props.get("openidconnect.url.token").openOrThrowException("no openidconnect.url.token set"),
Props.get("openidconnect.url.login").openOrThrowException("no openidconnect.url.login set"),
Props.get("openidconnect.url.buttonImage").openOrThrowException("no openidconnect.url.buttonImage set")
APIUtil.getPropsValue("openidconnect.clientSecret").openOrThrowException("no openidconnect.clientSecret set"),
APIUtil.getPropsValue("openidconnect.clientId").openOrThrowException("no openidconnect.clientId set"),
APIUtil.getPropsValue("openidconnect.callbackURL").openOrThrowException("no openidconnect.callbackURL set"),
APIUtil.getPropsValue("openidconnect.domain").openOrThrowException("no openidconnect.domain set"),
APIUtil.getPropsValue("openidconnect.url.userinfo").openOrThrowException("no openidconnect.url.userinfo set"),
APIUtil.getPropsValue("openidconnect.url.token").openOrThrowException("no openidconnect.url.token set"),
APIUtil.getPropsValue("openidconnect.url.login").openOrThrowException("no openidconnect.url.login set"),
APIUtil.getPropsValue("openidconnect.url.buttonImage").openOrThrowException("no openidconnect.url.buttonImage set")
)
}
}

View File

@ -2,7 +2,7 @@ package code.api.sandbox
import code.api.{APIFailure, OBPRestHelper}
import code.api.util.APIUtil._
import code.api.util.ErrorMessages
import code.api.util.{APIUtil, ErrorMessages}
import code.sandbox.{OBPDataImport, SandboxDataImport}
import code.util.Helper
import net.liftweb.http.S
@ -28,7 +28,7 @@ object SandboxApiCalls extends OBPRestHelper with MdcLoggable {
cc =>
logger.debug("Hello from v1.0 data-import")
for{
correctToken <- Props.get("sandbox_data_import_secret") ~> APIFailure("Data import is disabled for this API instance.", 403)
correctToken <- APIUtil.getPropsValue("sandbox_data_import_secret") ~> APIFailure("Data import is disabled for this API instance.", 403)
providedToken <- S.param("secret_token") ~> APIFailure("secret_token parameter required", 403)
tokensMatch <- Helper.booleanToBox(providedToken == correctToken) ~> APIFailure("incorrect secret token", 403)
importData <- tryo{json.extract[SandboxDataImport]} ?~ ErrorMessages.InvalidJsonFormat

View File

@ -1727,7 +1727,7 @@ Returns a string showed to the developer
}
def isSuperAdmin(user_id: String) : Boolean = {
val user_ids = Props.get("super_admin_user_ids") match {
val user_ids = APIUtil.getPropsValue("super_admin_user_ids") match {
case Full(v) =>
v.split(",").map(_.trim).toList
case _ =>
@ -1772,7 +1772,7 @@ Returns a string showed to the developer
}
def getAutocompleteValue: String = {
Props.get("autocomplete_at_login_form_enabled", "false") match {
APIUtil.getPropsValue("autocomplete_at_login_form_enabled", "false") match {
case "true" => "on"
case "false" => "off"
case _ => "off"
@ -1804,7 +1804,7 @@ Returns a string showed to the developer
def akkaSanityCheck (): Box[Boolean] = {
getPropsAsBoolValue("use_akka", false) match {
case true =>
val remotedataSecret = Props.get("remotedata.secret").openOrThrowException("Cannot obtain property remotedata.secret")
val remotedataSecret = APIUtil.getPropsValue("remotedata.secret").openOrThrowException("Cannot obtain property remotedata.secret")
SanityCheck.sanityCheck.vend.remoteAkkaSanityCheck(remotedataSecret)
case false => Empty
}
@ -1981,15 +1981,15 @@ Returns a string showed to the developer
}
def getDisabledVersions() : List[String] = Props.get("api_disabled_versions").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def getDisabledVersions() : List[String] = APIUtil.getPropsValue("api_disabled_versions").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def getDisabledEndpoints() : List[String] = Props.get("api_disabled_endpoints").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def getDisabledEndpoints() : List[String] = APIUtil.getPropsValue("api_disabled_endpoints").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def getEnabledVersions() : List[String] = Props.get("api_enabled_versions").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def getEnabledVersions() : List[String] = APIUtil.getPropsValue("api_enabled_versions").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def getEnabledEndpoints() : List[String] = Props.get("api_enabled_endpoints").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def getEnabledEndpoints() : List[String] = APIUtil.getPropsValue("api_enabled_endpoints").getOrElse("").replace("[", "").replace("]", "").split(",").toList.filter(_.nonEmpty)
def stringToDate(value: String, dateFormat: String): Date = {
import java.text.SimpleDateFormat
@ -2294,7 +2294,7 @@ Versions are groups of endpoints in a file
} else if (getPropsAsBoolValue("allow_direct_login", true) && hasDirectLoginHeader(cc.authReqHeaderField)) {
DirectLogin.getUserFromDirectLoginHeaderFuture(cc)
} else if (getPropsAsBoolValue("allow_gateway_login", false) && hasGatewayHeader(cc.authReqHeaderField)) {
Props.get("gateway.host") match {
APIUtil.getPropsValue("gateway.host") match {
case Full(h) if h.split(",").toList.exists(_.equalsIgnoreCase(getRemoteIpAddress()) == true) => // Only addresses from white list can use this feature
val (httpCode, message, parameters) = GatewayLogin.validator(s.request)
httpCode match {
@ -2457,7 +2457,7 @@ Versions are groups of endpoints in a file
counterpartyName: String
)= createOBPId(s"$thisBankId$thisAccountId$counterpartyName")
val isSandboxMode: Boolean = (Props.get("connector").openOrThrowException(attemptedToOpenAnEmptyBox).toString).equalsIgnoreCase("mapped")
val isSandboxMode: Boolean = (APIUtil.getPropsValue("connector").openOrThrowException(attemptedToOpenAnEmptyBox).toString).equalsIgnoreCase("mapped")
/**
* This function is implemented in order to support encrypted values in props file.
@ -2487,6 +2487,9 @@ Versions are groups of endpoints in a file
Failure(cannotDecryptValueOfProperty + nameOfProperty)
}
}
def getPropsValue(nameOfProperty: String, defaultValue: String): String = {
getPropsValue(nameOfProperty) openOr(defaultValue)
}
def getPropsAsBoolValue(nameOfProperty: String, defaultValue: Boolean): Boolean = {
getPropsValue(nameOfProperty) map(toBoolean) openOr(defaultValue)

View File

@ -24,10 +24,10 @@ object CertificateUtil extends MdcLoggable {
lazy val (publicKey: RSAPublicKey, privateKey: RSAPrivateKey) = APIUtil.getPropsAsBoolValue("jwt.use.ssl", false) match {
case true =>
getKeyPair(
jkspath = Props.get("keystore.path").getOrElse(""),
jkspasswd = Props.get("keystore.password").getOrElse(APIUtil.initPasswd),
keypasswd = Props.get("keystore.passphrase").getOrElse(APIUtil.initPasswd),
alias = Props.get("keystore.alias").getOrElse("")
jkspath = APIUtil.getPropsValue("keystore.path").getOrElse(""),
jkspasswd = APIUtil.getPropsValue("keystore.password").getOrElse(APIUtil.initPasswd),
keypasswd = APIUtil.getPropsValue("keystore.passphrase").getOrElse(APIUtil.initPasswd),
alias = APIUtil.getPropsValue("keystore.alias").getOrElse("")
)
case false =>
val keyPair = buildKeyPair(CryptoSystem.RSA)
@ -146,8 +146,8 @@ object CertificateUtil extends MdcLoggable {
print("Enter the Password for the SSL Certificate Stores: ")
//As most IDEs do not provide a Console, we fall back to readLine
code.api.util.APIUtil.initPasswd =
if (Props.get("kafka.use.ssl").getOrElse("") == "true" ||
Props.get("jwt.use.ssl").getOrElse("") == "true")
if (APIUtil.getPropsValue("kafka.use.ssl").getOrElse("") == "true" ||
APIUtil.getPropsValue("jwt.use.ssl").getOrElse("") == "true")
{
try {
System.console.readPassword().toString

View File

@ -66,7 +66,7 @@ object JwtUtil {
*/
def verifyHmacSignedJwt(jwtToken: String): Boolean = {
val signedJWT = SignedJWT.parse(jwtToken)
val sharedSecret = Props.get("oauth2.token_secret", "")
val sharedSecret = APIUtil.getPropsValue("oauth2.token_secret", "")
val verifier = new MACVerifier(sharedSecret)
signedJWT.verify(verifier)
}

View File

@ -61,7 +61,7 @@
// //we now identify users by a combination of auth provider and the id given to them by their auth provider
// // in v1.2 only one auth provider (the api itself) was possible. Because many functions now require both
// //provider and id from the provider as arguments, we just use this value here as the provider.
// val authProvider = Props.get("hostname","")
// val authProvider = APIUtil.getPropsValue("hostname","")
// val version = "1.2"
// val versionStatus = "DEPRECIATED"
//

View File

@ -39,7 +39,7 @@ trait APIMethods121 {
val underlyingGuavaCache = CacheBuilder.newBuilder().maximumSize(10000L).build[String, Object]
implicit val scalaCache = ScalaCache(GuavaCache(underlyingGuavaCache))
val apiMethods121GetTransactionsTTL = Props.get("connector.cache.ttl.seconds.APIMethods121.getTransactions", "0").toInt * 1000 // Miliseconds
val apiMethods121GetTransactionsTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.APIMethods121.getTransactions", "0").toInt * 1000 // Miliseconds
// helper methods begin here
@ -90,12 +90,12 @@ trait APIMethods121 {
private def getApiInfoJSON(apiVersion : String, apiVersionStatus : String) = {
val apiDetails: JValue = {
val organisation = Props.get("hosted_by.organisation", "TESOBE")
val email = Props.get("hosted_by.email", "contact@tesobe.com")
val phone = Props.get("hosted_by.phone", "+49 (0)30 8145 3994")
val organisationWebsite = Props.get("organisation_website", "https://www.tesobe.com")
val organisation = APIUtil.getPropsValue("hosted_by.organisation", "TESOBE")
val email = APIUtil.getPropsValue("hosted_by.email", "contact@tesobe.com")
val phone = APIUtil.getPropsValue("hosted_by.phone", "+49 (0)30 8145 3994")
val organisationWebsite = APIUtil.getPropsValue("organisation_website", "https://www.tesobe.com")
val connector = Props.get("connector").openOrThrowException("no connector set")
val connector = APIUtil.getPropsValue("connector").openOrThrowException("no connector set")
val hostedBy = new HostedBy(organisation, email, phone, organisationWebsite)
val apiInfoJSON = new APIInfoJSON(apiVersion, apiVersionStatus, gitCommit, connector, hostedBy, Akka(APIUtil.akkaSanityCheck()))

View File

@ -56,7 +56,7 @@ trait APIMethods200 {
// helper methods begin here
val defaultBankId = Props.get("defaultBank.bank_id", "DEFAULT_BANK_ID_NOT_SET")
val defaultBankId = APIUtil.getPropsValue("defaultBank.bank_id", "DEFAULT_BANK_ID_NOT_SET")
@ -1299,7 +1299,7 @@ trait APIMethods200 {
toAccount <- BankAccount(toBankId, toAccountId) ?~! {ErrorMessages.CounterpartyNotFound}
// Prevent default value for transaction request type (at least).
// Get Transaction Request Types from Props "transactionRequests_supported_types". Default is empty string
validTransactionRequestTypes <- tryo{Props.get("transactionRequests_supported_types", "")}
validTransactionRequestTypes <- tryo{APIUtil.getPropsValue("transactionRequests_supported_types", "")}
// Use a list instead of a string to avoid partial matches
validTransactionRequestTypesList <- tryo{validTransactionRequestTypes.split(",")}
_ <- tryo(assert(transactionRequestType.value != "TRANSACTION_REQUEST_TYPE" && validTransactionRequestTypesList.contains(transactionRequestType.value))) ?~! s"${InvalidTransactionRequestType} : Invalid value is: '${transactionRequestType.value}' Valid values are: ${validTransactionRequestTypes}"
@ -1566,8 +1566,8 @@ trait APIMethods200 {
if (APIUtil.getPropsAsBoolValue("meeting.tokbox_enabled", false)) {
for {
// TODO use these keys to get session and tokens from tokbox
_ <- Props.get("meeting.tokbox_api_key") ~> APIFailure(MeetingApiKeyNotConfigured, 403)
_ <- Props.get("meeting.tokbox_api_secret") ~> APIFailure(MeetingApiSecretNotConfigured, 403)
_ <- APIUtil.getPropsValue("meeting.tokbox_api_key") ~> APIFailure(MeetingApiKeyNotConfigured, 403)
_ <- APIUtil.getPropsValue("meeting.tokbox_api_secret") ~> APIFailure(MeetingApiSecretNotConfigured, 403)
u <- cc.user ?~! UserNotLoggedIn
_ <- tryo(assert(isValidID(bankId.value)))?~! InvalidBankIdFormat
bank <- Bank(bankId) ?~! BankNotFound
@ -1624,8 +1624,8 @@ trait APIMethods200 {
for {
_ <- cc.user ?~! ErrorMessages.UserNotLoggedIn
_ <- Bank(bankId) ?~! BankNotFound
_ <- Props.get("meeting.tokbox_api_key") ~> APIFailure(ErrorMessages.MeetingApiKeyNotConfigured, 403)
_ <- Props.get("meeting.tokbox_api_secret") ~> APIFailure(ErrorMessages.MeetingApiSecretNotConfigured, 403)
_ <- APIUtil.getPropsValue("meeting.tokbox_api_key") ~> APIFailure(ErrorMessages.MeetingApiKeyNotConfigured, 403)
_ <- APIUtil.getPropsValue("meeting.tokbox_api_secret") ~> APIFailure(ErrorMessages.MeetingApiSecretNotConfigured, 403)
u <- cc.user ?~! ErrorMessages.UserNotLoggedIn
bank <- Bank(bankId) ?~! BankNotFound
// now = Calendar.getInstance().getTime()
@ -1682,8 +1682,8 @@ trait APIMethods200 {
for {
u <- cc.user ?~! UserNotLoggedIn
_ <- Bank(bankId) ?~! BankNotFound
_ <- Props.get("meeting.tokbox_api_key") ~> APIFailure(ErrorMessages.MeetingApiKeyNotConfigured, 403)
_ <- Props.get("meeting.tokbox_api_secret") ~> APIFailure(ErrorMessages.MeetingApiSecretNotConfigured, 403)
_ <- APIUtil.getPropsValue("meeting.tokbox_api_key") ~> APIFailure(ErrorMessages.MeetingApiKeyNotConfigured, 403)
_ <- APIUtil.getPropsValue("meeting.tokbox_api_secret") ~> APIFailure(ErrorMessages.MeetingApiSecretNotConfigured, 403)
bank <- Bank(bankId) ?~! BankNotFound
meeting <- Meeting.meetingProvider.vend.getMeeting(bank.bankId, u, meetingId) ?~! {ErrorMessages.MeetingNotFound}
}

View File

@ -116,7 +116,7 @@ trait APIMethods210 {
for {
importData <- tryo {json.extract[SandboxDataImport]} ?~! {InvalidJsonFormat}
u <- cc.user ?~! UserNotLoggedIn
allowDataImportProp <- Props.get("allow_sandbox_data_import") ~> APIFailure(DataImportDisabled, 403)
allowDataImportProp <- APIUtil.getPropsValue("allow_sandbox_data_import") ~> APIFailure(DataImportDisabled, 403)
_ <- Helper.booleanToBox(allowDataImportProp == "true") ~> APIFailure(DataImportDisabled, 403)
_ <- booleanToBox(hasEntitlement("", u.userId, canCreateSandbox), s"$UserHasMissingRoles $CanCreateSandbox")
_ <- OBPDataImport.importer.vend.importData(importData)
@ -158,7 +158,7 @@ trait APIMethods210 {
cc.user ?~! UserNotLoggedIn
_ <- Bank(bankId) ?~! {BankNotFound}
// Get Transaction Request Types from Props "transactionRequests_supported_types". Default is empty string
transactionRequestTypes <- tryo(Props.get("transactionRequests_supported_types", ""))
transactionRequestTypes <- tryo(APIUtil.getPropsValue("transactionRequests_supported_types", ""))
} yield {
// Format the data as json
val json = JSONFactory210.createTransactionRequestTypeJSON(transactionRequestTypes.split(",").toList)
@ -413,7 +413,7 @@ trait APIMethods210 {
_ <- Views.views.vend.view(viewId, BankIdAccountId(fromAccount.bankId,fromAccount.accountId)) ?~! {ViewNotFound}
isOwnerOrHasEntitlement <- booleanToBox(u.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId,fromAccount.accountId)) == true ||
hasEntitlement(fromAccount.bankId.value, u.userId, canCreateAnyTransactionRequest) == true, InsufficientAuthorisationToCreateTransactionRequest)
_ <- tryo(assert(Props.get("transactionRequests_supported_types", "").split(",").contains(transactionRequestType.value))) ?~!
_ <- tryo(assert(APIUtil.getPropsValue("transactionRequests_supported_types", "").split(",").contains(transactionRequestType.value))) ?~!
s"${InvalidTransactionRequestType}: '${transactionRequestType.value}'"
// Check the input JSON format, here is just check the common parts of all four tpyes

View File

@ -8,7 +8,7 @@ import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON._
import code.api.util.APIUtil._
import code.api.util.ApiRole._
import code.api.util.ErrorMessages.{BankAccountNotFound, _}
import code.api.util.{ApiRole, ErrorMessages}
import code.api.util.{APIUtil, ApiRole, ErrorMessages}
import code.api.v2_1_0._
import code.api.v2_2_0.JSONFactory220.transformV220ToBranch
import code.bankconnectors._
@ -42,24 +42,24 @@ trait APIMethods220 {
// helper methods begin here
private def getConfigInfoJSON(): ConfigurationJSON = {
val f1 = CachedFunctionJSON("getBank", Props.get("connector.cache.ttl.seconds.getBank", "0").toInt)
val f2 = CachedFunctionJSON("getBanks", Props.get("connector.cache.ttl.seconds.getBanks", "0").toInt)
val f3 = CachedFunctionJSON("getAccount", Props.get("connector.cache.ttl.seconds.getAccount", "0").toInt)
val f4 = CachedFunctionJSON("getAccounts", Props.get("connector.cache.ttl.seconds.getAccounts", "0").toInt)
val f5 = CachedFunctionJSON("getTransaction", Props.get("connector.cache.ttl.seconds.getTransaction", "0").toInt)
val f6 = CachedFunctionJSON("getTransactions", Props.get("connector.cache.ttl.seconds.getTransactions", "0").toInt)
val f7 = CachedFunctionJSON("getCounterpartyFromTransaction", Props.get("connector.cache.ttl.seconds.getCounterpartyFromTransaction", "0").toInt)
val f8 = CachedFunctionJSON("getCounterpartiesFromTransaction", Props.get("connector.cache.ttl.seconds.getCounterpartiesFromTransaction", "0").toInt)
val f1 = CachedFunctionJSON("getBank", APIUtil.getPropsValue("connector.cache.ttl.seconds.getBank", "0").toInt)
val f2 = CachedFunctionJSON("getBanks", APIUtil.getPropsValue("connector.cache.ttl.seconds.getBanks", "0").toInt)
val f3 = CachedFunctionJSON("getAccount", APIUtil.getPropsValue("connector.cache.ttl.seconds.getAccount", "0").toInt)
val f4 = CachedFunctionJSON("getAccounts", APIUtil.getPropsValue("connector.cache.ttl.seconds.getAccounts", "0").toInt)
val f5 = CachedFunctionJSON("getTransaction", APIUtil.getPropsValue("connector.cache.ttl.seconds.getTransaction", "0").toInt)
val f6 = CachedFunctionJSON("getTransactions", APIUtil.getPropsValue("connector.cache.ttl.seconds.getTransactions", "0").toInt)
val f7 = CachedFunctionJSON("getCounterpartyFromTransaction", APIUtil.getPropsValue("connector.cache.ttl.seconds.getCounterpartyFromTransaction", "0").toInt)
val f8 = CachedFunctionJSON("getCounterpartiesFromTransaction", APIUtil.getPropsValue("connector.cache.ttl.seconds.getCounterpartiesFromTransaction", "0").toInt)
val akkaPorts = PortJSON("remotedata.local.port", ObpActorConfig.localPort.toString) :: PortJSON("remotedata.port", ObpActorConfig.remotePort) :: Nil
val akka = AkkaJSON(akkaPorts, ObpActorConfig.akka_loglevel)
val cache = f1::f2::f3::f4::f5::f6::f7::f8::Nil
val metrics = MetricsJSON("es.metrics.port.tcp", Props.get("es.metrics.port.tcp", "9300")) ::
MetricsJSON("es.metrics.port.http", Props.get("es.metrics.port.tcp", "9200")) ::
val metrics = MetricsJSON("es.metrics.port.tcp", APIUtil.getPropsValue("es.metrics.port.tcp", "9300")) ::
MetricsJSON("es.metrics.port.http", APIUtil.getPropsValue("es.metrics.port.tcp", "9200")) ::
Nil
val warehouse = WarehouseJSON("es.warehouse.port.tcp", Props.get("es.warehouse.port.tcp", "9300")) ::
WarehouseJSON("es.warehouse.port.http", Props.get("es.warehouse.port.http", "9200")) ::
val warehouse = WarehouseJSON("es.warehouse.port.tcp", APIUtil.getPropsValue("es.warehouse.port.tcp", "9300")) ::
WarehouseJSON("es.warehouse.port.http", APIUtil.getPropsValue("es.warehouse.port.http", "9200")) ::
Nil
ConfigurationJSON(akka, ElasticSearchJSON(metrics, warehouse), cache)

View File

@ -67,7 +67,7 @@ object Connector extends SimpleInjector {
val connector = new Inject(buildOne _) {}
def buildOne: Connector = {
val connectorProps = Props.get("connector").openOrThrowException("no connector set")
val connectorProps = APIUtil.getPropsValue("connector").openOrThrowException("no connector set")
connectorProps match {
case "mapped" => LocalMappedConnector
@ -794,7 +794,7 @@ trait Connector extends MdcLoggable{
protected def getTransactionRequestTypesImpl(fromAccount : BankAccount) : Box[List[TransactionRequestType]] = {
//TODO: write logic / data access
// Get Transaction Request Types from Props "transactionRequests_supported_types". Default is empty string
val validTransactionRequestTypes = Props.get("transactionRequests_supported_types", "").split(",").map(x => TransactionRequestType(x)).toList
val validTransactionRequestTypes = APIUtil.getPropsValue("transactionRequests_supported_types", "").split(",").map(x => TransactionRequestType(x)).toList
Full(validTransactionRequestTypes)
}

View File

@ -64,7 +64,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
implicit override val nameOfConnector = KafkaMappedConnector.getClass.getSimpleName
// Local TTL Cache
val cacheTTL = Props.get("connector.cache.ttl.seconds", "10").toInt
val cacheTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds", "10").toInt
val cachedUser = TTLCache[KafkaInboundValidatedUser](cacheTTL)
val cachedBank = TTLCache[KafkaInboundBank](cacheTTL)
val cachedAccount = TTLCache[KafkaInboundAccount](cacheTTL)

View File

@ -32,7 +32,7 @@ import java.util.{Date, Locale, UUID}
import code.accountholder.AccountHolders
import code.api.util.APIUtil.saveConnectorMetric
import code.api.util.ErrorMessages._
import code.api.util.{ErrorMessages, CallContext}
import code.api.util.{APIUtil, CallContext, ErrorMessages}
import code.api.v2_1_0.TransactionRequestCommonBodyJSON
import code.atms.Atms.{AtmId, AtmT}
import code.atms.{Atms, MappedAtm}
@ -66,7 +66,6 @@ import net.liftweb.json.JsonAST.JValue
import net.liftweb.json.MappingException
import net.liftweb.mapper._
import net.liftweb.util.Helpers._
import net.liftweb.util.Props
import scala.collection.immutable.{List, Seq}
import scala.concurrent.duration._
@ -86,17 +85,17 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
val underlyingGuavaCache = CacheBuilder.newBuilder().maximumSize(10000L).build[String, Object]
implicit val scalaCache = ScalaCache(GuavaCache(underlyingGuavaCache))
val getBankTTL = Props.get("connector.cache.ttl.seconds.getBank", "0").toInt * 1000 // Miliseconds
val getBanksTTL = Props.get("connector.cache.ttl.seconds.getBanks", "0").toInt * 1000 // Miliseconds
val getUserTTL = Props.get("connector.cache.ttl.seconds.getUser", "0").toInt * 1000 // Miliseconds
val updateUserAccountViewsTTL = Props.get("connector.cache.ttl.seconds.updateUserAccountViews", "0").toInt * 1000 // Miliseconds
val getAccountTTL = Props.get("connector.cache.ttl.seconds.getAccount", "0").toInt * 1000 // Miliseconds
val getAccountHolderTTL = Props.get("connector.cache.ttl.seconds.getAccountHolderTTL", "0").toInt * 1000 // Miliseconds
val getAccountsTTL = Props.get("connector.cache.ttl.seconds.getAccounts", "0").toInt * 1000 // Miliseconds
val getTransactionTTL = Props.get("connector.cache.ttl.seconds.getTransaction", "0").toInt * 1000 // Miliseconds
val getTransactionsTTL = Props.get("connector.cache.ttl.seconds.getTransactions", "0").toInt * 1000 // Miliseconds
val getCounterpartyFromTransactionTTL = Props.get("connector.cache.ttl.seconds.getCounterpartyFromTransaction", "0").toInt * 1000 // Miliseconds
val getCounterpartiesFromTransactionTTL = Props.get("connector.cache.ttl.seconds.getCounterpartiesFromTransaction", "0").toInt * 1000 // Miliseconds
val getBankTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getBank", "0").toInt * 1000 // Miliseconds
val getBanksTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getBanks", "0").toInt * 1000 // Miliseconds
val getUserTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getUser", "0").toInt * 1000 // Miliseconds
val updateUserAccountViewsTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.updateUserAccountViews", "0").toInt * 1000 // Miliseconds
val getAccountTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getAccount", "0").toInt * 1000 // Miliseconds
val getAccountHolderTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getAccountHolderTTL", "0").toInt * 1000 // Miliseconds
val getAccountsTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getAccounts", "0").toInt * 1000 // Miliseconds
val getTransactionTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getTransaction", "0").toInt * 1000 // Miliseconds
val getTransactionsTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getTransactions", "0").toInt * 1000 // Miliseconds
val getCounterpartyFromTransactionTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getCounterpartyFromTransaction", "0").toInt * 1000 // Miliseconds
val getCounterpartiesFromTransactionTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getCounterpartiesFromTransaction", "0").toInt * 1000 // Miliseconds
val primaryUserIdentifier = AuthUser.getCurrentUserUsername

View File

@ -52,11 +52,11 @@ import scalacache.memoization._
object LocalMappedConnector extends Connector with MdcLoggable {
// override type AccountType = MappedBankAccount
val maxBadLoginAttempts = Props.get("max.bad.login.attempts") openOr "10"
val maxBadLoginAttempts = APIUtil.getPropsValue("max.bad.login.attempts") openOr "10"
val underlyingGuavaCache = CacheBuilder.newBuilder().maximumSize(10000L).build[String, Object]
implicit val scalaCache = ScalaCache(GuavaCache(underlyingGuavaCache))
val getTransactionsTTL = Props.get("connector.cache.ttl.seconds.getTransactions", "0").toInt * 1000 // Miliseconds
val getTransactionsTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getTransactions", "0").toInt * 1000 // Miliseconds
//This is the implicit parameter for saveConnectorMetric function.
//eg: override def getBank(bankId: BankId): Box[Bank] = saveConnectorMetric
@ -72,7 +72,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
logger.debug(s"threshold is $threshold")
// TODO constrain this to supported currencies.
val thresholdCurrency = Props.get("transactionRequests_challenge_currency", "EUR")
val thresholdCurrency = APIUtil.getPropsValue("transactionRequests_challenge_currency", "EUR")
logger.debug(s"thresholdCurrency is $thresholdCurrency")
val rate = fx.exchangeRate(thresholdCurrency, currency)
@ -131,7 +131,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
logger.debug(s"transactionRequests_charge_level is $chargeLevel")
// TODO constrain this to supported currencies.
// val chargeLevelCurrency = Props.get("transactionRequests_challenge_currency", "EUR")
// val chargeLevelCurrency = APIUtil.getPropsValue("transactionRequests_challenge_currency", "EUR")
// logger.debug(s"chargeLevelCurrency is $chargeLevelCurrency")
// val rate = fx.exchangeRate (chargeLevelCurrency, currency)
// val convertedThreshold = fx.convert(chargeLevel, rate)

View File

@ -5,9 +5,10 @@ import java.time.ZoneOffset.UTC
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.util.{Date, Locale, Optional, UUID}
import code.api.util.ErrorMessages._
import code.accountholder.{AccountHolders, MapperAccountHolders}
import code.api.util.{ErrorMessages, CallContext}
import code.api.util.{APIUtil, CallContext, ErrorMessages}
import code.api.v2_1_0.TransactionRequestCommonBodyJSON
import code.bankconnectors.vJune2017.AccountRule
import code.bankconnectors.vMar2017.InboundAdapterInfoInternal
@ -68,8 +69,8 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
var jvmNorth : JConnector = null
val responseTopic = Props.get("obpjvm.response_topic").openOr("Response")
val requestTopic = Props.get("obpjvm.request_topic").openOr("Request")
val responseTopic = APIUtil.getPropsValue("obpjvm.response_topic").openOr("Response")
val requestTopic = APIUtil.getPropsValue("obpjvm.request_topic").openOr("Request")
var propsFile = "/props/production.default.props"
@ -103,14 +104,14 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
val underlyingGuavaCache = CacheBuilder.newBuilder().maximumSize(10000L).build[String, Object]
implicit val scalaCache = ScalaCache(GuavaCache(underlyingGuavaCache))
val getBankTTL = Props.get("connector.cache.ttl.seconds.getBank", "0").toInt * 1000 // Miliseconds
val getBanksTTL = Props.get("connector.cache.ttl.seconds.getBanks", "0").toInt * 1000 // Miliseconds
val getAccountTTL = Props.get("connector.cache.ttl.seconds.getAccount", "0").toInt * 1000 // Miliseconds
val getAccountsTTL = Props.get("connector.cache.ttl.seconds.getAccounts", "0").toInt * 1000 // Miliseconds
val getTransactionTTL = Props.get("connector.cache.ttl.seconds.getTransaction", "0").toInt * 1000 // Miliseconds
val getTransactionsTTL = Props.get("connector.cache.ttl.seconds.getTransactions", "0").toInt * 1000 // Miliseconds
val getCounterpartyFromTransactionTTL = Props.get("connector.cache.ttl.seconds.getCounterpartyFromTransaction", "0").toInt * 1000 // Miliseconds
val getCounterpartiesFromTransactionTTL = Props.get("connector.cache.ttl.seconds.getCounterpartiesFromTransaction", "0").toInt * 1000 // Miliseconds
val getBankTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getBank", "0").toInt * 1000 // Miliseconds
val getBanksTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getBanks", "0").toInt * 1000 // Miliseconds
val getAccountTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getAccount", "0").toInt * 1000 // Miliseconds
val getAccountsTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getAccounts", "0").toInt * 1000 // Miliseconds
val getTransactionTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getTransaction", "0").toInt * 1000 // Miliseconds
val getTransactionsTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getTransactions", "0").toInt * 1000 // Miliseconds
val getCounterpartyFromTransactionTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getCounterpartyFromTransaction", "0").toInt * 1000 // Miliseconds
val getCounterpartiesFromTransactionTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getCounterpartiesFromTransaction", "0").toInt * 1000 // Miliseconds
override def getAdapterInfo: Box[InboundAdapterInfoInternal] = Empty

View File

@ -68,7 +68,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
implicit override val nameOfConnector = KafkaMappedConnector_vMar2017.getClass.getSimpleName
// Local TTL Cache
val cacheTTL = Props.get("connector.cache.ttl.seconds", "10").toInt
val cacheTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds", "10").toInt
val cachedUser = TTLCache[InboundValidatedUser](cacheTTL)
val cachedBank = TTLCache[InboundBank](cacheTTL)
val cachedAccount = TTLCache[InboundAccount](cacheTTL)

View File

@ -2,12 +2,10 @@ package code.examplething
// Need to import these one by one because in same package!
import code.bankconnectors.{KafkaMappedConnector, LocalRecordConnector, LocalMappedConnector}
import code.model.{BankId}
import code.api.util.APIUtil
import code.model.BankId
import net.liftweb.common.Logger
import net.liftweb.util.{Props, SimpleInjector}
import net.liftweb.util.SimpleInjector
object Thing extends SimpleInjector {
@ -17,7 +15,7 @@ object Thing extends SimpleInjector {
// This determines the provider we use
def buildOne: ThingProvider =
Props.get("provider.thing").openOr("mapped") match {
APIUtil.getPropsValue("provider.thing").openOr("mapped") match {
case "mapped" => MappedThingProvider
case _ => MappedThingProvider
}

View File

@ -12,7 +12,7 @@ import scala.concurrent.duration.{FiniteDuration, MILLISECONDS}
*/
trait KafkaConfig {
val bootstrapServers = Props.get("kafka.bootstrap_hosts")openOr("localhost:9092")
val bootstrapServers = APIUtil.getPropsValue("kafka.bootstrap_hosts")openOr("localhost:9092")
val partitions = APIUtil.getPropsAsIntValue("kafka.partitions", 10)

View File

@ -5,10 +5,10 @@ import java.util.{Properties, UUID}
import akka.actor.Actor
import code.actorsystem.{ObpActorHelper, ObpActorInit}
import code.api.util.APIUtil
import code.util.Helper.MdcLoggable
import net.liftweb.json
import net.liftweb.json.{DefaultFormats, Extraction, JValue}
import net.liftweb.util.Props
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.kafka.clients.producer.{KafkaProducer, ProducerRecord}
import org.apache.kafka.common.errors.WakeupException
@ -24,11 +24,11 @@ class KafkaHelperActor extends Actor with ObpActorInit with ObpActorHelper with
implicit val formats = DefaultFormats
val requestTopic = Props.get("kafka.request_topic").openOr("Request")
val responseTopic = Props.get("kafka.response_topic").openOr("Response")
val requestTopic = APIUtil.getPropsValue("kafka.request_topic").openOr("Request")
val responseTopic = APIUtil.getPropsValue("kafka.response_topic").openOr("Response")
val producerProps = new Properties()
producerProps.put("bootstrap.servers", Props.get("kafka.bootstrap_hosts")openOr("localhost:9092"))
producerProps.put("bootstrap.servers", APIUtil.getPropsValue("kafka.bootstrap_hosts")openOr("localhost:9092"))
producerProps.put("acks", "all")
producerProps.put("retries", "0")
producerProps.put("batch.size", "16384")
@ -38,7 +38,7 @@ class KafkaHelperActor extends Actor with ObpActorInit with ObpActorHelper with
producerProps.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
val consumerProps = new Properties()
consumerProps.put("bootstrap.servers", Props.get("kafka.bootstrap_hosts")openOr("localhost:9092"))
consumerProps.put("bootstrap.servers", APIUtil.getPropsValue("kafka.bootstrap_hosts")openOr("localhost:9092"))
consumerProps.put("enable.auto.commit", "false")
consumerProps.put("group.id", UUID.randomUUID.toString)
consumerProps.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer")

View File

@ -9,19 +9,19 @@ import akka.pattern.pipe
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Sink, Source}
import code.actorsystem.{ObpActorHelper, ObpActorInit}
import code.api.util.APIUtil
import code.api.util.APIUtil.initPasswd
import code.api.util.ErrorMessages._
import code.bankconnectors.AvroSerializer
import code.kafka.Topics.TopicTrait
import code.util.Helper.MdcLoggable
import net.liftweb.common.{Failure, Full}
import net.liftweb.json
import net.liftweb.json.{DefaultFormats, Extraction, JsonAST}
import net.liftweb.util.Props
import org.apache.kafka.clients.consumer.{ConsumerConfig, ConsumerRecord}
import org.apache.kafka.clients.producer.ProducerRecord
import org.apache.kafka.common.TopicPartition
import org.apache.kafka.common.serialization.{StringDeserializer, StringSerializer}
import code.api.util.ErrorMessages._
import scala.concurrent.{ExecutionException, Future, TimeoutException}
@ -41,7 +41,7 @@ class KafkaStreamsHelperActor extends Actor with ObpActorInit with ObpActorHelpe
*/
private def keyAndPartition = scala.util.Random.nextInt(partitions) + "_" + UUID.randomUUID().toString
private val consumerSettings = if (Props.get("kafka.use.ssl").getOrElse("false") == "true") {
private val consumerSettings = if (APIUtil.getPropsValue("kafka.use.ssl").getOrElse("false") == "true") {
ConsumerSettings(system, new StringDeserializer, new StringDeserializer)
.withBootstrapServers(bootstrapServers)
.withGroupId(groupId)
@ -49,9 +49,9 @@ class KafkaStreamsHelperActor extends Actor with ObpActorInit with ObpActorHelpe
.withMaxWakeups(maxWakeups)
.withProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, autoOffsetResetConfig)
.withProperty("security.protocol","SSL")
.withProperty("ssl.truststore.location", Props.get("truststore.path").getOrElse(""))
.withProperty("ssl.truststore.location", APIUtil.getPropsValue("truststore.path").getOrElse(""))
.withProperty("ssl.truststore.password", initPasswd)
.withProperty("ssl.keystore.location",Props.get("keystore.path").getOrElse(""))
.withProperty("ssl.keystore.location",APIUtil.getPropsValue("keystore.path").getOrElse(""))
.withProperty("ssl.keystore.password", initPasswd)
} else {
ConsumerSettings(system, new StringDeserializer, new StringDeserializer)
@ -68,15 +68,15 @@ class KafkaStreamsHelperActor extends Actor with ObpActorInit with ObpActorHelpe
.completionTimeout(completionTimeout)
}
private val producerSettings = if (Props.get("kafka.use.ssl").getOrElse("false") == "true") {
private val producerSettings = if (APIUtil.getPropsValue("kafka.use.ssl").getOrElse("false") == "true") {
ProducerSettings(system, new StringSerializer, new StringSerializer)
.withBootstrapServers(bootstrapServers)
.withProperty("batch.size", "0")
.withParallelism(3)
.withProperty("security.protocol","SSL")
.withProperty("ssl.truststore.location", Props.get("truststore.path").getOrElse(""))
.withProperty("ssl.truststore.location", APIUtil.getPropsValue("truststore.path").getOrElse(""))
.withProperty("ssl.truststore.password", initPasswd)
.withProperty("ssl.keystore.location",Props.get("keystore.path").getOrElse(""))
.withProperty("ssl.keystore.location",APIUtil.getPropsValue("keystore.path").getOrElse(""))
.withProperty("ssl.keystore.password", initPasswd)
} else {
ProducerSettings(system, new StringSerializer, new StringSerializer)
@ -139,7 +139,7 @@ class KafkaStreamsHelperActor extends Actor with ObpActorInit with ObpActorHelpe
super.preStart()
val conn = {
val c = Props.get("connector").openOr("June2017")
val c = APIUtil.getPropsValue("connector").openOr("June2017")
if (c.contains("_")) c.split("_")(1) else c
}
//configuration optimization is postponed
@ -229,8 +229,8 @@ object Topics {
* Request : North is producer, South is the consumer. North --> South
* Response: South is producer, North is the consumer. South --> North
*/
private val requestTopic = Props.get("kafka.request_topic").openOr("Request")
private val responseTopic = Props.get("kafka.response_topic").openOr("Response")
private val requestTopic = APIUtil.getPropsValue("kafka.request_topic").openOr("Request")
private val responseTopic = APIUtil.getPropsValue("kafka.response_topic").openOr("Response")
/**
* set in props, we have two topics: Request and Response
@ -247,7 +247,7 @@ object Topics {
* connectorVersion = June2017
*/
val connectorVersion = {
val connectorNameFromProps = Props.get("connector").openOr("June2017")
val connectorNameFromProps = APIUtil.getPropsValue("connector").openOr("June2017")
val c = if (connectorNameFromProps.contains("_")) connectorNameFromProps.split("_")(1) else connectorNameFromProps
c.replaceFirst("v", "")
}

View File

@ -1,14 +1,14 @@
package code.loginattempts
import code.api.util.APIUtil
import code.util.Helper.MdcLoggable
import net.liftweb.common.{Empty, Full}
import net.liftweb.mapper.By
import net.liftweb.util.Helpers._
import net.liftweb.util.Props
import code.util.Helper.MdcLoggable
object LoginAttempt extends MdcLoggable {
val maxBadLoginAttempts = Props.get("max.bad.login.attempts") openOr "5"
val maxBadLoginAttempts = APIUtil.getPropsValue("max.bad.login.attempts") openOr "5"
def incrementBadLoginAttempts(username: String): Unit = {

View File

@ -1,9 +1,11 @@
package code.management
import java.util.Date
import code.api.util.APIUtil
import code.api.util.ErrorMessages._
import code.bankconnectors.Connector
import code.model.{Transaction, BankId, AccountId}
import code.model.{AccountId, BankId, Transaction}
import code.tesobe.ErrorMessage
import code.util.Helper
import net.liftweb.common.Full
@ -179,7 +181,7 @@ object ImporterAPI extends RestHelper with MdcLoggable {
S.param("secret") match {
case Full(s) => {
Props.get("importer_secret") match {
APIUtil.getPropsValue("importer_secret") match {
case Full(localS) =>
if(localS == s)
savetransactions

View File

@ -162,9 +162,9 @@ class AuthUser extends MegaProtoUser[AuthUser] with Logger {
def getProvider() = {
if(provider.get == null) {
Props.get("hostname","")
} else if ( provider.get == "" || provider.get == Props.get("hostname","") ) {
Props.get("hostname","")
APIUtil.getPropsValue("hostname","")
} else if ( provider.get == "" || provider.get == APIUtil.getPropsValue("hostname","") ) {
APIUtil.getPropsValue("hostname","")
} else {
provider.get
}
@ -247,9 +247,9 @@ import net.liftweb.util.Helpers._
/**Marking the locked state to show different error message */
val usernameLockedStateCode = Long.MaxValue
val connector = Props.get("connector").openOrThrowException("no connector set")
val connector = APIUtil.getPropsValue("connector").openOrThrowException("no connector set")
override def emailFrom = Props.get("mail.users.userinfo.sender.address", "sender-not-set")
override def emailFrom = APIUtil.getPropsValue("mail.users.userinfo.sender.address", "sender-not-set")
override def screenWrap = Full(<lift:surround with="default" at="content"><lift:bind /></lift:surround>)
// define the order fields will appear in forms and output
@ -352,7 +352,7 @@ import net.liftweb.util.Helpers._
findUserByUsernameLocally(name) match {
case Full(user) if user.validated_? =>
user.resetUniqueId().save
val resetLink = Props.get("hostname", "ERROR")+
val resetLink = APIUtil.getPropsValue("hostname", "ERROR")+
passwordResetPath.mkString("/", "/", "/")+urlEncode(user.getUniqueId())
Mailer.sendMail(From(emailFrom),Subject(passwordResetEmailSubject),
@ -401,7 +401,7 @@ import net.liftweb.util.Helpers._
* Overriden to use the hostname set in the props file
*/
override def sendValidationEmail(user: TheUserType) {
val resetLink = Props.get("hostname", "ERROR")+"/"+validateUserPath.mkString("/")+
val resetLink = APIUtil.getPropsValue("hostname", "ERROR")+"/"+validateUserPath.mkString("/")+
"/"+urlEncode(user.getUniqueId())
val email: String = user.getEmail
@ -423,7 +423,7 @@ import net.liftweb.util.Helpers._
def agreeTerms = {
val url = Props.get("webui_agree_terms_url", "")
val url = APIUtil.getPropsValue("webui_agree_terms_url", "")
if (url.isEmpty) {
s""
} else {
@ -480,7 +480,7 @@ import net.liftweb.util.Helpers._
def getResourceUserId(username: String, password: String): Box[Long] = {
findUserByUsernameLocally(username) match {
case Full(user) if (user.getProvider() == Props.get("hostname","")) =>
case Full(user) if (user.getProvider() == APIUtil.getPropsValue("hostname","")) =>
if (
user.validated_? &&
// User is NOT locked AND the password is good
@ -514,7 +514,7 @@ import net.liftweb.util.Helpers._
Empty
}
case Full(user) if (user.getProvider() != Props.get("hostname","")) =>
case Full(user) if (user.getProvider() != APIUtil.getPropsValue("hostname","")) =>
connector match {
case Helper.matchAnyKafka() if ( APIUtil.getPropsAsBoolValue("kafka.user.authentication", false) &&
! LoginAttempt.userIsLocked(username) ) =>
@ -634,7 +634,7 @@ import net.liftweb.util.Helpers._
// Check if user came from localhost and
// if User is NOT locked and password is good
case Full(user) if user.validated_? &&
user.getProvider() == Props.get("hostname","") &&
user.getProvider() == APIUtil.getPropsValue("hostname","") &&
! LoginAttempt.userIsLocked(usernameFromGui) &&
user.testPassword(Full(passwordFromGui)) => {
// Reset any bad attempts
@ -669,7 +669,7 @@ import net.liftweb.util.Helpers._
// if User is NOT locked. Then check username and password
// from connector in case they changed on the south-side
case Full(user) if user.validated_? &&
user.getProvider() != Props.get("hostname","") &&
user.getProvider() != APIUtil.getPropsValue("hostname","") &&
! LoginAttempt.userIsLocked(usernameFromGui) &&
testExternalPassword(Full(user.username.get), Full(passwordFromGui)).getOrElse(false) => {
// Reset any bad attempts
@ -704,7 +704,7 @@ import net.liftweb.util.Helpers._
// If user is unlocked AND bad password, increment bad login attempt counter.
case Full(user) if user.validated_? &&
user.getProvider() == Props.get("hostname","") &&
user.getProvider() == APIUtil.getPropsValue("hostname","") &&
! LoginAttempt.userIsLocked(usernameFromGui) &&
! user.testPassword(Full(passwordFromGui)) =>
LoginAttempt.incrementBadLoginAttempts(usernameFromGui)

View File

@ -48,23 +48,17 @@ package com.tesobe.model {
package code.model.dataAccess {
import code.api.util.APIUtil
import code.bankconnectors.Connector
import code.model._
import code.users.Users
import code.views.Views
import com.rabbitmq.client.{ConnectionFactory,Channel}
import net.liftmodules.amqp.{
AMQPDispatcher,
AMQPMessage,
SerializedConsumer,
AMQPAddListener
}
import net.liftweb.util._
import net.liftweb.common.{Failure, Full}
import code.util.Helper.MdcLoggable
import net.liftweb.actor.LiftActor
import code.views.Views
import com.rabbitmq.client.{Channel, ConnectionFactory}
import com.tesobe.model.{CreateBankAccount, UpdateBankAccount}
import net.liftmodules.amqp.{AMQPAddListener, AMQPDispatcher, AMQPMessage, SerializedConsumer}
import net.liftweb.actor.LiftActor
import net.liftweb.common.{Failure, Full}
/**
@ -145,10 +139,10 @@ import com.tesobe.model.{CreateBankAccount, UpdateBankAccount}
lazy val factory = new ConnectionFactory {
import ConnectionFactory._
setHost(Props.get("connection.host", "localhost"))
setHost(APIUtil.getPropsValue("connection.host", "localhost"))
setPort(DEFAULT_AMQP_PORT)
setUsername(Props.get("connection.user", DEFAULT_USER))
setPassword(Props.get("connection.password", DEFAULT_PASS))
setUsername(APIUtil.getPropsValue("connection.user", DEFAULT_USER))
setPassword(APIUtil.getPropsValue("connection.password", DEFAULT_PASS))
setVirtualHost(DEFAULT_VHOST)
}

View File

@ -49,7 +49,7 @@ object MongoConfig {
val srvr = new ServerAddress(
Props.get("mongo.host", "localhost"),
APIUtil.getPropsValue("mongo.host", "localhost"),
APIUtil.getPropsAsIntValue("mongo.port", 27017)
)
val defaultDatabase = Props.mode match {
@ -57,7 +57,7 @@ object MongoConfig {
case _ => "OBP006"
}
MongoDB.defineDb(DefaultConnectionIdentifier, new MongoClient(srvr), Props.get("mongo.dbName", defaultDatabase))
MongoDB.defineDb(DefaultConnectionIdentifier, new MongoClient(srvr), APIUtil.getPropsValue("mongo.dbName", defaultDatabase))
MongoDB.defineDb(AdminDb, new MongoClient(srvr), "admin")

View File

@ -31,12 +31,10 @@ Berlin 13359, Germany
*/
package code.model.dataAccess
import code.api.util.APIUtil
import code.model.{User, UserId}
import code.util.MappedUUID
import net.liftweb.mapper._
import net.liftweb.util.Props
import code.model.{BankIdAccountId, User, UserId, View}
import code.views.Views
import net.liftweb.common.Full
/**
* Refer to AuthUser, see the difference between AuthUser and ResourceUser
@ -54,7 +52,7 @@ class ResourceUser extends LongKeyedMapper[ResourceUser] with User with ManyToMa
override def defaultValue = ""
}
object provider_ extends MappedString(this, 100){
override def defaultValue = Props.get("hostname","")
override def defaultValue = APIUtil.getPropsValue("hostname","")
}
/**

View File

@ -45,21 +45,21 @@ package com.tesobe.model{
package code.model.dataAccess {
import com.rabbitmq.client.{ConnectionFactory,Channel}
import net.liftmodules.amqp.{AMQPSender,AMQPMessage}
import net.liftweb.util._
import code.api.util.APIUtil
import code.util.Helper.MdcLoggable
import com.rabbitmq.client.{Channel, ConnectionFactory}
import com.tesobe.model.UpdateBankAccount
import net.liftmodules.amqp.{AMQPMessage, AMQPSender}
object UpdatesRequestSender extends MdcLoggable {
private val factory = new ConnectionFactory {
import ConnectionFactory._
setHost(Props.get("connection.host", "localhost"))
setHost(APIUtil.getPropsValue("connection.host", "localhost"))
setPort(DEFAULT_AMQP_PORT)
setUsername(Props.get("connection.user", DEFAULT_USER))
setPassword(Props.get("connection.password", DEFAULT_PASS))
setUsername(APIUtil.getPropsValue("connection.user", DEFAULT_USER))
setPassword(APIUtil.getPropsValue("connection.password", DEFAULT_PASS))
setVirtualHost(DEFAULT_VHOST)
}

View File

@ -1,8 +1,8 @@
package code.opentok
import code.api.util.APIUtil
import com.opentok._
import com.opentok.exception.OpenTokException
import net.liftweb.util.Props
/**
* Created by markom on 5/22/16.
@ -13,8 +13,8 @@ object OpenTokUtil {
def createOpenTok: OpenTok = {
// Set the following constants with the API key and API secret
// that you receive when you sign up to use the OpenTok API:
val apiKey: Int = Props.get("meeting.tokbox_api_key", "0000").toInt
val apiSecret: String = Props.get("meeting.tokbox_api_secret", "YOUR API SECRET")
val apiKey: Int = APIUtil.getPropsValue("meeting.tokbox_api_key", "0000").toInt
val apiSecret: String = APIUtil.getPropsValue("meeting.tokbox_api_secret", "YOUR API SECRET")
val opentok: OpenTok = new OpenTok(apiKey, apiSecret)
return opentok
}

View File

@ -3,10 +3,11 @@ package code.remotedata
import java.util.concurrent.TimeUnit
import akka.actor.{ActorSystem, Props => ActorProps}
import akka.routing.RoundRobinPool
import bootstrap.liftweb.ToSchemify
import code.actorsystem.ObpActorConfig
import code.api.util.APIUtil
import code.util.Helper
import code.util.Helper.MdcLoggable
import com.typesafe.config.ConfigFactory
import net.liftweb.common._
import net.liftweb.db.StandardDBVendor
@ -16,7 +17,6 @@ import net.liftweb.util.Props
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import code.util.Helper.MdcLoggable
object RemotedataActors extends MdcLoggable {
@ -64,15 +64,15 @@ object RemotedataActors extends MdcLoggable {
if (!DB.jndiJdbcConnAvailable_?) {
val driver =
Props.mode match {
case Props.RunModes.Production | Props.RunModes.Staging | Props.RunModes.Development => Props.get("remotedata.db.driver") openOr "org.h2.Driver"
case Props.RunModes.Production | Props.RunModes.Staging | Props.RunModes.Development => APIUtil.getPropsValue("remotedata.db.driver") openOr "org.h2.Driver"
case _ => "org.h2.Driver"
}
val vendor =
Props.mode match {
case Props.RunModes.Production | Props.RunModes.Staging | Props.RunModes.Development =>
new StandardDBVendor(driver,
Props.get("remotedata.db.url") openOr "jdbc:h2:./lift_proto.remotedata.db;AUTO_SERVER=TRUE",
Props.get("remotedata.db.user"), Props.get("remotedata.db.password"))
APIUtil.getPropsValue("remotedata.db.url") openOr "jdbc:h2:./lift_proto.remotedata.db;AUTO_SERVER=TRUE",
APIUtil.getPropsValue("remotedata.db.user"), APIUtil.getPropsValue("remotedata.db.password"))
case _ =>
new StandardDBVendor(
driver,

View File

@ -2,17 +2,17 @@ package code.remotedata
import akka.pattern.ask
import code.actorsystem.ObpActorInit
import code.api.util.APIUtil
import code.consumer.{ConsumersProvider, RemotedataConsumersCaseClasses}
import code.model._
import com.google.common.cache.CacheBuilder
import net.liftweb.common._
import net.liftweb.util.Props
import scala.concurrent.Future
import scala.concurrent.duration._
import scalacache.{Flags, ScalaCache}
import scalacache.guava.GuavaCache
import scalacache.memoization.{cacheKeyExclude, memoizeSync}
import scalacache.{Flags, ScalaCache}
object RemotedataConsumers extends ObpActorInit with ConsumersProvider {
@ -20,7 +20,7 @@ object RemotedataConsumers extends ObpActorInit with ConsumersProvider {
val underlyingGuavaCache = CacheBuilder.newBuilder().maximumSize(10000L).build[String, Object]
implicit val scalaCache = ScalaCache(GuavaCache(underlyingGuavaCache))
val getConsumerTTL = Props.get("connector.cache.ttl.seconds.getConsumer", "6000").toInt * 1000 // Miliseconds
val getConsumerTTL = APIUtil.getPropsValue("connector.cache.ttl.seconds.getConsumer", "6000").toInt * 1000 // Miliseconds
val cc = RemotedataConsumersCaseClasses

View File

@ -27,7 +27,7 @@ object RemotedataSanityCheckCaseClasses extends RemotedataSanityCheckCaseClasses
object SanityChecksImpl extends SanityChecks {
override def remoteAkkaSanityCheck(remoteDataSecret: String): Box[Boolean] = {
Props.get("remotedata.secret") match {
APIUtil.getPropsValue("remotedata.secret") match {
case Full(x) => Full(remoteDataSecret == x)
case _ => Empty
}

View File

@ -145,17 +145,17 @@ class elasticsearch extends MdcLoggable {
class elasticsearchMetrics extends elasticsearch {
override val esHost = Props.get("es.metrics.host","localhost")
override val esPortTCP = Props.get("es.metrics.port.tcp","9300")
override val esPortHTTP = Props.get("es.metrics.port.http","9200")
override val esIndex = Props.get("es.metrics.index", "metrics")
override val esHost = APIUtil.getPropsValue("es.metrics.host","localhost")
override val esPortTCP = APIUtil.getPropsValue("es.metrics.port.tcp","9300")
override val esPortHTTP = APIUtil.getPropsValue("es.metrics.port.http","9200")
override val esIndex = APIUtil.getPropsValue("es.metrics.index", "metrics")
if (esIndex.contains(",")) throw new RuntimeException("Props error: es.metrics.index can not be a list")
var client:TcpClient = null
if (APIUtil.getPropsAsBoolValue("allow_elasticsearch", false) && APIUtil.getPropsAsBoolValue("allow_elasticsearch_metrics", false) ) {
val settings = Settings.builder().put("cluster.name", Props.get("es.cluster.name", "elasticsearch")).build()
val settings = Settings.builder().put("cluster.name", APIUtil.getPropsValue("es.cluster.name", "elasticsearch")).build()
client = TcpClient.transport(settings, "elasticsearch://" + esHost + ":" + esPortTCP + ",")
try {
client.execute {
@ -202,23 +202,23 @@ class elasticsearchMetrics extends elasticsearch {
}
class elasticsearchWarehouse extends elasticsearch {
override val esHost = Props.get("es.warehouse.host","localhost")
override val esPortTCP = Props.get("es.warehouse.port.tcp","9300")
override val esPortHTTP = Props.get("es.warehouse.port.http","9200")
override val esIndex = Props.get("es.warehouse.index", "warehouse")
override val esHost = APIUtil.getPropsValue("es.warehouse.host","localhost")
override val esPortTCP = APIUtil.getPropsValue("es.warehouse.port.tcp","9300")
override val esPortHTTP = APIUtil.getPropsValue("es.warehouse.port.http","9200")
override val esIndex = APIUtil.getPropsValue("es.warehouse.index", "warehouse")
var client:TcpClient = null
if (APIUtil.getPropsAsBoolValue("allow_elasticsearch", false) && APIUtil.getPropsAsBoolValue("allow_elasticsearch_warehouse", false) ) {
val settings = Settings.builder().put("cluster.name", Props.get("es.cluster.name", "elasticsearch")).build()
val settings = Settings.builder().put("cluster.name", APIUtil.getPropsValue("es.cluster.name", "elasticsearch")).build()
client = TcpClient.transport(settings, "elasticsearch://" + esHost + ":" + esPortTCP + ",")
}
}
/*
class elasticsearchOBP extends elasticsearch {
override val esHost = Props.get("es.obp.host","localhost")
override val esPortTCP = Props.get("es.obp.port.tcp","9300")
override val esPortHTTP = Props.get("es.obp.port.tcp","9200")
override val esIndex = Props.get("es.obp.index", "obp")
override val esHost = APIUtil.getPropsValue("es.obp.host","localhost")
override val esPortTCP = APIUtil.getPropsValue("es.obp.port.tcp","9300")
override val esPortHTTP = APIUtil.getPropsValue("es.obp.port.tcp","9200")
override val esIndex = APIUtil.getPropsValue("es.obp.index", "obp")
val accountIndex = "account_v1.2.1"
val transactionIndex = "transaction_v1.2.1"

View File

@ -56,11 +56,11 @@ class ConsumerRegistration extends MdcLoggable {
// Can be used to show link to an online form to collect more information about the App / Startup
val registrationMoreInfoUrl = Props.get("webui_post_consumer_registration_more_info_url", "")
val registrationMoreInfoUrl = APIUtil.getPropsValue("webui_post_consumer_registration_more_info_url", "")
val registrationMoreInfoText : String = registrationMoreInfoUrl match {
case "" => ""
case _ => Props.get("webui_post_consumer_registration_more_info_text", "Please tell us more your Application and / or Startup using this link.")
case _ => APIUtil.getPropsValue("webui_post_consumer_registration_more_info_text", "Please tell us more your Application and / or Startup using this link.")
}
@ -90,8 +90,8 @@ class ConsumerRegistration extends MdcLoggable {
}
def showResults(consumer : Consumer) = {
val urlOAuthEndpoint = Props.get("hostname", "") + "/oauth/initiate"
val urlDirectLoginEndpoint = Props.get("hostname", "") + "/my/logins/direct"
val urlOAuthEndpoint = APIUtil.getPropsValue("hostname", "") + "/oauth/initiate"
val urlDirectLoginEndpoint = APIUtil.getPropsValue("hostname", "") + "/my/logins/direct"
//thanks for registering, here's your key, etc.
"#app-consumer_id *" #> consumer.id.get &
"#app-name *" #> consumer.name.get &
@ -197,8 +197,8 @@ class ConsumerRegistration extends MdcLoggable {
import net.liftweb.util.Mailer._
val mailSent = for {
send : String <- Props.get("mail.api.consumer.registered.notification.send") if send.equalsIgnoreCase("true")
from <- Props.get("mail.api.consumer.registered.sender.address") ?~ "Could not send mail: Missing props param for 'from'"
send : String <- APIUtil.getPropsValue("mail.api.consumer.registered.notification.send") if send.equalsIgnoreCase("true")
from <- APIUtil.getPropsValue("mail.api.consumer.registered.sender.address") ?~ "Could not send mail: Missing props param for 'from'"
} yield {
// Only send consumer key / secret by email if we explicitly want that.
@ -206,7 +206,7 @@ class ConsumerRegistration extends MdcLoggable {
val consumerKeyOrMessage : String = if (sendSensitive) registered.key.get else "Configured so sensitive data is not sent by email (Consumer Key)."
val consumerSecretOrMessage : String = if (sendSensitive) registered.secret.get else "Configured so sensitive data is not sent by email (Consumer Secret)."
val thisApiInstance = Props.get("hostname", "unknown host")
val thisApiInstance = APIUtil.getPropsValue("hostname", "unknown host")
val urlOAuthEndpoint = thisApiInstance + "/oauth/initiate"
val urlDirectLoginEndpoint = thisApiInstance + "/my/logins/direct"
val registrationMessage = s"Thank you for registering a Consumer on $thisApiInstance. \n" +
@ -248,12 +248,12 @@ class ConsumerRegistration extends MdcLoggable {
val mailSent = for {
// e.g mail.api.consumer.registered.sender.address=no-reply@example.com
from <- Props.get("mail.api.consumer.registered.sender.address") ?~ "Could not send mail: Missing props param for 'from'"
from <- APIUtil.getPropsValue("mail.api.consumer.registered.sender.address") ?~ "Could not send mail: Missing props param for 'from'"
// no spaces, comma separated e.g. mail.api.consumer.registered.notification.addresses=notify@example.com,notify2@example.com,notify3@example.com
toAddressesString <- Props.get("mail.api.consumer.registered.notification.addresses") ?~ "Could not send mail: Missing props param for 'to'"
toAddressesString <- APIUtil.getPropsValue("mail.api.consumer.registered.notification.addresses") ?~ "Could not send mail: Missing props param for 'to'"
} yield {
val thisApiInstance = Props.get("hostname", "unknown host")
val thisApiInstance = APIUtil.getPropsValue("hostname", "unknown host")
val registrationMessage = s"New user signed up for API keys on $thisApiInstance. \n" +
s"Email: ${registered.developerEmail.get} \n" +
s"App name: ${registered.name.get} \n" +

View File

@ -89,7 +89,7 @@ class Login {
// Used to display custom message to users when they login.
// For instance we can use it to display example login on a sandbox
def customiseLogin : CssSel = {
val specialLoginInstructions = scala.xml.Unparsed(Props.get("webui_login_page_special_instructions", ""))
val specialLoginInstructions = scala.xml.Unparsed(APIUtil.getPropsValue("webui_login_page_special_instructions", ""))
// In case we use Extraction.decompose
implicit val formats = net.liftweb.json.DefaultFormats
"#login-special-instructions *" #> specialLoginInstructions

View File

@ -119,7 +119,7 @@ object OAuthAuthorisation {
val oauthQueryParams: List[(String, String)] = ("oauth_token", unencodedTokenParam) ::("oauth_verifier", verifier) :: Nil
val applicationRedirectionUrl = appendParams(appToken.callbackURL.get, oauthQueryParams)
val encodedApplicationRedirectionUrl = urlEncode(applicationRedirectionUrl)
val redirectionUrl = Props.get("hostname", "") + OAuthWorkedThanks.menu.loc.calcDefaultHref
val redirectionUrl = APIUtil.getPropsValue("hostname", "") + OAuthWorkedThanks.menu.loc.calcDefaultHref
val redirectionParam = List(("redirectUrl", encodedApplicationRedirectionUrl))
//The URLs get from callbankURL or OAuthWorkedThanks, they are all internal ones, no open redirect issue.
S.redirectTo(appendParams(redirectionUrl, redirectionParam))

View File

@ -32,11 +32,12 @@ Berlin 13359, Germany
package code.snippet
import code.api.util.APIUtil
import code.api.util.APIUtil.getRemoteIpAddress
import code.util.Helper.MdcLoggable
import net.liftweb.http.{S, SessionVar}
import net.liftweb.util.CssSel
import net.liftweb.util.Helpers._
import net.liftweb.util.{CssSel, Props, _}
@ -75,51 +76,51 @@ class WebUI extends MdcLoggable{
}
def headerLogoLeft = {
"img [src]" #> Props.get("webui_header_logo_left_url", "")
"img [src]" #> APIUtil.getPropsValue("webui_header_logo_left_url", "")
}
def headerLogoRight: CssSel = {
"img [src]" #> Props.get("webui_header_logo_right_url", "")
"img [src]" #> APIUtil.getPropsValue("webui_header_logo_right_url", "")
}
def footer2LogoLeft = {
"img [src]" #> Props.get("webui_footer2_logo_left_url", "")
"img [src]" #> APIUtil.getPropsValue("webui_footer2_logo_left_url", "")
}
def footer2MiddleText: CssSel = {
"#footer2-middle-text *" #> scala.xml.Unparsed(Props.get("webui_footer2_middle_text", ""))
"#footer2-middle-text *" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_footer2_middle_text", ""))
}
def aboutBackground: CssSel = {
"#main-about [style]" #> ("background-image: url(" + Props.get("webui_index_page_about_section_background_image_url", "") + ");")
"#main-about [style]" #> ("background-image: url(" + APIUtil.getPropsValue("webui_index_page_about_section_background_image_url", "") + ");")
}
def aboutText: CssSel = {
"#main-about-text *" #> scala.xml.Unparsed(Props.get("webui_index_page_about_section_text", ""))
"#main-about-text *" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_index_page_about_section_text", ""))
}
def topText: CssSel = {
"#top-text *" #> scala.xml.Unparsed(Props.get("webui_top_text", ""))
"#top-text *" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_top_text", ""))
}
def apiExplorerLink: CssSel = {
val tags = S.attr("tags") openOr ""
".api-explorer-link a [href]" #> scala.xml.Unparsed(Props.get("webui_api_explorer_url", "") + s"?ignoredefcat=true&tags=$tags")
".api-explorer-link a [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_api_explorer_url", "") + s"?ignoredefcat=true&tags=$tags")
}
// Link to API Manager
def apiManagerLink: CssSel = {
".api-manager-link a [href]" #> scala.xml.Unparsed(Props.get("webui_api_manager_url", ""))
".api-manager-link a [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_api_manager_url", ""))
}
// Link to API Tester
def apiTesterLink: CssSel = {
".api-tester-link a [href]" #> scala.xml.Unparsed(Props.get("webui_api_tester_url", ""))
".api-tester-link a [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_api_tester_url", ""))
}
// Link to API
def apiLink: CssSel = {
val hostname = scala.xml.Unparsed(Props.get("hostname", ""))
val hostname = scala.xml.Unparsed(APIUtil.getPropsValue("hostname", ""))
".api-link a *" #> hostname &
".api-link a [href]" #> hostname
}
@ -128,41 +129,41 @@ class WebUI extends MdcLoggable{
// Social Finance (Sofi)
def sofiLink: CssSel = {
".sofi-link a [href]" #> scala.xml.Unparsed(Props.get("webui_sofi_url", ""))
".sofi-link a [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_sofi_url", ""))
}
// Points to the documentation. Probably a sandbox specific link is good.
def apiDocumentationLink: CssSel = {
".api-documentation-link a [href]" #> scala.xml.Unparsed(Props.get("webui_api_documentation_url", "https://github.com/OpenBankProject/OBP-API/wiki"))
".api-documentation-link a [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_api_documentation_url", "https://github.com/OpenBankProject/OBP-API/wiki"))
}
// For example customers and credentials
// This relies on the page for sandbox documentation having an anchor called example-customer-logins
def exampleSandboxCredentialsLink: CssSel = {
".example_sandbox_credentials_link a [href]" #> scala.xml.Unparsed(Props.get("webui_api_documentation_url", "") + "#customer-logins")
".example_sandbox_credentials_link a [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_api_documentation_url", "") + "#customer-logins")
}
// For link to OAuth Client SDKs
def sdksLink: CssSel = {
".sdks_link a [href]" #> scala.xml.Unparsed(Props.get("webui_sdks_url", "https://github.com/OpenBankProject/OBP-API/wiki/OAuth-Client-SDKS"))
".sdks_link a [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_sdks_url", "https://github.com/OpenBankProject/OBP-API/wiki/OAuth-Client-SDKS"))
}
// Text about data in FAQ
def faqDataText: CssSel = {
".faq-data-text *" #> scala.xml.Unparsed(Props.get("webui_faq_data_text", "This depends on the end point and/or OBP instance you are using. A combination of synthetic, anonymised and real data may be available. Please ask support for more information."))
".faq-data-text *" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_faq_data_text", "This depends on the end point and/or OBP instance you are using. A combination of synthetic, anonymised and real data may be available. Please ask support for more information."))
}
// Link to FAQ
def faqLink: CssSel = {
val link = scala.xml.Unparsed(Props.get("webui_faq_url", "https://openbankproject.com/faq/"))
val link = scala.xml.Unparsed(APIUtil.getPropsValue("webui_faq_url", "https://openbankproject.com/faq/"))
//".faq-link a *" #> link &
".faq-link a [href]" #> link
}
// Email address re FAQ
def faqEmail: CssSel = {
val email = scala.xml.Unparsed(Props.get("webui_faq_email", "contact@openbankproject.com"))
val email = scala.xml.Unparsed(APIUtil.getPropsValue("webui_faq_email", "contact@openbankproject.com"))
val emailMailto = scala.xml.Unparsed("mailto:" + email.toString())
".faq-email a *" #> email &
".faq-email a [href]" #> emailMailto
@ -170,16 +171,16 @@ class WebUI extends MdcLoggable{
// Page title
def pageTitle = {
val prefix = Props.get("webui_page_title_prefix", "Open Bank Project: ")
val prefix = APIUtil.getPropsValue("webui_page_title_prefix", "Open Bank Project: ")
scala.xml.XML.loadString(s"<title>$prefix<lift:Menu.title /></title>")
}
def mainStyleSheet: CssSel = {
"#main_style_sheet [href]" #> scala.xml.Unparsed(Props.get("webui_main_style_sheet", "/media/css/website.css"))
"#main_style_sheet [href]" #> scala.xml.Unparsed(APIUtil.getPropsValue("webui_main_style_sheet", "/media/css/website.css"))
}
def overrideStyleSheet: CssSel = {
val stylesheet = Props.get("webui_override_style_sheet", "")
val stylesheet = APIUtil.getPropsValue("webui_override_style_sheet", "")
if (stylesheet.isEmpty) {
"#override_style_sheet" #> ""
} else {
@ -202,7 +203,7 @@ class WebUI extends MdcLoggable{
val mainPartners: Option[String] = {
Props.get("webui_main_partners")
APIUtil.getPropsValue("webui_main_partners")
}

View File

@ -84,7 +84,7 @@ object TransactionRequests extends SimpleInjector {
val transactionRequestProvider = new Inject(buildOne _) {}
def buildOne: TransactionRequestProvider =
Props.get("transactionRequests_connector", "mapped") match {
APIUtil.getPropsValue("transactionRequests_connector", "mapped") match {
case "mapped" => APIUtil.getPropsAsBoolValue("use_akka", false) match {
case false => MappedTransactionRequestProvider
case true => RemotedataTransactionRequests // We will use Akka as a middleware

View File

@ -1,13 +1,12 @@
package code.TransactionTypes
import java.util.Date
import code.api.util.APIUtil
import code.api.v2_0_0.TransactionTypeJsonV200
import code.model._
import code.transaction_types.MappedTransactionTypeProvider
import net.liftweb.common.{Box, Logger}
import net.liftweb.util.{Props, SimpleInjector}
import net.liftweb.util.SimpleInjector
// See http://simply.liftweb.net/index-8.2.html for info about "vend" and SimpleInjector
@ -44,7 +43,7 @@ object TransactionType extends SimpleInjector {
val TransactionTypeProvider = new Inject(buildOne _) {}
def buildOne: TransactionTypeProvider =
Props.get("TransactionTypes_connector", "mapped") match {
APIUtil.getPropsValue("TransactionTypes_connector", "mapped") match {
case "mapped" => MappedTransactionTypeProvider
case ttc: String => throw new IllegalArgumentException("No such connector for Transaction Types: " + ttc)
}

View File

@ -3,6 +3,7 @@ package code.util
import java.net.{Socket, SocketException}
import java.util.{Date, GregorianCalendar}
import code.api.util.APIUtil
import code.api.APIFailureNewStyle
import code.api.util.APIUtil.fullBoxOrException
import net.liftweb.common._
@ -10,7 +11,6 @@ import net.liftweb.json.Extraction._
import net.liftweb.json.JsonAST._
import net.liftweb.json.{DateFormat, Formats}
import net.liftweb.util.Helpers._
import net.liftweb.util.Props
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
@ -241,7 +241,7 @@ object Helper{
}
def getHostname(): String = {
Props.get("hostname", "") match {
APIUtil.getPropsValue("hostname", "") match {
case s: String if s.nonEmpty => s.split(":").lift(1) match {
case Some(s) => s.replaceAll("\\/", "").replaceAll("\\.", "-")
case None => "unknown"
@ -251,7 +251,7 @@ object Helper{
}
def getRemotedataHostname(): String = {
Props.get("remotedata.hostname", "") match {
APIUtil.getPropsValue("remotedata.hostname", "") match {
case s: String if s.nonEmpty => s.replaceAll("\\/", "").replaceAll("\\.", "-")
case _ => "unknown"
}

View File

@ -1,11 +1,9 @@
package code.yearlycustomercharges
import code.bankconnectors.{KafkaMappedConnector, LocalRecordConnector, LocalMappedConnector}
import code.model.{CustomerId, BankId}
import code.api.util.APIUtil
import code.model.{BankId, CustomerId}
import net.liftweb.common.Logger
import net.liftweb.util.{Props, SimpleInjector}
import net.liftweb.util.SimpleInjector
object YearlyCharge extends SimpleInjector {
@ -14,7 +12,7 @@ object YearlyCharge extends SimpleInjector {
// This determines the provider we use
def buildOne: YearlyChargeProvider =
Props.get("provider.thing").openOr("mapped") match {
APIUtil.getPropsValue("provider.thing").openOr("mapped") match {
case "mapped" => MappedYearlyChargeProvider
case _ => MappedYearlyChargeProvider
}

View File

@ -5,11 +5,10 @@ import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
object TestServer {
import net.liftweb.util.Props
val host = "localhost"
val port = APIUtil.getPropsAsIntValue("tests.port",8000)
val externalHost = Props.get("external.hostname")
val externalHost = APIUtil.getPropsValue("external.hostname")
val externalPort = APIUtil.getPropsAsIntValue("external.port")
val server = new Server(port)

View File

@ -33,26 +33,26 @@ Berlin 13359, Germany
package code.api
import java.util.ResourceBundle
import code.api.util.ErrorMessages._
import code.api.util.APIUtil.OAuth._
import code.api.util.ErrorMessages
import code.api.util.ErrorMessages._
import code.api.util.{APIUtil, ErrorMessages}
import code.consumer.Consumers
import code.loginattempts.LoginAttempt
import code.model.dataAccess.AuthUser
import code.model.{Consumer => OBPConsumer, Token => OBPToken}
import code.setup.ServerSetup
import code.util.Helper.MdcLoggable
import dispatch.Defaults._
import dispatch._
import net.liftweb.common.{Box, Failure}
import net.liftweb.http.LiftRules
import net.liftweb.util.Helpers._
import net.liftweb.util.Props
import org.scalatest._
import org.scalatest.selenium._
import scala.concurrent.Await
import scala.concurrent.duration._
import code.util.Helper.MdcLoggable
case class OAuthResponse(
code: Int,
@ -64,7 +64,7 @@ class OAuthTest extends ServerSetup {
def oauthRequest = baseRequest / "oauth"
//a url that will be guaranteed to resolve when the oauth redirects us to it
val selfCallback = Props.get("hostname").openOrThrowException("hostname not set")
val selfCallback = APIUtil.getPropsValue("hostname").openOrThrowException("hostname not set")
val accountValidationError = ResourceBundle.getBundle(LiftRules.liftCoreResourceName).getObject("account.validation.error").toString

View File

@ -48,6 +48,7 @@ TESOBE (http://www.tesobe.com/)
import java.util.Date
import code.api.util.APIUtil
import code.api.v2_2_0.FXRateJsonV220
import code.setup.SendServerRequests
import code.util.ObpJson._
@ -79,10 +80,10 @@ object PutFX extends SendServerRequests {
// this sets the date format to "yyyy-MM-dd'T'HH:mm:ss'Z'" i.e. ISO 8601 No milliseconds UTC
implicit val formats = DefaultFormats // Brings in default date formats etc.
val adminUserUsername = Props.get("import.admin_user.username").getOrElse("ERROR")
val adminUserUsername = APIUtil.getPropsValue("import.admin_user.username").getOrElse("ERROR")
println(s"adminUserUsername is $adminUserUsername")
val adminUserPassword = Props.get("import.admin_user.password").getOrElse("ERROR")
val adminUserPassword = APIUtil.getPropsValue("import.admin_user.password").getOrElse("ERROR")
println(s"adminUserPassword is $adminUserPassword")
//println("Got " + customers.length + " records")
@ -133,7 +134,7 @@ object PutFX extends SendServerRequests {
val url = s"/v3.0.0/banks/${b.id}/fx"
//load json for fx rates
val fxDataPath = Props.get("import.fx_data_path")
val fxDataPath = APIUtil.getPropsValue("import.fx_data_path")
println(s"fxDataPath is $fxDataPath")

View File

@ -2,6 +2,8 @@ package code.management
import java.text.SimpleDateFormat
import java.util.TimeZone
import code.api.util.APIUtil
import code.api.util.ErrorMessages._
import code.bankconnectors.Connector
import code.model.{AccountId, Transaction}
@ -24,7 +26,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
}
val secretKeyHttpParamName = "secret"
val secretKeyValue = Props.get("importer_secret").openOrThrowException("Prop importer_secret not specified.")
val secretKeyValue = APIUtil.getPropsValue("importer_secret").openOrThrowException("Prop importer_secret not specified.")
val dummyKind = "Transfer"

View File

@ -47,28 +47,23 @@ TESOBE (http://www.tesobe.com/)
* into your props file.
* */
import java.util.{UUID, Date}
import java.util.{Date, UUID}
import code.api.util.APIUtil
import code.api.v1_2_1.AmountOfMoneyJsonV121
import code.api.v1_4_0.JSONFactory1_4_0.CustomerFaceImageJson
import code.util.ObpJson._
import code.api._
import code.api.v2_0_0.JSONFactory200.UserJsonV200
import code.api.v2_1_0.{CustomerCreditRatingJSON, PostCustomerJsonV210}
import code.setup.SendServerRequests
import code.util.ObpJson._
import code.util.{OAuthClient, ObpGet, ObpPost}
import net.liftweb.common.{Box, Empty, Full}
import net.liftweb.http.RequestVar
import net.liftweb.json._
import net.liftweb.util.Props
import scala.collection.mutable.ListBuffer
import scala.io.Source
import code.api.v2_1_0.{PostCustomerJsonV210, CustomerCreditRatingJSON, CustomerJsonV210}
import code.api.v1_4_0.JSONFactory1_4_0.CustomerFaceImageJson
import code.api.v2_0_0.JSONFactory200.UserJsonV200
case class CustomerFullJson(customer_number : String,
legal_name : String,
@ -96,14 +91,14 @@ object PostCustomer extends SendServerRequests {
// this sets the date format to "yyyy-MM-dd'T'HH:mm:ss'Z'" i.e. ISO 8601 No milliseconds UTC
implicit val formats = DefaultFormats // Brings in default date formats etc.
val adminUserUsername = Props.get("import.admin_user.username").getOrElse("ERROR")
val adminUserUsername = APIUtil.getPropsValue("import.admin_user.username").getOrElse("ERROR")
println(s"adminUserUsername is $adminUserUsername")
val adminUserPassword = Props.get("import.admin_user.password").getOrElse("ERROR")
val adminUserPassword = APIUtil.getPropsValue("import.admin_user.password").getOrElse("ERROR")
println(s"adminUserPassword is $adminUserPassword")
//load json for customers
val customerDataPath = Props.get("import.customer_data_path")
val customerDataPath = APIUtil.getPropsValue("import.customer_data_path")
println(s"customerDataPath is $customerDataPath")
@ -128,7 +123,7 @@ object PostCustomer extends SendServerRequests {
//load sandbox users from json
val mainDataPath = Props.get("import.main_data_path")
val mainDataPath = APIUtil.getPropsValue("import.main_data_path")
println(s"mainDataPath is $mainDataPath")

View File

@ -84,9 +84,9 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
def sandboxApiPrefix = baseRequest / "obp" / "vsandbox"
//users should automatically be assigned the "hostname" as a provider (for now at least)
val defaultProvider = Props.get("hostname").openOrThrowException("no hostname set")
val defaultProvider = APIUtil.getPropsValue("hostname").openOrThrowException("no hostname set")
val theImportToken = Props.get("sandbox_data_import_secret").openOrThrowException("sandbox_data_import_secret not set")
val theImportToken = APIUtil.getPropsValue("sandbox_data_import_secret").openOrThrowException("sandbox_data_import_secret not set")
override def beforeEach() = {
//drop database tables before

View File

@ -42,7 +42,7 @@ trait DefaultUsers {
lazy val tokenDuration = weeks(expiration)
// Create resource user, need provider
val defaultProvider = Props.get("hostname", "")
val defaultProvider = APIUtil.getPropsValue("hostname", "")
// create some resource user for test purposes
lazy val resourceUser1 = User.createResourceUser(defaultProvider, None, None, None, userId).openOrThrowException(attemptedToOpenAnEmptyBox)

View File

@ -34,9 +34,9 @@ package code.util
import java.net.{URI, URLDecoder}
import code.api.util.APIUtil
import code.util.Helper.MdcLoggable
import net.liftweb.common.{Box, Empty, Failure, Full}
import net.liftweb.util.Props
import oauth.signpost.basic.{DefaultOAuthConsumer, DefaultOAuthProvider}
import oauth.signpost.{OAuthConsumer, OAuthProvider}
import org.apache.http.client.utils.URLEncodedUtils
@ -67,7 +67,7 @@ sealed trait Provider {
trait DefaultProvider extends Provider {
val name = "The Open Bank Project Demo"
val baseUrl = Props.get("target_api_hostname", "")
val baseUrl = APIUtil.getPropsValue("target_api_hostname", "")
val apiBaseUrl = baseUrl + "/obp"
val requestTokenUrl = baseUrl + "/oauth/initiate"
val accessTokenUrl = baseUrl + "/oauth/token"
@ -76,8 +76,8 @@ trait DefaultProvider extends Provider {
lazy val oAuthProvider : OAuthProvider = new DefaultOAuthProvider(requestTokenUrl, accessTokenUrl, authorizeUrl)
val consumerKey = Props.get("obp_consumer_key", "")
val consumerSecret = Props.get("obp_secret_key", "")
val consumerKey = APIUtil.getPropsValue("obp_consumer_key", "")
val consumerSecret = APIUtil.getPropsValue("obp_secret_key", "")
}
object OBPDemo extends DefaultProvider

View File

@ -5,6 +5,7 @@ import java.net.{HttpURLConnection, URL}
import java.text.SimpleDateFormat
import java.util.Date
import code.api.util.APIUtil
import code.util.Helper.MdcLoggable
import code.util.ObpJson._
import net.liftweb.common.{Box, Empty, Failure, Full}
@ -13,7 +14,6 @@ import net.liftweb.json.JsonAST.JValue
import net.liftweb.json.JsonDSL._
import net.liftweb.json.{JObject, _}
import net.liftweb.util.Helpers._
import net.liftweb.util.Props
case class Header(key: String, value: String)
case class ObpError(error :String)
@ -22,7 +22,7 @@ object ObpAPI extends MdcLoggable {
implicit val formats = DefaultFormats
val dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
val defaultProvider = Props.get("defaultAuthProvider").getOrElse("")
val defaultProvider = APIUtil.getPropsValue("defaultAuthProvider").getOrElse("")
val userNotFoundError = "user (\\S+) at provider (\\S+) not found".r