It is possible to request a new activation for an existing personalization. The goal of this process is to create a new
activation that then can be used by another XignSys SDK (app that integrates the SDK). The newly requested activation is
temporary and will only become permanent if it is personalized. At the end of this process the personalization
initialization data are returned as base64 encoded String and can be displayed as a QR Code by the app. Optionally an
email can be sent to the user with the new temporary activation. The process starts by invoking the
function Personalizer.startRequestNewActivationDataSynchronous(idmIdentifier:) with the idmIdentifier of the
XignIn-Manager the user account belongs to. The result of the function is an AuthenticationInitializationData object
which can be used to start and finish an authentication process. For that purpose, please refer to the
chapter Starting an authentication.
The result of the final function of the authentication process Authenticator.finishAuthenticationSynchronous(:)returns
an AuthenticationResult of the type ApiAccessRequestNewActivationData. This object must be supplemented with at
least a new activation PIN by invoking ApiAccessRequestNewActivationData.pinSpec.setPin(:). An alias can also be
specified optionally. The alias is used as a display name of the activation e.g., during a recovery. Furthermore, if the
user should receive an email with the activation data after the process is finished, the
property ApiAccessRequestNewActivationData.shouldSendEmail can be set to true. The following example shows how the
process can be completed:
func finishRequestNewActivation(apiAccessRequest: ApiAccessRequestNewActivationData) throws {
// retrieve the pin specification
let pinSpec: PinSpecification = apiAccessRequest.pinSpec
var isPinValid: Bool = false
var errorText: String? = nil
while !isPinValid {
// query the user for the pin and optionally show previous errors
let pin: String = YourImplementation.askUserForPin(
minLength: pinSpec.minLength,
maxLength: pinSpec.maxLength,
errorText: errorText
)
let pinError: PinValidator.ResultCode = pinSpec.setPin(pin)
switch pinError {
case .valid:
// pin is ok, continue
isPinValid = true
case .empty:
errorText = "PIN must not be empty"
case .onlyNumbers:
errorText = "Only numbers are allowed"
case .tooShort:
errorText = "PIN must be at least \(pinSpec.minLength) digits long"
case .tooLong:
errorText = "PIN can't be longer than \(pinSpec.maxLength) digits"
}
}
// Optionally ask the user for an alias. If no designated value is available, this step can be skipped.
apiAccessRequest.setAlias("the_alias")
// Set this property to `true` if the user should receive an email with the activation data, for
// example to be used as a backup. Beware that the XignIn-Manager needs a valid email address
// of the user which might not be available in some setups.
apiAccessRequest.shouldSendEmail = true
// create a new temporary activation on the server
let activationData: ActivationData =
try XignSdk.shared.personalizer.finishRequestNewActivationDataSynchronous(apiAccessRequest)
// the expiration date of this temporary new activation
activationData.validUntil
// The activation data as base64 string. This can be converted to a QR Code to be displayed to the user.
activationData.pid
}
fun finishRequestNewActivation(apiAccessRequest: ApiAccessRequestNewActivationData) {
// retrieve the pin specification
val pinSpec: PinSpecification = apiAccessRequest.pinSpec
var isPinValid: Boolean = false
var errorText: String? = null
while (!isPinValid) {
// query the user for the pin and optionally show previous errors
val pin: String = YourImplementation.askUserForPin(
pinSpec.minLength,
pinSpec.maxLength,
errorText
)
val pinError: PinValidator.ErrorCode = pinSpec.setPin(pin)
when (pinError) {
PinValidator.ErrorCode.VALID -> {
// pin is ok, continue
isPinValid = true
}
PinValidator.ErrorCode.EMPTY ->
errorText = "PIN must not be empty"
PinValidator.ErrorCode.ONLY_NUMBERS ->
errorText = "Only numbers are allowed"
PinValidator.ErrorCode.TOO_SHORT ->
errorText = "PIN must be at least ${pinSpec.minLength} digits long"
PinValidator.ErrorCode.TOO_LONG ->
errorText = "PIN can't be longer than ${pinSpec.maxLength} digits"
}
}
// Optionally ask the user for an alias. If no designated value is available, this step can be skipped.
apiAccessRequest.setAlias("the_alias")
// Set this property to `true` if the user should receive an email with the activation data, for
// example to be used as a backup. Beware that the XignIn-Manager needs a valid email address
// of the user which might not be available in some setups.
apiAccessRequest.shouldSendEmail = true
// Create a new temporary activation on the server.
val activationData: ActivationData =
XignSdk.shared.personalizer.finishRequestNewActivationDataSynchronous(apiAccessRequest)
// The expiration date of this temporary new activation
activationData.validUntil
// The activation data as base64 string. This can be converted to a QR Code to be displayed to the user.
activationData.pid
}