-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript_helper.rb
More file actions
48 lines (41 loc) · 1.26 KB
/
script_helper.rb
File metadata and controls
48 lines (41 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
################################################################################
# BMC Software, Inc.
# Confidential and Proprietary
# Copyright (c) BMC Software, Inc. 2001-2012
# All Rights Reserved.
################################################################################
# Private Routines to Support scriping #
# BJB 9/8/10
require 'base64'
require 'nori'
PRIVATE_PREFIX = "__SS__" # Must also change in config/environment.rb and streamstep.py
def strip_private_flag(params)
params.each do |item, val|
if val.class == String
params[item] = decrypt(val.gsub(PRIVATE_PREFIX, "")) if val.include?(PRIVATE_PREFIX)
end
end
end
def decrypt_string_with_prefix(val)
unless val.blank?
decrypt(val.gsub(PRIVATE_PREFIX, ""))
else
val
end
end
def decrypt(val)
enc = Base64::decode64(val).reverse
enc = Base64::decode64(enc).gsub(PRIVATE_PREFIX,"")
end
def encrypt(val)
enc = Base64::encode64(val).reverse
enc = PRIVATE_PREFIX + Base64::encode64(enc).gsub("\n","")
end
def sub_tokens(script_params,var_string)
prop_val = var_string.match('rpm{[^{}]*}')
while ! prop_val.nil? do
var_string = var_string.sub(prop_val[0],script_params[prop_val[0][4..-2]])
prop_val = var_string.match('rpm{[^{}]*}')
end
return var_string
end