Skip to content

Commit

Permalink
Adding conditional calling of the idpCollector and registering during…
Browse files Browse the repository at this point in the history
… CollectorFactory initialization
  • Loading branch information
george-bafaloukas-forgerock committed Feb 6, 2025
1 parent 53f1afb commit 6eda720
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Davinci/Davinci/Davinci.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extension DaVinci {
cookieConfig.persist = [Request.Constants.stCookie, Request.Constants.stNoSsCookie]
}

CollectorFactory.shared.registerDefaultCollectors()

// Apply custom configuration
block(config)

Expand Down
10 changes: 8 additions & 2 deletions Davinci/Davinci/collector/CollectorFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// of the MIT license. See the LICENSE file for details.
//


import Foundation
import PingOrchestrate

/// The CollectorFactory singleton is responsible for creating and managing Collector instances.
Expand All @@ -21,7 +21,10 @@ public final class CollectorFactory {
/// The shared instance of the CollectorFactory.
public static let shared = CollectorFactory()

init() {
init() { }

/// Registers the default DaVinci Collectors.
public func registerDefaultCollectors() {
register(type: Constants.TEXT, collector: TextCollector.self)//
register(type: Constants.PASSWORD, collector: PasswordCollector.self)
register(type: Constants.PASSWORD_VERIFY, collector: PasswordCollector.self)
Expand All @@ -33,6 +36,9 @@ public final class CollectorFactory {
register(type: Constants.RADIO, collector: SingleSelectCollector.self)
register(type: Constants.COMBOBOX, collector: MultiSelectCollector.self)
register(type: Constants.CHECKBOX, collector: MultiSelectCollector.self)
if let c: NSObject.Type = NSClassFromString("Extrernal_idp.IdpCollector") as? NSObject.Type {
c.perform(Selector(("registerCollector")))
}
}

/// Registers a new type of Collector.
Expand Down
8 changes: 7 additions & 1 deletion Extrernal-idp/Extrernal-idp/IdpCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import Foundation
import PingOrchestrate
import PingDavinci

public class IdpCollector: Collector, ContinueNodeAware, RequestInterceptor {
@objc
public class IdpCollector: NSObject, Collector, ContinueNodeAware, RequestInterceptor {

public var continueNode: PingOrchestrate.ContinueNode?

Expand Down Expand Up @@ -60,6 +61,11 @@ public class IdpCollector: Collector, ContinueNodeAware, RequestInterceptor {
}
}

@objc
public static func registerCollector() {
CollectorFactory.shared.register(type: Constants.SOCIAL_LOGIN_BUTTON, collector: IdpCollector.self)
}

public func authorize() async -> Result<Bool, IdpExceptions> {
do {

Expand Down
3 changes: 0 additions & 3 deletions SampleApps/PingExample/PingExample/DavinciViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public let davinci = DaVinci.createDaVinci { config in
oidcValue.redirectUri = currentConfig?.redirectUri ?? ""
oidcValue.discoveryEndpoint = currentConfig?.discoveryEndpoint ?? ""
}
#if canImport(Extrernal_idp)
CollectorFactory.shared.register(type: Constants.SOCIAL_LOGIN_BUTTON, collector: IdpCollector.self)
#endif
}

// A view model that manages the flow and state of the DaVinci orchestration process.
Expand Down

0 comments on commit 6eda720

Please sign in to comment.