Class: RSAML::Action
- Inherits:
-
Object
- Object
- RSAML::Action
- Includes:
- Validatable
- Defined in:
- lib/rsaml/action.rb
Overview
Specifies an action on the specified resource for which permission is sought. Its value provides the label for an action sought to be performed on the specified resource.
Instance Attribute Summary collapse
-
#namespace ⇒ Object
The action namespace.
-
#value ⇒ Object
The action value.
Attributes included from Validatable
Class Method Summary collapse
-
.from_xml(element) ⇒ Object
Construct an Action instance from the given XML Element or fragment.
-
.namespaces ⇒ Object
Identifiers that MAY be used in the namespace attribute of the Action element to refer to common sets of actions to perform on resources.
Instance Method Summary collapse
-
#initialize(value) ⇒ Action
constructor
Initialize the action with the given value.
-
#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object
Construct an XML fragment representing the action.
-
#validate ⇒ Object
Validate the structure.
Methods included from Validatable
Constructor Details
#initialize(value) ⇒ Action
Initialize the action with the given value.
25 26 27 |
# File 'lib/rsaml/action.rb', line 25 def initialize(value) @value = value end |
Instance Attribute Details
#namespace ⇒ Object
The action namespace.
19 20 21 |
# File 'lib/rsaml/action.rb', line 19 def namespace @namespace end |
#value ⇒ Object
The action value
22 23 24 |
# File 'lib/rsaml/action.rb', line 22 def value @value end |
Class Method Details
.from_xml(element) ⇒ Object
Construct an Action instance from the given XML Element or fragment.
48 49 50 51 52 53 54 55 |
# File 'lib/rsaml/action.rb', line 48 def self.from_xml(element) element = REXML::Document.new(element).root if element.is_a?(String) action = Action.new(element.text) if (namespace_attribute = element.attribute('Namespace')) action.namespace = ActionNamespace.namespace_for_uri(namespace_attribute.value) end action end |
.namespaces ⇒ Object
Identifiers that MAY be used in the namespace attribute of the Action element to refer to common sets of actions to perform on resources.
Each namespace provides a defined set of actions. Please refer to the SAML 2.0 specification for additional information.
12 13 14 |
# File 'lib/rsaml/action.rb', line 12 def self.namespaces ActionNamespace.namespaces end |
Instance Method Details
#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object
Construct an XML fragment representing the action.
41 42 43 44 45 |
# File 'lib/rsaml/action.rb', line 41 def to_xml(xml=Builder::XmlMarkup.new) attributes = {} attributes['Namespace'] = namespace unless namespace.nil? xml.tag!('saml:Action', attributes, value) end |
#validate ⇒ Object
Validate the structure
35 36 37 38 |
# File 'lib/rsaml/action.rb', line 35 def validate raise ValidationError, "Action value must be specified" if value.nil? raise ValidationError, "Action value not in given namespace" unless namespace.valid_action?(value) end |