Class: KeycloakAdmin::CredentialRepresentation

Inherits:
Representation show all
Defined in:
lib/keycloak-admin/representation/credential_representation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Representation

#as_json, #to_json

Methods included from CamelJson

#camelize

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def algorithm
  @algorithm
end

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def config
  @config
end

#counterObject

Returns the value of attribute counter.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def counter
  @counter
end

#createdDateObject

Returns the value of attribute createdDate.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def createdDate
  @createdDate
end

#credentialDataObject

Returns the value of attribute credentialData.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def credentialData
  @credentialData
end

#deviceObject

Returns the value of attribute device.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def device
  @device
end

#digitsObject

Returns the value of attribute digits.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def digits
  @digits
end

#hashedSaltedValueObject

Returns the value of attribute hashedSaltedValue.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def hashedSaltedValue
  @hashedSaltedValue
end

#hashIterationsObject

Returns the value of attribute hashIterations.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def hashIterations
  @hashIterations
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def id
  @id
end

#periodObject

Returns the value of attribute period.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def period
  @period
end

#saltObject

Returns the value of attribute salt.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def salt
  @salt
end

#secretDataObject

Returns the value of attribute secretData.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def secretData
  @secretData
end

#temporaryObject

Returns the value of attribute temporary.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def temporary
  @temporary
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def type
  @type
end

#userLabelObject

Returns the value of attribute userLabel.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def userLabel
  @userLabel
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 3

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 34

def self.from_hash(hash)
  credential = new
  hash.each do |key, value|
    if credential.respond_to?("#{key}=")
      credential.public_send("#{key}=", value)
    end
  end

  nested_attributes = safely_parse_nested_json(hash["credentialData"]).merge(safely_parse_nested_json(hash["secretData"]))

  nested_attributes.each do |key, value|
    if credential.respond_to?("#{key}=")
      current_value = credential.public_send(key)
      if current_value.nil?
        credential.public_send("#{key}=", value)
      end
    end
  end

  credential
end

.from_json(json) ⇒ Object



29
30
31
32
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 29

def self.from_json(json)
  attributes = JSON.parse(json)
  from_hash(attributes)
end

.from_password(password, temporary = false) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/keycloak-admin/representation/credential_representation.rb', line 21

def self.from_password(password, temporary=false)
  credential = new
  credential.value     = password
  credential.type      = "password"
  credential.temporary = temporary
  credential
end