Class: Nexpose::PasswordPolicy
- Defined in:
- lib/nexpose/password_policy.rb
Overview
Configuration structure for password policies.
Instance Attribute Summary collapse
-
#capitals ⇒ Object
Returns the value of attribute capitals.
-
#digits ⇒ Object
Returns the value of attribute digits.
-
#expiration_days ⇒ Object
Returns the value of attribute expiration_days.
-
#max_length ⇒ Object
Returns the value of attribute max_length.
-
#min_length ⇒ Object
Returns the value of attribute min_length.
-
#policy_name ⇒ Object
Returns the value of attribute policy_name.
-
#special_chars ⇒ Object
Returns the value of attribute special_chars.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(policy_name:, min_length:, max_length:, special_chars:, capitals:, digits:, expiration_days: 0) ⇒ PasswordPolicy
constructor
A new instance of PasswordPolicy.
- #save(nsc) ⇒ Object
- #to_h ⇒ Object
- #to_json ⇒ Object
Methods inherited from APIObject
Constructor Details
#initialize(policy_name:, min_length:, max_length:, special_chars:, capitals:, digits:, expiration_days: 0) ⇒ PasswordPolicy
Returns a new instance of PasswordPolicy.
13 14 15 16 17 18 19 20 21 |
# File 'lib/nexpose/password_policy.rb', line 13 def initialize(policy_name:, min_length:, max_length:, special_chars:, capitals:, digits:, expiration_days: 0) @policy_name = policy_name.to_s @min_length = min_length.to_i @max_length = max_length.to_i @special_chars = special_chars.to_i @capitals = capitals.to_i @digits = digits.to_i @expiration_days = expiration_days.to_i end |
Instance Attribute Details
#capitals ⇒ Object
Returns the value of attribute capitals.
8 9 10 |
# File 'lib/nexpose/password_policy.rb', line 8 def capitals @capitals end |
#digits ⇒ Object
Returns the value of attribute digits.
9 10 11 |
# File 'lib/nexpose/password_policy.rb', line 9 def digits @digits end |
#expiration_days ⇒ Object
Returns the value of attribute expiration_days.
11 12 13 |
# File 'lib/nexpose/password_policy.rb', line 11 def expiration_days @expiration_days end |
#max_length ⇒ Object
Returns the value of attribute max_length.
7 8 9 |
# File 'lib/nexpose/password_policy.rb', line 7 def max_length @max_length end |
#min_length ⇒ Object
Returns the value of attribute min_length.
6 7 8 |
# File 'lib/nexpose/password_policy.rb', line 6 def min_length @min_length end |
#policy_name ⇒ Object
Returns the value of attribute policy_name.
5 6 7 |
# File 'lib/nexpose/password_policy.rb', line 5 def policy_name @policy_name end |
#special_chars ⇒ Object
Returns the value of attribute special_chars.
10 11 12 |
# File 'lib/nexpose/password_policy.rb', line 10 def special_chars @special_chars end |
Class Method Details
.from_hash(hash) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/nexpose/password_policy.rb', line 23 def self.from_hash(hash) new(policy_name: hash[:policyName], min_length: hash[:minLength], max_length: hash[:maxLength], special_chars: hash[:specialChars], capitals: hash[:capitals], digits: hash[:digits], expiration_days: hash[:expirationDays]) end |
.load(nsc) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/nexpose/password_policy.rb', line 54 def self.load(nsc) uri = '/api/2.1/password_policy/' resp = AJAX.get(nsc, uri, AJAX::CONTENT_TYPE::JSON) hash = JSON.parse(resp, symbolize_names: true) self.from_hash(hash) end |
Instance Method Details
#save(nsc) ⇒ Object
49 50 51 52 |
# File 'lib/nexpose/password_policy.rb', line 49 def save(nsc) params = to_json AJAX.post(nsc, '/api/2.1/password_policy/', params, AJAX::CONTENT_TYPE::JSON) end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/nexpose/password_policy.rb', line 33 def to_h { policyName: @policy_name, minLength: @min_length, maxLength: @max_length, specialChars: @special_chars, capitals: @capitals, digits: @digits, expirationDays: @expiration_days } end |
#to_json ⇒ Object
45 46 47 |
# File 'lib/nexpose/password_policy.rb', line 45 def to_json JSON.generate(to_h) end |