Class: Identikey::Provisioning

Inherits:
Base
  • Object
show all
Defined in:
lib/identikey/provisioning.rb

Overview

This class wraps the Provisioning API.

Constant Summary

Constants inherited from Base

Base::DEFAULTS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, configure, default_user_agent_header, #endpoint, identikey_filter_proc_for, process_identikey_filters, #wsdl

Class Method Details

.cronto_code_for_srp_registration(gateway:, **kwargs) ⇒ Object

Wraps dsapp_srp_register and returns directly the activation message through which a CRONTO image can be generated, to be used for push notifications setups in combination with a MDC configured on your OneSpan control panel and on Identikey.

You may want to look into github.com/ifad/cronto for a generator to produce PNGs to deliver to your clients.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/identikey/provisioning.rb', line 67

def self.cronto_code_for_srp_registration(gateway:, **kwargs)
  status, result, error = new.dsapp_srp_register(**kwargs)

  if status != 'STAT_SUCCESS'
    raise Identikey::OperationFailed, "Error while assigning DAL: #{status} - #{[error].flatten.join('; ')}"
  end

  # Compose proprietary string
  message = '01;01;%s;%s;%s;%s;%s' % [
    result[:user][:user_id],
    result[:user][:domain],
    result[:registration_id],
    result[:activation_password],
    gateway
  ]

  # Encode it as hex
  return message.split(//).map {|c| '%x' % c.ord}.join
end

Instance Method Details

#dsapp_srp_register(component:, user:, domain:, password:) ⇒ Object

dsappSRPRegister



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/identikey/provisioning.rb', line 43

def dsapp_srp_register(component:, user:, domain:, password:)
  resp = super(message: {
    componentType: component,
    user: {
      userID: user,
      domain: domain,
    },
    credential: {
      staticPassword: password
    }
  })

  parse_response resp, :dsapp_srp_register_response
end

#provisioning_execute(cmd:, attributes:) ⇒ Object

PROVISIONING_EXECUTE



15
16
17
18
19
20
21
22
23
24
# File 'lib/identikey/provisioning.rb', line 15

def provisioning_execute(cmd:, attributes:)
  resp = super(message: {
    cmd: cmd,
    attributeSet: {
      attributes: attributes
    }
  })

  parse_response resp, :provisioning_execute_response
end

#provisioning_execute_MDL_REGISTER(component:, user:, domain:, password:) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/identikey/provisioning.rb', line 26

def provisioning_execute_MDL_REGISTER(component:, user:, domain:, password:)
  provisioning_execute(
    cmd: 'PROVISIONCMD_MDL_REGISTER',
    attributes: typed_attributes_list_from(
      PROVFLD_USERID:          user,
      PROVFLD_DOMAIN:          domain,
      PROVFLD_COMPONENT_TYPE:  component,
      PROVFLD_STATIC_PASSWORD: password,
      PROVFLD_ACTIVATION_TYPE: Unsigned(0),
    )
  )
end