rubycas-server-memory 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43f7dc0e1c4d9049aa83176d86147b9959dec452
4
+ data.tar.gz: fab9ce2f0d778bb74ddd3dc8b6aaf75004dd4d83
5
+ SHA512:
6
+ metadata.gz: 7d4b2ee05c9d2addccc631e78ebf1cde44244e577aaa41ebb11276bd3341491fc992200980c92a8dcabb6cd823590aa74cc92e18e984543934d766e4d1c9cf96
7
+ data.tar.gz: 07fbd758ff307ce0ac4ed37aed075c53fd6b90ff3b1cf5ae67e3192c394a050aa84617e09c411ac212aefa08aa22d31c68e6e95123dbbb819b046ef81ed3dc14
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubycas-server-memory.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Filippos Vasilakis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Rubycas::Server::Memory
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rubycas-server-memory'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rubycas-server-memory
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/rubycas-server-memory/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ require 'securerandom'
2
+
3
+ module RubyCAS
4
+ module Server
5
+ module Core
6
+ module Database
7
+ extend self
8
+ def setup(config_file)
9
+ # InMemory adapter do not require any settings
10
+ return true
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ require "rubycas/server/memory/storage"
18
+ require "rubycas/server/memory/login_ticket"
19
+ require "rubycas/server/memory/ticket_granting_ticket"
20
+ require "rubycas/server/memory/service_ticket"
21
+ require "rubycas/server/memory/proxy_ticket"
22
+ require "rubycas/server/memory/proxy_granting_ticket"
23
+ require "rubycas/server/memory/version"
@@ -0,0 +1,44 @@
1
+ module RubyCAS
2
+ module Server
3
+ module Core
4
+ module Tickets
5
+ class LoginTicket < Storage
6
+ attr_accessor :id, :ticket, :consumed, :client_hostname,
7
+ :created_at, :updated_at
8
+
9
+ def initialize(lt = {})
10
+ @id = SecureRandom.uuid
11
+ @ticket = lt[:ticket]
12
+ @consumed = lt[:consumed]
13
+ @client_hostname = lt[:client_hostname]
14
+ @created_at = DateTime.now
15
+ @updated_at = DateTime.now
16
+ super()
17
+ end
18
+
19
+ def self.find_by_ticket(ticket)
20
+ @storage.each do |id,lt|
21
+ return lt if lt.ticket == ticket
22
+ end
23
+ return nil
24
+ end
25
+
26
+ def consumed?
27
+ consumed
28
+ end
29
+
30
+ def consume!
31
+ self.consumed = true
32
+ self.save
33
+ end
34
+
35
+ def expired?(max_lifetime = 100)
36
+ lifetime = Time.now.to_i - created_at.to_time.to_i
37
+ lifetime > max_lifetime
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,38 @@
1
+ module RubyCAS
2
+ module Server
3
+ module Core
4
+ module Tickets
5
+ class ProxyGrantingTicket < Storage
6
+
7
+ attr_accessor :id, :ticket, :client_hostname, :iou,
8
+ :created_at, :updated_at, :service_ticket,
9
+ :proxy_tickets
10
+
11
+ def initialize(pgt = {})
12
+ @id = SecureRandom.uuid
13
+ @ticket = pgt[:ticket]
14
+ @client_hostname = pgt[:client_hostname]
15
+ @created_at = DateTime.now
16
+ @updated_at = DateTime.now
17
+ @service_ticket = pgt[:service_ticket]
18
+ @proxy_tickets = pgt[:proxy_tickets]
19
+ super()
20
+ end
21
+
22
+
23
+ def self.find_by_ticket(ticket)
24
+ @storage.each do |id,pgt|
25
+ return pgt if pgt.ticket == ticket
26
+ end
27
+ return nil
28
+ end
29
+
30
+ def expired?(max_lifetime = 100)
31
+ lifetime = Time.now.to_i - created_at.to_time.to_i
32
+ lifetime > max_lifetime
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,50 @@
1
+ module RubyCAS
2
+ module Server
3
+ module Core
4
+ module Tickets
5
+ class ProxyTicket < Storage
6
+
7
+ attr_accessor :id, :ticket, :service, :consumed, :client_hostname,
8
+ :username, :created_at, :updated_at, :proxy_granting_ticket,
9
+ :ticket_granting_ticket
10
+
11
+ def initialize(pt = {})
12
+ @id = SecureRandom.uuid
13
+ @ticket = pt[:ticket]
14
+ @service = pt[:service]
15
+ @consumed = pt[:consumed]
16
+ @client_hostname = pt[:client_hostname]
17
+ @username = pt[:username]
18
+ @created_at = DateTime.now
19
+ @updated_at = DateTime.now
20
+ @proxy_granting_ticket = pt[:proxy_granting_ticket]
21
+ @ticket_granting_ticket = pt[:ticket_granting_ticket]
22
+ super()
23
+ end
24
+
25
+
26
+ def self.find_by_ticket(ticket)
27
+ @storage.each do |id,pt|
28
+ return pt if pt.ticket == ticket
29
+ end
30
+ return nil
31
+ end
32
+
33
+ def consumed?
34
+ consumed
35
+ end
36
+
37
+ def consume!
38
+ consumed = true
39
+ self.save
40
+ end
41
+
42
+ def expired?(max_lifetime = 100)
43
+ lifetime = Time.now.to_i - created_at.to_time.to_i
44
+ lifetime > max_lifetime
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,56 @@
1
+ module RubyCAS
2
+ module Server
3
+ module Core
4
+ module Tickets
5
+ class ServiceTicket < RubyCAS::Server::Core::Tickets::TicketGrantingTicket
6
+
7
+ attr_accessor :id, :ticket, :consumed, :client_hostname,
8
+ :username, :created_at, :updated_at, :proxy_granting_ticket,
9
+ :ticket_granting_ticket
10
+ attr_reader :service
11
+
12
+ def initialize(st = {})
13
+ @id = SecureRandom.uuid
14
+ @ticket = st[:ticket]
15
+ @service = st[:service]
16
+ @consumed = st[:consumed]
17
+ @client_hostname = st[:client_hostname]
18
+ @username = st[:username]
19
+ @created_at = DateTime.now
20
+ @updated_at = DateTime.now
21
+ @proxy_granting_ticket = st[:proxy_granting_ticket]
22
+ @ticket_granting_ticket = st[:ticket_granting_ticket]
23
+ super()
24
+ end
25
+
26
+
27
+ def self.find_by_ticket(ticket)
28
+ @storage.each do |id,st|
29
+ return st if st.ticket == ticket
30
+ end
31
+ return nil
32
+ end
33
+
34
+ def consumed?
35
+ self.consumed
36
+ end
37
+
38
+ def consume!
39
+ self.consumed = true
40
+ self.save
41
+ end
42
+
43
+ def expired?(max_lifetime = 100)
44
+ lifetime = Time.now.to_i - created_at.to_time.to_i
45
+ lifetime > max_lifetime
46
+ end
47
+
48
+ def service=(url)
49
+ @service = RubyCAS::Server::Core::Util.clean_service_url(url)
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,28 @@
1
+ module RubyCAS
2
+ module Server
3
+ module Core
4
+ module Tickets
5
+ class Storage
6
+ class << self
7
+ attr_accessor :storage
8
+ end
9
+
10
+ def initialize
11
+ self.class.storage = {} unless self.class.storage
12
+ end
13
+
14
+ def save
15
+ self.class.storage[@id] = self
16
+ return true
17
+ end
18
+
19
+ def save!
20
+ self.class.storage[@id] = self
21
+ return true
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,43 @@
1
+ module RubyCAS
2
+ module Server
3
+ module Core
4
+ module Tickets
5
+ class TicketGrantingTicket < Storage
6
+ attr_accessor :id, :ticket, :client_hostname, :username,
7
+ :extra_attributes, :service_tickets, :proxy_tickets,
8
+ :remember_me, :created_at, :updated_at
9
+
10
+ def initialize(tgt = {})
11
+ @id = SecureRandom.uuid
12
+ @ticket = tgt[:ticket]
13
+ @client_hostname = tgt[:client_hostname]
14
+ @username = tgt[:username]
15
+ @extra_attributes = tgt[:extra_attributes]
16
+ @service_tickets = tgt[:service_tickets]
17
+ @proxy_tickets = tgt[:proxy_tickets]
18
+ @remember_me = tgt[:remember_me]
19
+ @created_at = DateTime.now
20
+ @updated_at = DateTime.now
21
+ super()
22
+ end
23
+
24
+ def self.find_by_ticket(ticket)
25
+ @storage.each do |id, tgt|
26
+ return tgt if tgt.ticket == ticket
27
+ end
28
+ return nil
29
+ end
30
+
31
+ def expired?(max_lifetime)
32
+ lifetime = Time.now.to_i - created_at.to_time.to_i
33
+ lifetime > max_lifetime
34
+ end
35
+
36
+ def service_tickets
37
+ ServiceTicket
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,7 @@
1
+ module RubyCAS
2
+ module Server
3
+ module Core
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rubycas/server/memory/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rubycas-server-memory"
8
+ spec.version = RubyCAS::Server::Core::VERSION
9
+ spec.authors = ["Filippos Vasilakis"]
10
+ spec.email = ["vasilakisfil@gmail.com"]
11
+ spec.description = %q{Memory adapter for RubyCAS Server}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/vasilakisfil/rubycas-server-memory"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib/rubycas/server/"]
20
+
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "pry"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", "~> 3.1.0"
25
+ spec.add_development_dependency "rspec-its", "~> 1.1.0"
26
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubycas-server-memory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Filippos Vasilakis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.1.0
83
+ description: Memory adapter for RubyCAS Server
84
+ email:
85
+ - vasilakisfil@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/rubycas/server/memory.rb
96
+ - lib/rubycas/server/memory/login_ticket.rb
97
+ - lib/rubycas/server/memory/proxy_granting_ticket.rb
98
+ - lib/rubycas/server/memory/proxy_ticket.rb
99
+ - lib/rubycas/server/memory/service_ticket.rb
100
+ - lib/rubycas/server/memory/storage.rb
101
+ - lib/rubycas/server/memory/ticket_granting_ticket.rb
102
+ - lib/rubycas/server/memory/version.rb
103
+ - rubycas-server-memory.gemspec
104
+ homepage: https://github.com/vasilakisfil/rubycas-server-memory
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib/rubycas/server/
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.5
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Memory adapter for RubyCAS Server
128
+ test_files: []