jgrouper 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +11 -0
- data/bin/jgrouper-add-group-type +95 -0
- data/bin/jgrouper-grant +2 -2
- data/bin/jgrouper-revoke +2 -2
- data/lib/jgrouper/group.rb +19 -0
- data/lib/jgrouper/group_type.rb +10 -0
- data/lib/jgrouper/version.rb +1 -1
- metadata +4 -2
data/HISTORY.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
JGrouper History
|
2
2
|
================
|
3
3
|
|
4
|
+
2014-02-27 v0.7.0
|
5
|
+
-----------------
|
6
|
+
* Add `bin/jgrouper-add-group-type`
|
7
|
+
* Add `JGrouper::Group#add_type()`
|
8
|
+
* Add `JGrouper::Group#type?()`
|
9
|
+
* Add `JGrouper::GroupType#to_grouper()`
|
10
|
+
* Add `JGrouper::GroupType#to_s()`
|
11
|
+
* Fix `bin/jgrouper-grant` error messages
|
12
|
+
* Fix `bin/jgrouper-revoke` error messages
|
13
|
+
|
14
|
+
|
4
15
|
2014-01-10 JGrouper v0.6.0
|
5
16
|
-------------------------
|
6
17
|
* Add `bin/jgrouper-diff`
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
|
3
|
+
require 'jgrouper'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
|
7
|
+
class MyApp
|
8
|
+
|
9
|
+
attr_accessor :recurse, :verbose
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@recurse = false
|
13
|
+
@verbose = false
|
14
|
+
yield self if block_given?
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_group_type(stem_or_group, group_type)
|
19
|
+
raise 'ERROR: stem-or-group is nil' if stem_or_group.nil?
|
20
|
+
raise 'ERROR: group type is nil' if group_type.nil?
|
21
|
+
|
22
|
+
type = JGrouper::GroupType.find group_type
|
23
|
+
raise "ERROR: could not find group type: #{group_type}" if type.nil?
|
24
|
+
puts "found group type: #{type.to_s}" if verbose?
|
25
|
+
|
26
|
+
stem = JGrouper::Stem.find stem_or_group
|
27
|
+
return add_group_type_to_stem(stem, type) unless stem.nil?
|
28
|
+
|
29
|
+
group = JGrouper::Group.find stem_or_group
|
30
|
+
return add_group_type_to_group(group, type) unless group.nil?
|
31
|
+
|
32
|
+
raise "ERROR: could not find stem-or-group: #{stem_or_group}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def recurse? ; @recurse ; end
|
36
|
+
def verbose? ; @verbose ; end
|
37
|
+
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def add_group_type_to_group(group, type)
|
42
|
+
return if group.type? type
|
43
|
+
puts "adding group type #{type.name} on group #{group.name}" if verbose?
|
44
|
+
group.add_type type
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_group_type_to_stem(stem, type)
|
48
|
+
unless recurse?
|
49
|
+
warn 'WARNING: cannot add group type on stem without specifying -R'
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
|
53
|
+
stem.groups do |group|
|
54
|
+
next if group.type? type
|
55
|
+
puts "adding group type #{type.name} on group #{group.name}" if verbose?
|
56
|
+
group.add_type type
|
57
|
+
end
|
58
|
+
stem.stems { |child| add_group_type_to_stem child, type }
|
59
|
+
|
60
|
+
true
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
MyApp.new do |app|
|
67
|
+
|
68
|
+
opts = OptionParser.new do |opts|
|
69
|
+
opts.banner = "USAGE: #{ File.basename(__FILE__) } [options] <stem-or-group> <group type>"
|
70
|
+
opts.on('-R', '--[no-]recurse', 'Recursively add group type [DEFAULT: no]') do |recurse|
|
71
|
+
app.recurse = recurse
|
72
|
+
end
|
73
|
+
opts.on_tail('-h', '--help', 'Show help') do
|
74
|
+
puts opts
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
opts.on_tail('-v', '--[no-]verbose', 'Enable verbose mode [DEFAULT: no]') do |verbose|
|
78
|
+
app.verbose = verbose
|
79
|
+
end
|
80
|
+
end.parse!
|
81
|
+
|
82
|
+
# TODO DRY
|
83
|
+
if ENV['GROUPER_HOME']
|
84
|
+
JGrouper.home! ENV['GROUPER_HOME']
|
85
|
+
else
|
86
|
+
warn "ERROR: GROUPER_HOME not set"
|
87
|
+
exit 1
|
88
|
+
end
|
89
|
+
|
90
|
+
app.add_group_type( ARGV.shift, ARGV.shift ) or exit 1
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
# vim: syntax=ruby
|
95
|
+
|
data/bin/jgrouper-grant
CHANGED
@@ -17,8 +17,8 @@ class MyApp
|
|
17
17
|
|
18
18
|
def grant(stem_or_group, privilege, subject)
|
19
19
|
raise 'ERROR: stem-or-group is nil' if stem_or_group.nil?
|
20
|
-
raise 'ERROR: privilege is nil' if
|
21
|
-
raise 'ERROR: subject is nil' if
|
20
|
+
raise 'ERROR: privilege is nil' if privilege.nil?
|
21
|
+
raise 'ERROR: subject is nil' if subject.nil?
|
22
22
|
|
23
23
|
priv = JGrouper::Privilege.find privilege
|
24
24
|
raise "ERROR: could not find privilege: #{privilege}" if priv.nil?
|
data/bin/jgrouper-revoke
CHANGED
@@ -17,8 +17,8 @@ class MyApp
|
|
17
17
|
|
18
18
|
def revoke(stem_or_group, privilege, subject)
|
19
19
|
raise 'ERROR: stem-or-group is nil' if stem_or_group.nil?
|
20
|
-
raise 'ERROR: privilege is nil' if
|
21
|
-
raise 'ERROR: subject is nil' if
|
20
|
+
raise 'ERROR: privilege is nil' if privilege.nil?
|
21
|
+
raise 'ERROR: subject is nil' if subject.nil?
|
22
22
|
|
23
23
|
priv = JGrouper::Privilege.find privilege
|
24
24
|
raise "ERROR: could not find privilege: #{privilege}" if priv.nil?
|
data/lib/jgrouper/group.rb
CHANGED
@@ -33,6 +33,13 @@ module JGrouper # :nodoc:
|
|
33
33
|
group
|
34
34
|
end
|
35
35
|
|
36
|
+
#
|
37
|
+
# Add +JGrouper::GroupType+ to group.
|
38
|
+
#
|
39
|
+
def add_type(type)
|
40
|
+
@obj.addType type.to_grouper, false
|
41
|
+
end
|
42
|
+
|
36
43
|
def grant(subject, privilege)
|
37
44
|
@obj.grantPriv subject.to_grouper, privilege.to_grouper, false
|
38
45
|
end
|
@@ -98,6 +105,18 @@ module JGrouper # :nodoc:
|
|
98
105
|
%w( name display_name uuid ).collect { |k| "#{k}=#{ self.send(k) }" }.to_csv.chomp
|
99
106
|
end
|
100
107
|
|
108
|
+
#
|
109
|
+
# Does group have group type (where type is +String+ or +JGrouper::GroupType+)?
|
110
|
+
#
|
111
|
+
def type?(type)
|
112
|
+
case type.class
|
113
|
+
when String
|
114
|
+
return @obj.hasType JGrouper::GroupType.find(type).to_grouper
|
115
|
+
else
|
116
|
+
return @obj.hasType type.to_grouper
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
101
120
|
end
|
102
121
|
end
|
103
122
|
|
data/lib/jgrouper/group_type.rb
CHANGED
@@ -53,6 +53,11 @@ module JGrouper # :nodoc:
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
#
|
57
|
+
# Return Grouper object.
|
58
|
+
#
|
59
|
+
def to_grouper; @obj; end
|
60
|
+
|
56
61
|
def to_hash
|
57
62
|
{
|
58
63
|
kind: 'group_type',
|
@@ -70,6 +75,11 @@ module JGrouper # :nodoc:
|
|
70
75
|
to_hash.to_json
|
71
76
|
end
|
72
77
|
|
78
|
+
def to_s
|
79
|
+
return nil if @obj.nil?
|
80
|
+
%w( name uuid ).collect { |k| "#{k}=#{ self.send(k) }" }.to_csv.chomp
|
81
|
+
end
|
82
|
+
|
73
83
|
end
|
74
84
|
end
|
75
85
|
|
data/lib/jgrouper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jgrouper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashdiff
|
@@ -111,6 +111,7 @@ description: JRuby wrapper around the Internet2 Grouper API
|
|
111
111
|
email:
|
112
112
|
- blair.christensen@gmail.com
|
113
113
|
executables:
|
114
|
+
- jgrouper-add-group-type
|
114
115
|
- jgrouper-audit-archiver
|
115
116
|
- jgrouper-diff
|
116
117
|
- jgrouper-export
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- README.rdoc
|
128
129
|
- Rakefile
|
129
130
|
- TODO.md
|
131
|
+
- bin/jgrouper-add-group-type
|
130
132
|
- bin/jgrouper-audit-archiver
|
131
133
|
- bin/jgrouper-diff
|
132
134
|
- bin/jgrouper-export
|