jgrouper 0.0.1
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/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.rdoc +58 -0
- data/Rakefile +19 -0
- data/TODO.md +33 -0
- data/jgrouper.gemspec +22 -0
- data/lib/jgrouper/stem.rb +44 -0
- data/lib/jgrouper/subject.rb +47 -0
- data/lib/jgrouper/version.rb +3 -0
- data/lib/jgrouper.rb +95 -0
- metadata +110 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 blair christensen
|
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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= JGrouper - JRuby wrapper around the Internet2 Grouper API
|
2
|
+
|
3
|
+
== Usage
|
4
|
+
|
5
|
+
require 'jgrouper'
|
6
|
+
|
7
|
+
# Set path to your Grouper API installation
|
8
|
+
JGrouper.home = '/path/to/your/grouper/api/installation/directory'
|
9
|
+
|
10
|
+
# Find root subject
|
11
|
+
JGrouper::Subject.root_subject do |subject|
|
12
|
+
subject.id # Subject identifier
|
13
|
+
subject.name # Subject name
|
14
|
+
subject.source # Subject source identifier
|
15
|
+
subject.type # Subject type name
|
16
|
+
end
|
17
|
+
|
18
|
+
# Find root stem
|
19
|
+
JGrouper::Stem.root_stem do |stem|
|
20
|
+
stem.display_name # Stem display name
|
21
|
+
stem.name # Stem name
|
22
|
+
stem.uuid # Stem UUID
|
23
|
+
end
|
24
|
+
|
25
|
+
== Installation
|
26
|
+
|
27
|
+
Add this line to your application's Gemfile:
|
28
|
+
|
29
|
+
gem 'jgrouper'
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
$ bundle
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
$ gem install jgrouper
|
38
|
+
|
39
|
+
== Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (+git checkout -b my-new-feature+)
|
43
|
+
3. Commit your changes (+git commit -am 'Added some feature'+)
|
44
|
+
4. Push to the branch (+git push origin my-new-feature+)
|
45
|
+
5. Create new Pull Request
|
46
|
+
|
47
|
+
== Author
|
48
|
+
|
49
|
+
blair christensen. <mailto:blair.christensen@gmail.com>
|
50
|
+
|
51
|
+
== Home Page
|
52
|
+
|
53
|
+
https://github.com/blairc/jgrouper
|
54
|
+
|
55
|
+
== See Also
|
56
|
+
|
57
|
+
http://grouper.internet2.edu
|
58
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rdoc-readme/rake_task'
|
6
|
+
require 'rdoc/task'
|
7
|
+
|
8
|
+
%w{ coverage goz.log html out.txt pkg }.each { |p| CLEAN.include(p) }
|
9
|
+
%w{ build install rdoc test }.each { |t| task t.to_sym => [ 'rdoc:readme' ] }
|
10
|
+
|
11
|
+
task :default => :test
|
12
|
+
|
13
|
+
RDoc::Readme::RakeTask.new 'lib/jgrouper.rb', 'README.rdoc'
|
14
|
+
|
15
|
+
RDoc::Task.new do |rdoc|
|
16
|
+
rdoc.main = 'README.rdoc'
|
17
|
+
rdoc.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'doc/*.txt')
|
18
|
+
end
|
19
|
+
|
data/TODO.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
JGrouper To Do
|
2
|
+
==============
|
3
|
+
|
4
|
+
JGrouper v0.0.2
|
5
|
+
---------------
|
6
|
+
* Add child stem
|
7
|
+
* Get child stems
|
8
|
+
* Delete child stem
|
9
|
+
* Grant stem privileges
|
10
|
+
* Get stem privileges
|
11
|
+
* Revoke stem privileges
|
12
|
+
* Document
|
13
|
+
* Release v0.0.2
|
14
|
+
|
15
|
+
JGrouper v0.0.3
|
16
|
+
---------------
|
17
|
+
* Add child group
|
18
|
+
* Get child groups
|
19
|
+
* Delete child group
|
20
|
+
* Add group member
|
21
|
+
* Get group members
|
22
|
+
* Remove group member
|
23
|
+
* Grant group privileges
|
24
|
+
* Get group privileges
|
25
|
+
* Revoke group privileges
|
26
|
+
* Document
|
27
|
+
* Release v0.0.3
|
28
|
+
|
29
|
+
Future
|
30
|
+
------
|
31
|
+
* Add privilege to stem and all children
|
32
|
+
* Add privilege to all groups beneath a stem
|
33
|
+
|
data/jgrouper.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/jgrouper/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['blair christensen']
|
6
|
+
gem.email = ['blair.christensen@gmail.com']
|
7
|
+
gem.description = %q{JRuby wrapper around the Internet2 Grouper API}
|
8
|
+
gem.summary = %q{JRuby wrapper around the Internet2 Grouper API}
|
9
|
+
gem.homepage = %q{https://github.com/blairc/jgrouper}
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = 'jgrouper'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = JGrouper::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rake'
|
19
|
+
gem.add_development_dependency 'rdoc'
|
20
|
+
gem.add_development_dependency 'rdoc-readme', '~> 0.1.2'
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
module JGrouper # :nodoc:
|
3
|
+
#
|
4
|
+
# = JGrouper::Stem - A Grouper stem
|
5
|
+
#
|
6
|
+
class Stem
|
7
|
+
|
8
|
+
def initialize(stem)
|
9
|
+
@stem = stem
|
10
|
+
yield self if block_given?
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Return root stem.
|
16
|
+
#
|
17
|
+
# root_stem = JGrouper::Stem.root_stem
|
18
|
+
#
|
19
|
+
def self.root_stem
|
20
|
+
stem = self.new StemFinder.findRootStem( GrouperSession.startRootSession ) # XXX How to handle sessions?
|
21
|
+
yield stem if block_given?
|
22
|
+
stem
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
%w( name display_name uuid ).collect { |k| "#{k}=#{ self.send(k) }" }.join(' | ')
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Stem display name getter.
|
31
|
+
#
|
32
|
+
def display_name; @stem.getDisplayName; end
|
33
|
+
#
|
34
|
+
# Stem name getter.
|
35
|
+
#
|
36
|
+
def name; @stem.getName; end
|
37
|
+
#
|
38
|
+
# Stem UUID getter
|
39
|
+
#
|
40
|
+
def uuid; @stem.getUuid; end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module JGrouper #: :nodoc:
|
2
|
+
#
|
3
|
+
# = JGrouper::Subject - A Grouper subject.
|
4
|
+
#
|
5
|
+
class Subject
|
6
|
+
|
7
|
+
def initialize(subject)
|
8
|
+
@subject = subject
|
9
|
+
yield self if block_given?
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Return root subject.
|
15
|
+
#
|
16
|
+
# root_subject = JGrouper::Subject.root_subject
|
17
|
+
#
|
18
|
+
def self.root_subject
|
19
|
+
subj = self.new SubjectFinder.findRootSubject
|
20
|
+
yield subj if block_given?
|
21
|
+
subj
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
%w( id name type source ).collect { |k| "#{k}=#{ self.send(k) }" }.join(' | ')
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Subject identifier getter.
|
30
|
+
#
|
31
|
+
def id; @subject.getId; end
|
32
|
+
#
|
33
|
+
# Subject name getter.
|
34
|
+
#
|
35
|
+
def name; @subject.getName; end
|
36
|
+
#
|
37
|
+
# Subject source identifier getter.
|
38
|
+
#
|
39
|
+
def source; @subject.sourceId; end
|
40
|
+
#
|
41
|
+
# Subject type name getter.
|
42
|
+
#
|
43
|
+
def type; @subject.typeName; end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/lib/jgrouper.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'java'
|
2
|
+
require 'jgrouper/stem'
|
3
|
+
require 'jgrouper/subject'
|
4
|
+
require 'jgrouper/version'
|
5
|
+
|
6
|
+
|
7
|
+
#
|
8
|
+
# = JGrouper - JRuby wrapper around the Internet2 Grouper API
|
9
|
+
#
|
10
|
+
# == Usage
|
11
|
+
#
|
12
|
+
# require 'jgrouper'
|
13
|
+
#
|
14
|
+
# # Set path to your Grouper API installation
|
15
|
+
# JGrouper.home = '/path/to/your/grouper/api/installation/directory'
|
16
|
+
#
|
17
|
+
# # Find root subject
|
18
|
+
# JGrouper::Subject.root_subject do |subject|
|
19
|
+
# subject.id # Subject identifier
|
20
|
+
# subject.name # Subject name
|
21
|
+
# subject.source # Subject source identifier
|
22
|
+
# subject.type # Subject type name
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# # Find root stem
|
26
|
+
# JGrouper::Stem.root_stem do |stem|
|
27
|
+
# stem.display_name # Stem display name
|
28
|
+
# stem.name # Stem name
|
29
|
+
# stem.uuid # Stem UUID
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# == Installation
|
33
|
+
#
|
34
|
+
# Add this line to your application's Gemfile:
|
35
|
+
#
|
36
|
+
# gem 'jgrouper'
|
37
|
+
#
|
38
|
+
# And then execute:
|
39
|
+
#
|
40
|
+
# $ bundle
|
41
|
+
#
|
42
|
+
# Or install it yourself as:
|
43
|
+
#
|
44
|
+
# $ gem install jgrouper
|
45
|
+
#
|
46
|
+
# == Contributing
|
47
|
+
#
|
48
|
+
# 1. Fork it
|
49
|
+
# 2. Create your feature branch (+git checkout -b my-new-feature+)
|
50
|
+
# 3. Commit your changes (+git commit -am 'Added some feature'+)
|
51
|
+
# 4. Push to the branch (+git push origin my-new-feature+)
|
52
|
+
# 5. Create new Pull Request
|
53
|
+
#
|
54
|
+
# == Author
|
55
|
+
#
|
56
|
+
# blair christensen. <mailto:blair.christensen@gmail.com>
|
57
|
+
#
|
58
|
+
# == Home Page
|
59
|
+
#
|
60
|
+
# https://github.com/blairc/jgrouper
|
61
|
+
#
|
62
|
+
# == See Also
|
63
|
+
#
|
64
|
+
# http://grouper.internet2.edu
|
65
|
+
#
|
66
|
+
module JGrouper
|
67
|
+
|
68
|
+
#
|
69
|
+
# Initialize Grouper API.
|
70
|
+
#
|
71
|
+
def self.home(path)
|
72
|
+
# TODO This could/should be so much better.
|
73
|
+
[ "#{path}/lib/grouper/", "#{path}/lib/jdbcSamples" ].each do |dir|
|
74
|
+
Dir[ "#{dir}/*.jar" ].each { |jar| $CLASSPATH << jar }
|
75
|
+
end
|
76
|
+
$CLASSPATH << File.join( path, 'conf' )
|
77
|
+
$CLASSPATH << File.join( path, 'dist', 'lib', 'grouper.jar' )
|
78
|
+
|
79
|
+
%w( edu.internet2.middleware.subject.SubjectNotFoundException
|
80
|
+
edu.internet2.middleware.grouper.GrouperSession
|
81
|
+
edu.internet2.middleware.grouper.SubjectFinder
|
82
|
+
edu.internet2.middleware.grouper.StemFinder
|
83
|
+
).each { |klass| include_class klass }
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# XXX Extract! Remove! Whatever!
|
90
|
+
if __FILE__ == $0
|
91
|
+
JGrouper.home ENV['GROUPER_HOME'] if ENV['GROUPER_HOME']
|
92
|
+
JGrouper::Subject.root_subject { |subject| puts "root_subject => #{subject}" }
|
93
|
+
JGrouper::Stem.root_stem { |stem| puts "root_stem => #{stem}" }
|
94
|
+
end
|
95
|
+
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jgrouper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- blair christensen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc-readme
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.1.2
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.2
|
62
|
+
description: JRuby wrapper around the Internet2 Grouper API
|
63
|
+
email:
|
64
|
+
- blair.christensen@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.rdoc
|
73
|
+
- Rakefile
|
74
|
+
- TODO.md
|
75
|
+
- jgrouper.gemspec
|
76
|
+
- lib/jgrouper.rb
|
77
|
+
- lib/jgrouper/stem.rb
|
78
|
+
- lib/jgrouper/subject.rb
|
79
|
+
- lib/jgrouper/version.rb
|
80
|
+
homepage: https://github.com/blairc/jgrouper
|
81
|
+
licenses: []
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
hash: 3970965628382223639
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
hash: 3970965628382223639
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.23
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: JRuby wrapper around the Internet2 Grouper API
|
110
|
+
test_files: []
|