Class: RSAML::ActionNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/rsaml/action_namespace.rb

Overview

Namespaces for actions.

Direct Known Subclasses

UnixActionNamespace

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, action_names) ⇒ ActionNamespace

Initialize the action namespace with the given URI and action names



34
35
36
37
# File 'lib/rsaml/action_namespace.rb', line 34

def initialize(uri, action_names)
  @uri = uri
  @action_names = action_names
end

Instance Attribute Details

#action_namesObject

Common sets of actions to perform on resources.



31
32
33
# File 'lib/rsaml/action_namespace.rb', line 31

def action_names
  @action_names
end

#uriObject

URI identifying this action namespace



28
29
30
# File 'lib/rsaml/action_namespace.rb', line 28

def uri
  @uri
end

Class Method Details

.namespace_for_uri(uri) ⇒ Object

Get an ActionNamespace instance for the given namespace URI. This method will return nil if no namespace is found for the given URI



23
24
25
# File 'lib/rsaml/action_namespace.rb', line 23

def self.namespace_for_uri(uri)
  namespaces.values.find { |ns| ns.uri == uri }
end

.namespacesObject

A Hash of predefined namespaces from the SAML 2.0 specification. The value for each key/value pair is an ActionNamespace instance with a URI and set of action names.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rsaml/action_namespace.rb', line 6

def self.namespaces
  @namespaces ||= {
    :rwedc => ActionNamespace.new('urn:oasis:names:tc:SAML:1.0:action:rwedc', [
      'Read','Write','Execute','Delete','Control'
    ]),
    :rwedc_negation => ActionNamespace.new('urn:oasis:names:tc:SAML:1.0:action:rwedc-negation', [
      'Read','Write','Execute','Delete','Control','~Read','~Write','~Execute','~Delete','~Control'
    ]),
    :ghpp => ActionNamespace.new('urn:oasis:names:tc:SAML:1.0:action:ghpp', [
      'GET','HEAD','PUT','POST'
    ]),
    :unix => UnixActionNamespace.new
  }
end

Instance Method Details

#to_sObject

Return a string representation, specifically the URI for the namespace.



45
46
47
# File 'lib/rsaml/action_namespace.rb', line 45

def to_s
  uri
end

#valid_action?(value) ⇒ Boolean

Return true if the given value is a valid action in the namespace.

Returns:

  • (Boolean)


40
41
42
# File 'lib/rsaml/action_namespace.rb', line 40

def valid_action?(value)
  action_names.include?(value)
end