icfs 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/bin/icfs_demo_fcgi.rb +2 -0
  3. data/{bin/icfs_demo_ssl_gen.rb → devel/demo/ssl_gen.rb} +25 -13
  4. data/devel/demo/ssl_gen.yml +14 -0
  5. data/devel/icfs-wrk/Dockerfile +1 -1
  6. data/devel/run/base.rb +92 -0
  7. data/devel/run/copy-s3.rb +2 -0
  8. data/devel/run/email.rb +36 -0
  9. data/devel/run/email_imap.rb +43 -0
  10. data/devel/run/email_smime.rb +47 -0
  11. data/devel/run/init-icfs.rb +2 -0
  12. data/devel/run/webrick.rb +5 -57
  13. data/lib/icfs/api.rb +101 -90
  14. data/lib/icfs/cache.rb +2 -0
  15. data/lib/icfs/cache_elastic.rb +127 -125
  16. data/lib/icfs/{web/config.rb → config.rb} +3 -3
  17. data/lib/icfs/{web/config_redis.rb → config_redis.rb} +8 -8
  18. data/lib/icfs/{web/config_s3.rb → config_s3.rb} +8 -8
  19. data/lib/icfs/demo/auth.rb +5 -7
  20. data/lib/icfs/demo/static.rb +2 -0
  21. data/lib/icfs/elastic.rb +10 -8
  22. data/lib/icfs/email/basic.rb +242 -0
  23. data/lib/icfs/email/core.rb +293 -0
  24. data/lib/icfs/email/from.rb +52 -0
  25. data/lib/icfs/email/imap.rb +148 -0
  26. data/lib/icfs/email/smime.rb +139 -0
  27. data/lib/icfs/items.rb +5 -3
  28. data/lib/icfs/store.rb +20 -18
  29. data/lib/icfs/store_fs.rb +7 -5
  30. data/lib/icfs/store_s3.rb +4 -2
  31. data/lib/icfs/users.rb +5 -3
  32. data/lib/icfs/users_fs.rb +8 -6
  33. data/lib/icfs/users_redis.rb +12 -10
  34. data/lib/icfs/users_s3.rb +6 -4
  35. data/lib/icfs/utils/backup.rb +30 -29
  36. data/lib/icfs/utils/check.rb +36 -34
  37. data/lib/icfs/validate.rb +24 -15
  38. data/lib/icfs/web/auth_ssl.rb +7 -9
  39. data/lib/icfs/web/client.rb +671 -679
  40. data/lib/icfs.rb +174 -10
  41. metadata +16 -7
  42. data/devel/devel-webrick.yml +0 -49
data/lib/icfs/users_s3.rb CHANGED
@@ -9,6 +9,8 @@
9
9
  # This program is distributed WITHOUT ANY WARRANTY; without even the
10
10
  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
11
 
12
+ # frozen_string_literal: true
13
+
12
14
  require 'aws-sdk-s3'
13
15
 
14
16
  module ICFS
@@ -28,7 +30,7 @@ class UsersS3 < Users
28
30
  def initialize(s3, bucket, prefix=nil)
29
31
  @s3 = s3
30
32
  @bck = bucket
31
- @pre = prefix || ''.freeze
33
+ @pre = prefix || ''
32
34
  end
33
35
 
34
36
 
@@ -36,7 +38,7 @@ class UsersS3 < Users
36
38
  # Where to store user
37
39
  #
38
40
  def _path(user)
39
- @pre + user + '.json'.freeze
41
+ @pre + user + '.json'
40
42
  end # def _path()
41
43
  private :_path
42
44
 
@@ -51,7 +53,7 @@ class UsersS3 < Users
51
53
  # (see Users#read)
52
54
  #
53
55
  def read(urg)
54
- Items.validate(urg, 'User/Role/Group name'.freeze, Items::FieldUsergrp)
56
+ Items.validate(urg, 'User/Role/Group name', Items::FieldUsergrp)
55
57
  json = @s3.get_object( bucket: @bck, key: _path(urg) ).body.read
