class Nexpose::PasswordPolicy
Configuration structure for password policies.
Attributes
capitals[RW]
digits[RW]
expiration_days[RW]
max_length[RW]
min_length[RW]
policy_name[RW]
special_chars[RW]
Public Class Methods
from_hash(hash)
click to toggle source
# 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)
click to toggle source
# 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
new(policy_name:, min_length:, max_length:, special_chars:, capitals:, digits:, expiration_days: 0)
click to toggle source
# 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
Public Instance Methods
save(nsc)
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/nexpose/password_policy.rb, line 45 def to_json JSON.generate(to_h) end