Skip to content

Commit

Permalink
MOPPIOS-602 - Configuration initializing changes
Browse files Browse the repository at this point in the history
MOPPIOS-602 - MOPPi võimekus kasutada keskhaldust
  • Loading branch information
martenrebane committed Nov 11, 2019
1 parent 67e4026 commit 506bb77
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions MoppApp/MoppApp/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Foundation

internal struct MOPPConfiguration: Codable {
let MIDSIGNURL: String
var TSLURL: String
let SIVAURL: String
let METAINF: MOPPMetaInf
let TSAURL: String
Expand All @@ -36,6 +37,7 @@ internal struct MOPPConfiguration: Codable {

private enum MOPPConfigurationType: String, CodingKey {
case MIDSIGNURL = "MID-SIGN-URL"
case TSLURL = "TSL-URL"
case SIVAURL = "SIVA-URL"
case METAINF = "META-INF"
case TSAURL = "TSA-URL"
Expand All @@ -48,6 +50,7 @@ internal struct MOPPConfiguration: Codable {
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: MOPPConfigurationType.self)
MIDSIGNURL = try container.decode(String.self, forKey: .MIDSIGNURL)
TSLURL = try container.decode(String.self, forKey: .TSLURL)
SIVAURL = try container.decode(String.self, forKey: .SIVAURL)
METAINF = try container.decode(MOPPMetaInf.self, forKey: .METAINF)
TSAURL = try container.decode(String.self, forKey: .TSAURL)
Expand Down
2 changes: 1 addition & 1 deletion MoppApp/MoppApp/DiagnosticsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DiagnosticsViewController: MoppViewController {
let decodedConf = getMoppConfiguration()

configURL.text = formatString(text: "CONFIG_URL:", additionalText: decodedConf.METAINF.URL)
tslURL.text = formatString(text: "TSL_URL:", additionalText: SettingsConfiguration().getDefaultMoppConfiguration().TSLURL)
tslURL.text = formatString(text: "TSL_URL:", additionalText: getMoppConfiguration().TSLURL)
sivaURL.text = formatString(text: "SIVA_URL:", additionalText: decodedConf.SIVAURL)
tsaURL.text = formatString(text: "TSA_URL:", additionalText: decodedConf.TSAURL)
midSignURL.text = formatString(text: "MID-SIGN-URL:", additionalText: decodedConf.MIDSIGNURL)
Expand Down
7 changes: 5 additions & 2 deletions MoppApp/MoppApp/SettingsConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class SettingsConfiguration: NSObject, URLSessionDelegate, URLSessionTaskDelegat
setAllConfigurationToCache(configData: localConfigData, signature: localSignature, initialUpdateDate: MoppDateFormatter().stringToDate(dateString: getDefaultMoppConfiguration().UPDATEDATE), versionSerial: decodedData.METAINF.SERIAL)
setConfigurationToCache("", forKey: "lastUpdateDateCheck")

setupMoppConfiguration(sivaUrl: decodedData.SIVAURL, tslUrl: getDefaultMoppConfiguration().TSLURL, tslCerts: decodedData.TSLCERTS, tsaUrl: decodedData.TSAURL, ocspIssuers: decodedData.OCSPISSUERS)
setupMoppConfiguration(sivaUrl: decodedData.SIVAURL, tslUrl: decodedData.TSLURL, tslCerts: decodedData.TSLCERTS, tsaUrl: decodedData.TSAURL, ocspIssuers: decodedData.OCSPISSUERS)
setupMoppLDAPConfiguration(ldapPersonUrl: decodedData.LDAPPERSONURL, ldapCorpUrl: decodedData.LDAPCORPURL)

setMoppConfiguration(configuration: decodedData)
Expand All @@ -113,7 +113,8 @@ class SettingsConfiguration: NSObject, URLSessionDelegate, URLSessionTaskDelegat
_ = try SignatureVerifier().isSignatureCorrect(configData: trim(text: cachedConfigData)!, publicKey: localPublicKey, signature: cachedSignature)

let decodedData = try MoppConfigurationDecoder().decodeMoppConfiguration(configData: cachedConfigData)
setupMoppConfiguration(sivaUrl: decodedData.SIVAURL, tslUrl: getDefaultMoppConfiguration().TSLURL, tslCerts: decodedData.TSLCERTS, tsaUrl: decodedData.TSAURL, ocspIssuers: decodedData.OCSPISSUERS)
setupMoppConfiguration(sivaUrl: decodedData.SIVAURL, tslUrl: decodedData.TSLURL, tslCerts: decodedData.TSLCERTS, tsaUrl: decodedData.TSAURL, ocspIssuers: decodedData.OCSPISSUERS)

setupMoppLDAPConfiguration(ldapPersonUrl: decodedData.LDAPPERSONURL, ldapCorpUrl: decodedData.LDAPCORPURL)

setMoppConfiguration(configuration: decodedData)
Expand All @@ -139,6 +140,8 @@ class SettingsConfiguration: NSObject, URLSessionDelegate, URLSessionTaskDelegat

setMoppConfiguration(configuration: decodedData)

setupMoppConfiguration(sivaUrl: decodedData.SIVAURL, tslUrl: decodedData.TSLURL, tslCerts: decodedData.TSLCERTS, tsaUrl: decodedData.TSAURL, ocspIssuers: decodedData.OCSPISSUERS)

reloadDigiDocConf()

} else {
Expand Down

0 comments on commit 506bb77

Please sign in to comment.