56
58
  return JSON.parse(json)
57
59
  rescue
@@ -63,7 +65,7 @@ class UsersS3 < Users
63
65
  # (see Users#write)
64
66
  #
65
67
  def write(obj)
66
- Items.validate(obj, 'User/Role/Group'.freeze, Users::ValUser)
68
+ Items.validate(obj, 'User/Role/Group', Users::ValUser)
67
69
  json = JSON.pretty_generate(obj)
68
70
  @s3.put_object( bucket: @bck, key: _path(obj['name']), body: json )
69
71
  end # def write()
@@ -9,9 +9,10 @@
9
9
  # This program is distributed WITHOUT ANY WARRANTY; without even the
10
10
  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
11
 
12
+ # frozen_string_literal: true
13
+
12
14
  require_relative '../store_fs'
13
15
 
14
- #
15
16
  module ICFS
16
17
 
17
18
  module Utils
@@ -40,12 +41,12 @@ class Backup
40
41
  # Copy an item
41
42
  #
42
43
  def _copy_item(dest, title, read, write, args, val=nil)
43
- @log.debug('ICFS copy: %s'.freeze % title)
44
+ @log.debug('ICFS copy: %s' % title)
44
45
 
45
46
  # read the item
46
47
  json = @store.send(read, *args)
47
48
  if !json
48
- @log.warn('ICFS copy: %s is missing'.freeze % title)
49
+ @log.warn('ICFS copy: %s is missing' % title)
49
50
  return nil
50
51
  end
51
52
 
@@ -54,7 +55,7 @@ class Backup
54
55
  obj = JSON.parse(json)
55
56
  err = Validate.check(obj, val)
56
57
  if err
57
- @log.error('ICFS copy: %s bad format'.freeze % title)
58
+ @log.error('ICFS copy: %s bad format' % title)
58
59
  return nil
59
60
  end
60
61
  end
@@ -64,7 +65,7 @@ class Backup
64
65
  return obj
65
66
 
66
67
  rescue JSON::ParserError
67
- @log.error('ICFS copy: %s bad JSON'.freeze % title)
68
+ @log.error('ICFS copy: %s bad JSON' % title)
68
69
  return nil
69
70
  end # def _item
70
71
  private :_copy_item
@@ -79,17 +80,17 @@ class Backup
79
80
  # @param lnum_min [Integer] The lowest log
80
81
  #
81
82
  def copy(cid, dest, lnum_min=1, lnum_max=0)
82
- @log.info('ICFS copy: %s %d-%d'.freeze % [cid, lnum_min, lnum_max])
83
+ @log.info('ICFS copy: %s %d-%d' % [cid, lnum_min, lnum_max])
83
84
 
84
85
  # if no max specified, pull from current
85
86
  if lnum_max == 0
86
87
  json = @cache.current_read(cid)
87
- cur = Items.parse(json, 'current'.freeze, Items::ItemCurrent)
88
+ cur = Items.parse(json, 'current', Items::ItemCurrent)
88
89
  lnum_max = cur['log']
89
90
  end
90
91
 
91
92
  if lnum_min > lnum_max
92
- raise ArgumentError, 'ICFS copy, log num min is larger than max'.freeze
93
+ raise ArgumentError, 'ICFS copy, log num min is larger than max'
93
94
  end
94
95
 
95
96
  # each log
@@ -98,7 +99,7 @@ class Backup
98
99
 
99
100
  # copy the log
