gunark-rubycas-client 2.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.txt +1 -0
- data/History.txt +152 -0
- data/LICENSE.txt +504 -0
- data/Manifest.txt +16 -0
- data/README.txt +291 -0
- data/Rakefile +63 -0
- data/init.rb +6 -0
- data/lib/casclient/client.rb +256 -0
- data/lib/casclient/frameworks/merb/strategy.rb +110 -0
- data/lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb +76 -0
- data/lib/casclient/frameworks/rails/filter.rb +313 -0
- data/lib/casclient/responses.rb +185 -0
- data/lib/casclient/tickets.rb +38 -0
- data/lib/casclient/version.rb +9 -0
- data/lib/casclient.rb +89 -0
- data/lib/rubycas-client.rb +5 -0
- data/setup.rb +1585 -0
- metadata +92 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
module CASClient
|
2
|
+
# Represents a CAS service ticket.
|
3
|
+
class ServiceTicket
|
4
|
+
attr_reader :ticket, :service, :renew
|
5
|
+
attr_accessor :response
|
6
|
+
|
7
|
+
def initialize(ticket, service, renew = false)
|
8
|
+
@ticket = ticket
|
9
|
+
@service = service
|
10
|
+
@renew = renew
|
11
|
+
end
|
12
|
+
|
13
|
+
def is_valid?
|
14
|
+
response.is_success?
|
15
|
+
end
|
16
|
+
|
17
|
+
def has_been_validated?
|
18
|
+
not response.nil?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Represents a CAS proxy ticket.
|
23
|
+
class ProxyTicket < ServiceTicket
|
24
|
+
end
|
25
|
+
|
26
|
+
class ProxyGrantingTicket
|
27
|
+
attr_reader :ticket, :iou
|
28
|
+
|
29
|
+
def initialize(ticket, iou)
|
30
|
+
@ticket = ticket
|
31
|
+
@iou = iou
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
ticket
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/casclient.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'cgi'
|
3
|
+
require 'net/https'
|
4
|
+
require 'rexml/document'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'active_support'
|
8
|
+
rescue LoadError
|
9
|
+
require 'rubygems'
|
10
|
+
require 'active_support'
|
11
|
+
end
|
12
|
+
|
13
|
+
$: << File.expand_path(File.dirname(__FILE__))
|
14
|
+
|
15
|
+
module CASClient
|
16
|
+
class CASException < Exception
|
17
|
+
end
|
18
|
+
|
19
|
+
# Customized logger for the client.
|
20
|
+
# This is useful if you're trying to do logging in Rails, since Rails'
|
21
|
+
# clean_logger.rb pretty much completely breaks the base Logger class.
|
22
|
+
class Logger < ::Logger
|
23
|
+
def initialize(logdev, shift_age = 0, shift_size = 1048576)
|
24
|
+
@default_formatter = Formatter.new
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def format_message(severity, datetime, progrname, msg)
|
29
|
+
(@formatter || @default_formatter).call(severity, datetime, progname, msg)
|
30
|
+
end
|
31
|
+
|
32
|
+
def break
|
33
|
+
self << $/
|
34
|
+
end
|
35
|
+
|
36
|
+
class Formatter < ::Logger::Formatter
|
37
|
+
Format = "[%s#%d] %5s -- %s: %s\n"
|
38
|
+
|
39
|
+
def call(severity, time, progname, msg)
|
40
|
+
Format % [format_datetime(time), $$, severity, progname, msg2str(msg)]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Wraps a real Logger. If no real Logger is set, then this wrapper
|
46
|
+
# will quietly swallow any logging calls.
|
47
|
+
class LoggerWrapper
|
48
|
+
def initialize(real_logger=nil)
|
49
|
+
set_logger(real_logger)
|
50
|
+
end
|
51
|
+
# Assign the 'real' Logger instance that this dummy instance wraps around.
|
52
|
+
def set_real_logger(real_logger)
|
53
|
+
@real_logger = real_logger
|
54
|
+
end
|
55
|
+
# Log using the appropriate method if we have a logger
|
56
|
+
# if we dont' have a logger, gracefully ignore.
|
57
|
+
def method_missing(name, *args)
|
58
|
+
if @real_logger && @real_logger.respond_to?(name)
|
59
|
+
@real_logger.send(name, *args)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
require 'casclient/tickets'
|
66
|
+
require 'casclient/responses'
|
67
|
+
require 'casclient/client'
|
68
|
+
require 'casclient/version'
|
69
|
+
|
70
|
+
# Detect legacy configuration and show appropriate error message
|
71
|
+
module CAS
|
72
|
+
module Filter
|
73
|
+
class << self
|
74
|
+
def method_missing(method, *args)
|
75
|
+
$stderr.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
76
|
+
$stderr.puts
|
77
|
+
$stderr.puts "WARNING: Your RubyCAS-Client configuration is no longer valid!!"
|
78
|
+
$stderr.puts
|
79
|
+
$stderr.puts "For information on the new configuration format please see: "
|
80
|
+
$stderr.puts
|
81
|
+
$stderr.puts " http://rubycas-client.googlecode.com/svn/trunk/rubycas-client/README.txt"
|
82
|
+
$stderr.puts
|
83
|
+
$stderr.puts "After upgrading your configuration you should also clear your application's session store."
|
84
|
+
$stderr.puts
|
85
|
+
$stderr.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|