Exception: SecurityViolationError

Inherits:
AnnotationSecurity::SecurityError show all
Defined in:
lib/annotation_security/exceptions.rb

Overview

Exception indicating that some rights were violated.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user = nil, *args) ⇒ SecurityViolationError

:nodoc:



22
23
24
25
26
27
28
# File 'lib/annotation_security/exceptions.rb', line 22

def initialize(user=nil,*args) # :nodoc:
  if user == nil || args.empty?
    super "Access denied"
  else
    super load_args(user,args)
  end
end

Class Method Details

.access_denied(user, *args) ⇒ Object

:nodoc:



18
19
20
# File 'lib/annotation_security/exceptions.rb', line 18

def self.access_denied(user,*args) # :nodoc:
  new(user,*args)
end

Instance Method Details

#actionObject

the action that should have been performed on the resource object



45
46
47
# File 'lib/annotation_security/exceptions.rb', line 45

def action
  @action
end

#load_args(user, args) ⇒ Object

:nodoc:



30
31
32
33
34
35
# File 'lib/annotation_security/exceptions.rb', line 30

def load_args(user,args) # :nodoc:
  @user = user
  @action,@resclass,@res = AnnotationSecurity::Utils.parse_policy_arguments(args)
  "You (#@user) are missing the right '#@action' for #@resclass" +
      (@res.blank? ? '' : " '#@res'")
end

#resourceObject

the resource that was accessed



57
58
59
# File 'lib/annotation_security/exceptions.rb', line 57

def resource
  @res
end

#resource_classObject

the resource type



51
52
53
# File 'lib/annotation_security/exceptions.rb', line 51

def resource_class
  @resclass
end

#userObject

user that violated the right



39
40
41
# File 'lib/annotation_security/exceptions.rb', line 39

def user
  @user
end