100
101
  log = _copy_item(dest,
101
- 'log %d'.freeze % lnum,
102
+ 'log %d' % lnum,
102
103
  :log_read,
103
104
  :log_write,
104
105
  [cid, lnum],
@@ -112,7 +113,7 @@ class Backup
112
113
  # entry
113
114
  enum = log['entry']['num']
114
115
  _copy_item(dest,
115
- 'entry %d-%d'.freeze % [enum, lnum],
116
+ 'entry %d-%d' % [enum, lnum],
116
117
  :entry_read,
117
118
  :entry_write,
118
119
  [cid, enum, lnum]
@@ -122,7 +123,7 @@ class Backup
122
123
  if log['index']
123
124
  xnum = log['index']['num']
124
125
  _copy_item(dest,
125
- 'index %d-%d'.freeze % [xnum, lnum],
126
+ 'index %d-%d' % [xnum, lnum],
126
127
  :index_read,
127
128
  :index_write,
128
129
  [cid, xnum, lnum]
@@ -133,7 +134,7 @@ class Backup
133
134
  if log['action']
134
135
  anum = log['action']['num']
135
136
  _copy_item(dest,
136
- 'action %d-%d'.freeze % [anum, lnum],
137
+ 'action %d-%d' % [anum, lnum],
137
138
  :action_read,
138
139
  :action_write,
139
140
  [cid, anum, lnum]
@@ -143,7 +144,7 @@ class Backup
143
144
  # case
144
145
  if log['case_hash']
145
146
  _copy_item(dest,
146
- 'case %d'.freeze % lnum,
147
+ 'case %d' % lnum,
147
148
  :case_read,
148
149
  :case_write,
149
150
  [cid, lnum]
@@ -155,12 +156,12 @@ class Backup
155
156
  log['files_hash'].each_index do |fraw|
156
157
  fnum = fraw + 1
157
158
 
158
- @log.debug('ICFS copy: file %d-%d-%d'.freeze % [enum, lnum, fnum])
159
+ @log.debug('ICFS copy: file %d-%d-%d' % [enum, lnum, fnum])
159
160
 
160
161
  # read
161
162
  fi = @store.file_read(cid, enum, lnum, fnum)
162
163
  if !fi
163
- @log.warn('ICFS copy: file %d-%d-%d missing'.freeze %
164
+ @log.warn('ICFS copy: file %d-%d-%d missing' %
164
165
  [enum, lnum, fnum])
165
166
  next
166
167
  end
@@ -185,12 +186,12 @@ class Backup
185
186
  # Restore an item
186
187
  #
187
188
  def _restore_item(src, title, read, write, args_st, args_ca, val=nil)
188
- @log.debug('ICFS restore: %s'.freeze % title)
189
+ @log.debug('ICFS restore: %s' % title)
189
190
 
190
191
  # read the item
191
192
  json = src.send(read, *args_st)
192
193
  if !json
193
- @log.warn('ICFS restore: %s is missing'.freeze % title)
194
+ @log.warn('ICFS restore: %s is missing' % title)
194
195
  return nil
195
196
  end
196
197
 
@@ -199,7 +200,7 @@ class Backup
199
200
  obj = JSON.parse(json)
200
201
  err = Validate.check(obj, val)
201
202
  if err
202
- @log.error('ICFS restore: %s bad format'.freeze % title)
203
+ @log.error('ICFS restore: %s bad format' % title)
203
204
  return nil
204
205
  end
205
206
  end
@@ -222,7 +223,7 @@ class Backup
222
223
  # @param lnum_min [Integer] The lowest log
223
224
  #
224
225
  def restore(cid, src, lnum_min=0, lnum_max=0)
225
- @log.info('ICFS restore: %s %d-%d'.freeze % [cid, lnum_min, lnum_max])
226
+ @log.info('ICFS restore: %s %d-%d' % [cid, lnum_min, lnum_max])
226
227
 
227
228
  # take lock
228
229
  @cache.lock_take(cid)
@@ -231,7 +232,7 @@ class Backup
231
232
  # read current
232
233
  json = @cache.current_read(cid)
233
234
  if json
234
- cur = Items.parse(json, 'current'.freeze, Items::ItemCurrent)
235
+ cur = Items.parse(json, 'current', Items::ItemCurrent)
235
236
  else
236
237
  cur = {
237
238
  'icfs' => 1,
@@ -248,7 +249,7 @@ class Backup
248
249
 
249
250
  # sanity check min & max
250
251
  if (lnum_min > lnum_max) && (lnum_max != 0)
251
- raise ArgumentError: 'ICFS restore, log min is larger than max'.freeze
252
+ raise ArgumentError: 'ICFS restore, log min is larger than max'
252
253
  end
253
254
 
254
255
  # max entry, action, index
@@ -263,7 +264,7 @@ class Backup
263
264
 
264
265
  # copy the log
265
266
  log, litem = _restore_item(src,
266
- 'log %d'.freeze % lnum,
267
+ 'log %d' % lnum,
267
268
  :log_read,
268
269
  :log_write,
269
270
  [cid, lnum],
@@ -281,7 +282,7 @@ class Backup
281
282
  # entry
282
283
  enum = log['entry']['num']
283
284
  _restore_item(src,
284
- 'entry %d-%d'.freeze % [enum, lnum],
285
+ 'entry %d-%d' % [enum, lnum],
285
286
  :entry_read,
286
287
  :entry_write,
287
288
  [cid, enum, lnum],
@@ -293,7 +294,7 @@ class Backup
293
294
  if log['index']
294
295
  xnum = log['index']['num']
295
296
  _restore_item(src,
296
- 'index %d-%d'.freeze % [xnum, lnum],
297
+ 'index %d-%d' % [xnum, lnum],
297
298
  :index_read,
298
299
  :index_write,
299
300
  [cid, xnum, lnum],
@@ -306,7 +307,7 @@ class Backup
306
307
  if log['action']
307
308
  anum = log['action']['num']
308
309
  _restore_item(src,
309
- 'action %d-%d'.freeze % [anum, lnum],
310
+ 'action %d-%d' % [anum, lnum],
310
311
  :action_read,
311
312
  :action_write,
312
313
  [cid, anum, lnum],
@@ -318,7 +319,7 @@ class Backup
318
319
  # case
319
320
  if log['case_hash']
320
321
  _restore_item(src,
321
- 'case %d'.freeze % lnum,
322
+ 'case %d' % lnum,
322
323
  :case_read,
323
324
  :case_write,
324
325
  [cid, lnum],
@@ -331,12 +332,12 @@ class Backup
331
332
  log['files_hash'].each_index do |fraw|
332
333
  fnum = fraw + 1
333
334
 
334
- @log.debug('ICFS restore: file %d-%d-%d'.freeze % [enum, lnum, fnum])
335
+ @log.debug('ICFS restore: file %d-%d-%d' % [enum, lnum, fnum])
335
336
 
336
337
  # read
337
338
  fi = src.file_read(cid, enum, lnum, fnum)
338
339
  if !fi
339
- @log.warn('ICFS restore: file %d-%d-%d missing'.freeze %
340
+ @log.warn('ICFS restore: file %d-%d-%d missing' %
340
341
  [enum, lnum, fnum])
341
342
  next
342
343
  end
@@ -364,7 +365,7 @@ class Backup
364
365
  'index' => imax,
365
366
  'hash' => ICFS.hash(llast)
366
367
  }
367
- nitem = Items.generate(cur, 'current'.freeze, Items::ItemCurrent)
368
+ nitem = Items.generate(cur, 'current', Items::ItemCurrent)
368
369
  @cache.current_write(cid, nitem)
369
370
 
370
371
  ensure
@@ -9,6 +9,8 @@
9
9
  # This program is distributed WITHOUT ANY WARRANTY; without even the
10
10
  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
11
 
12
+ # frozen_string_literal: true
13
+
12
14
  #
13
15
  module ICFS
14
16
 
@@ -42,15 +44,15 @@ class Check
42
44
  #
43
45
  def _item(title, read, read_args, hist, hash, val, con)
44
46
 
45
- @log.debug('ICFS check: %s'.freeze % title)
47
+ @log.debug('ICFS check: %s' % title)
46
48
 
47
49
  # read
48
50
  json = @store.send(read, *read_args)
49
51
  if !json
50
52
  if hist
51
- @log.warn('ICFS check: %s is missing and historical'.freeze % title)
53
+ @log.warn('ICFS check: %s is missing and historical' % title)
52
54
  else
53
- @log.error('ICFS check: %s is missing and current'.freeze % title)
55
+ @log.error('ICFS check: %s is missing and current' % title)
54
56
  end
55
57
  return nil
56
58
  end
@@ -58,24 +60,24 @@ class Check
58
60
  # hash
59
61
  if hash
60
62
  if hash != ICFS.hash(json)
61
- @log.error('ICFS check: %s hash bad'.freeze % title)
63
+ @log.error('ICFS check: %s hash bad' % title)
62
64
  end
63
65
  else
64
- @log.warn('ICFS check: %s hash unverified'.freeze % title)
66
+ @log.warn('ICFS check: %s hash unverified' % title)
65
67
  end
66
68
 
67
69
  # parse
68
70
  obj = JSON.parse(json)
69
71
  err = Validate.check(obj, val)
70
72
  if err
71
- @log.error('ICFS check: %s bad format'.freeze % title)
73
+ @log.error('ICFS check: %s bad format' % title)
72
74
  return nil
73
75
  end
74
76
 
75
77
  # inconsistent
76
78
  con.each do |name, num|
77
79
  if obj[name] != read_args[num]
78
- @log.error('ICFS check: %s inconsistent'.freeze % title)
80
+ @log.error('ICFS check: %s inconsistent' % title)
79
81
  return nil
80
82
  end
81
83
  end
@@ -83,7 +85,7 @@ class Check
83
85
  return obj
84
86
 
85
87
  rescue JSON::ParserError
86
- @log.error('ICFS check: %s bad JSON'.freeze % title)
88
+ @log.error('ICFS check: %s bad JSON' % title)
87
89
  return nil
88
90
  end # def _item()
89
91
  private :_item
@@ -96,7 +98,7 @@ class Check
96
98
  # @param cur_hash [String] The hash of the last log
97
99
  #
98
100
  def check(cid, cur_log, cur_hash, opts={})
99
- @log.info('ICFS check: case %s'.freeze % cid)
101
+ @log.info('ICFS check: case %s' % cid)
100
102
 
101
103
  ent_cur = Set.new
102
104
  cse_cur = false
@@ -113,15 +115,15 @@ class Check
113
115
 
114
116
  # log
115
117
  log = _item(
116
- 'log %d'.freeze % lnum,
118
+ 'log %d' % lnum,
117
119
  :log_read,
118
120
  [cid, lnum],
119
121
  false,
120
122
  hash_log,
121
123
  Items::ItemLog,
122
124
  [
123
- ['caseid'.freeze, 0].freeze,
124
- ['log'.freeze, 1].freeze
125
+ ['caseid', 0].freeze,
126
+ ['log', 1].freeze
125
127
  ].freeze,
126
128
  )
127
129
  if !log
@@ -132,7 +134,7 @@ class Check
132
134
 
133
135
  # check that time decreases
134
136
  if log['time'] > time_log
135
- @log.warn('ICFS check: log %d time inconsistent'.freeze % lnum)
137
+ @log.warn('ICFS check: log %d time inconsistent' % lnum)
136
138
  end
137
139
 
138
140
  # entry
@@ -145,9 +147,9 @@ class Check
145
147
  log['entry']['hash'],
146
148
  Items::ItemEntry,
147
149
  [
148
- ['caseid'.freeze, 0].freeze,
149
- ['entry'.freeze, 1].freeze,
150
- ['log'.freeze, 2].freeze
150
+ ['caseid', 0].freeze,
151
+ ['entry', 1].freeze,
152
+ ['log', 2].freeze
151
153
  ].freeze,
152
154
  )
153
155
 
@@ -156,7 +158,7 @@ class Check
156
158
  ent_cur.add(enum)
157
159
  if ent['files']
158
160
  ent['files'].each do |fd|
159
- file_cur.add( '%d-%d-%d'.freeze % [enum, fd['num'], fd['log']] )
161
+ file_cur.add( '%d-%d-%d' % [enum, fd['num'], fd['log']] )
160
162
  end
161
163
  end
162
164
  end
@@ -172,9 +174,9 @@ class Check
172
174
  log['index']['hash'],
173
175
  Items::ItemIndex,
174
176
  [
175
- ['caseid'.freeze, 0].freeze,
176
- ['index'.freeze, 1].freeze,
177
- ['log'.freeze, 2].freeze
177
+ ['caseid', 0].freeze,
178
+ ['index', 1].freeze,
179
+ ['log', 2].freeze
178
180
  ]
179
181
  )
180
182
  idx_cur.add(xnum)
@@ -184,16 +186,16 @@ class Check
184
186
  if log['action']
185
187
  anum = log['action']['num']
186
188
  act = _item(
187
- 'action %d-%d'.freeze % [anum, lnum],
189
+ 'action %d-%d' % [anum, lnum],
188
190
  :action_read,
189
191
  [cid, anum, lnum],
190
192
  act_cur.include?(anum),
191
193
  log['action']['hash'],
192
194
  Items::ItemAction,
193
195
  [
194
- ['caseid'.freeze, 0].freeze,
195
- ['action'.freeze, 1].freeze,
196
- ['log'.freeze, 2].freeze
196
+ ['caseid', 0].freeze,
197
+ ['action', 1].freeze,
198
+ ['log', 2].freeze
197
199
  ]
198
200
  )
199
201
  act_cur.add(anum)
@@ -202,15 +204,15 @@ class Check
202
204
  # case
203
205
  if log['case_hash']
204
206
  cse = _item(
205
- 'case %d'.freeze % lnum,
207
+ 'case %d' % lnum,
206
208
  :case_read,
207
209
  [cid, lnum],
208
210
  cse_cur,
209
211
  log['case_hash'],
210
212
  Items::ItemCase,
211
213
  [
212
- ['caseid'.freeze, 0].freeze,
213
- ['log'.freeze, 1].freeze
214
+ ['caseid', 0].freeze,
215
+ ['log', 1].freeze
214
216
  ]
215
217
  )
216
218
  cse_cur = true
@@ -221,11 +223,11 @@ class Check
221
223
  fnum = 0
222
224
  log['files_hash'].each do |hash|
223
225
  fnum = fnum + 1
224
- fn = '%d-%d-%d'.freeze % [enum, fnum, lnum]
226
+ fn = '%d-%d-%d' % [enum, fnum, lnum]
225
227
  cur = file_cur.include?(fn)
226
228
  file_cur.delete(fn) if cur
227
229
 
228
- @log.debug('ICFS check: file %s'.freeze % fn)
230
+ @log.debug('ICFS check: file %s' % fn)
229
231
 
230
232
  # read/size
231
233
  if opts[:hash_all] || (cur && opts[:hash_current])
@@ -239,10 +241,10 @@ class Check
239
241
  # missing
240
242
  if !fi
241
243
  if cur
242
- @log.error('ICFS check: file %s missing and current'.freeze %
244
+ @log.error('ICFS check: file %s missing and current' %
243
245
  fn)
244
246
  else
245
- @log.warn('ICFS check: file %s missing and historical'.freeze %
247
+ @log.warn('ICFS check: file %s missing and historical' %
246
248
  fn)
247
249
  end
248
250
  end
@@ -251,7 +253,7 @@ class Check
251
253
  if fi.is_a?(File)
252
254
  # check
253
255
  if hash != ICFS.hash_temp(fi)
254
- @log.error('ICFS check: file %s hash bad'.freeze % fn)
256
+ @log.error('ICFS check: file %s hash bad' % fn)
255
257
  end
256
258
 
257
259
  # close
@@ -272,11 +274,11 @@ class Check
272
274
  # check for any non-existant current files
273
275
  unless file_cur.empty?
274
276
  file_cur.each do |fn|
275
- @log.error('ICFS check: file %s current but not logged'.freeze % fn)
277
+ @log.error('ICFS check: file %s current but not logged' % fn)
276
278
  end
277
279
  end
278
280
 
279
- @log.debug('ICFS check: case %s complete'.freeze % cid)
281
+ @log.debug('ICFS check: case %s complete' % cid)
280
282
  end # def check()
281
283
 
282
284
 
data/lib/icfs/validate.rb CHANGED
@@ -9,6 +9,8 @@
9
9
  # This program is distributed WITHOUT ANY WARRANTY; without even the
10
10
  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
11
 
12
+ # frozen_string_literal: true
13
+
12
14
  require 'set'
13
15
  require 'tempfile'
14
16
 
@@ -107,7 +109,7 @@ module Validate
107
109
  if val[:check] == obj
108
110
  return nil
109
111
  else
110
- return 'not equal'.freeze
112
+ return 'not equal'
111
113
  end
112
114
  end # def self.equals()
113
115
 
@@ -123,14 +125,14 @@ module Validate
123
125
  #
124
126
  #
125
127
  def self.integer(obj, val)
126
- return 'not an Integer'.freeze unless obj.is_a?(Integer)
128
+ return 'not an Integer' unless obj.is_a?(Integer)
127
129
 
128
130
  if val[:min] && obj < val[:min]
129
- return 'too small: %d < %d'.freeze % [obj, val[:min]]
131
+ return 'too small: %d < %d' % [obj, val[:min]]
130
132
  end
131
133
 
132
134
  if val[:max] && obj > val[:max]
133
- return 'too large: %d > %d '.freeze % [obj, val[:max]]
135
+ return 'too large: %d > %d ' % [obj, val[:max]]
134
136
  end
135
137
 
136
138
  return nil
@@ -147,14 +149,14 @@ module Validate
147
149
  # @return [String,NilClass] error descriptions
148
150
  #
149
151
  def self.float(obj, val)
150
- return 'not a Float'.freeze unless obj.is_a?(Float)
152
+ return 'not a Float' unless obj.is_a?(Float)
151
153
 
152
154
  if val[:min] && obj < val[:min]
153
- return 'too small: %f < %f'.freeze % [obj, val[:min]]
155
+ return 'too small: %f < %f' % [obj, val[:min]]
154
156
  end
155
157
 
156
158
  if val[:max] && obj > val[:max]
157
- return 'too large: %f > %f'.freeze % [obj, val[:max]]
159
+ return 'too large: %f > %f' % [obj, val[:max]]
158
160
  end
159
161
 
160
162
  return nil
@@ -173,10 +175,10 @@ module Validate
173
175
  if val[:type]
174
176
  if val[:type].is_a?(Array)
175
177
  val[:type].each{|cl| return nil if obj.is_a?(cl) }
176
- return 'not a listed type'.freeze
178
+ return 'not a listed type'
177
179
  else
178
180
  if !obj.is_a?(val[:type])
179
- return 'not a %s'.freeze % val[:type].name
181
+ return 'not a %s' % val[:type].name
180
182
  end
181
183
  end
182
184
  end
@@ -200,7 +202,7 @@ module Validate
200
202
  def self.string(obj, val)
201
203
 
202
204
  # type
203
- return 'not a String'.freeze unless obj.is_a?(String)
205
+ return 'not a String' unless obj.is_a?(String)
204
206
 
205
207
  errors = {}
206
208
 
@@ -212,7 +214,7 @@ module Validate
212
214
 
213
215
  # if whitelisting
214
216
  if val[:whitelist]
215
- errors[:whitelist] = 'Value was not whitelisted'.freeze
217
+ errors[:whitelist] = 'Value was not whitelisted'
216
218
  end
217
219
 
218
220
  # min length
@@ -250,7 +252,7 @@ module Validate
250
252
  def self.array(obj, val)
251
253
 
252
254
  # type
253
- return 'not an Array'.freeze unless obj.is_a?(Array)
255
+ return 'not an Array' unless obj.is_a?(Array)
254
256
 
255
257
  errors = {}
256
258
 
@@ -316,7 +318,7 @@ module Validate
316
318
  def self.hash(obj, val)
317
319
 
318
320
  # type
319
- return 'not a Hash'.freeze unless obj.is_a?(Hash)
321
+ return 'not a Hash' unless obj.is_a?(Hash)
320
322
 
321
323
  ary = obj.to_a
322
324
  chk = Array.new(ary.size)
@@ -331,7 +333,7 @@ module Validate
331
333
 
332
334
  # missing required key
333
335
  if ix.nil?
334
- errors[key] = 'missing'.freeze
336
+ errors[key] = 'missing'
335
337
  next
336
338
  end
337
339
 
@@ -361,7 +363,7 @@ module Validate
361
363
  if !val[:others]
362
364
  chk.each_index do |ix|
363
365
  next if chk[ix]
364
- errors[ary[ix][0]] = 'not allowed'.freeze
366
+ errors[ary[ix][0]] = 'not allowed'
365
367
  end
366
368
  end
367
369
 
@@ -411,6 +413,13 @@ module Validate
411
413
  }.freeze
412
414
 
413
415
 
416
+ # String
417
+ IsString = {
418
+ method: :type,
419
+ type: String,
420
+ }.freeze
421
+
422
+
414
423
  end # module ICFS::Validate
415
424
 
416
425
  end # module ICFS
@@ -9,6 +9,8 @@
9
9
  # This program is distributed WITHOUT ANY WARRANTY; without even the
10
10
  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
11
 
12
+ # frozen_string_literal: true
13
+
12
14
  #
13
15
  module ICFS
14
16
  module Web
@@ -24,13 +26,11 @@ class AuthSsl
24
26
  # @param app [Object] The rack app
25
27
  # @param map [Object] Maps DN to user name
26
28
  # @param api [ICFS::Api] the Api
27
- # @param cfg [ICFS::Web::Config] the config settings
28
29
  #
29
- def initialize(app, map, api, cfg)
30
+ def initialize(app, map, api)
30
31
  @app = app
31
32
  @map = map
32
33
  @api = api
33
- @cfg = cfg
34
34
  end
35
35
 
36
36
 
@@ -46,8 +46,8 @@ class AuthSsl
46
46
  unless env['SSL_CLIENT_VERIFY'] == 'SUCCESS'
47
47
  return [
48
48
  400,
49
- {'Content-Type' => 'text/plain'.freeze},
50
- ['Client certificate required.'.freeze]
49
+ {'Content-Type' => 'text/plain'},
50
+ ['Client certificate required.']
51
51
  ]
52
52
  end
53
53
 
@@ -56,7 +56,7 @@ class AuthSsl
56
56
  if user.nil?
57
57
  return [
58
58
  400,
59
- {'Content-Type' => 'text/plain'.freeze},
59
+ {'Content-Type' => 'text/plain'},
60
60
  ['%s: No User' % env['SSL_CLIENT_S_DN']]
61
61
  ]
62
62
  end
@@ -67,13 +67,11 @@ class AuthSsl
67
67
  rescue Error::NotFound, Error::Value => err
68
68
  return [
69
69
  400,
70
- {'Content-Type' => 'text/plain'.freeze},
70
+ {'Content-Type' => 'text/plain'},
71
71
  ['%s: %s' % [err.message, env['SSL_CLIENT_S_DN']]]
72
72
  ]
73
73
  end
74
74
  env['icfs'] = @api
75
- @cfg.load(user)
76
- env['icfs.config'] = @cfg
77
75
  return @app.call(env)
78
76
  end # def call()
79
77