certstepper 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/certstepper.rb +137 -58
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7faacbe1cfba5a2d252d438ae12598777d45d4a1
4
- data.tar.gz: 4601dbf4b3495ca03419c2069b7dea9b8d6e3aa5
3
+ metadata.gz: 7b20b0c5bf7433d5abf30aa4a910a2ab58cf1d33
4
+ data.tar.gz: 535389d69c1aa5acd381e97c284617f5253ffe6f
5
5
  SHA512:
6
- metadata.gz: 5bc163ff1c473f142cf53c17e55f27c833063aed4dc951e56483237ca0a65355dc6b94e39d0f91293f607c1fe76e00566e0e8e7a0b64723ee7c319af5557de03
7
- data.tar.gz: 749457b2cb2bfeb4f7e904cea685c1a37ec6293bc4e2c94b59d313adc34369772adee6d065c8046d687df0c515a062c0df2b5a0663bc6f8e56b3bc358aec419b
6
+ metadata.gz: 206e93a58d081b5985f4c13df89fc296908b8fece244af2216bf595b8d50e9f663c92e81aa69823d43dafc303bc7d85d4c77e362ae87c361536a5bbd71e4187f
7
+ data.tar.gz: bfdee98c951cc1a91ea5f611a83fb31a486e8115df480179a7984e884d76433e43a70ea1c3605fa35e703aaf07a0023b098b62c2ea6911eb95bc77411cb6d2dd
data/lib/certstepper.rb CHANGED
@@ -1,70 +1,142 @@
1
1
  require "pathname"
2
2
  require "fileutils"
3
+ require "json"
4
+
5
+ class String
6
+ def strip_control_characters()
7
+ chars.each_with_object("") do |char, str|
8
+ str << char unless char.ascii_only? and (char.ord < 32 or char.ord == 127)
9
+ end
10
+ end
11
+
12
+ def strip_control_and_extended_characters()
13
+ chars.each_with_object("") do |char, str|
14
+ str << char if char.ascii_only? and char.ord.between?(32,126)
15
+ end
16
+ end
17
+ end
18
+
3
19
  module CertStepper
4
20
 
5
- class Cert
6
- attr_accessor :email
7
- attr_accessor :password
8
- attr_accessor :profile_id
9
- attr_accessor :profile_name
10
- end
11
-
12
- def self.startStep
13
- # if ARGV.length==0 || ARGV == nil
14
- # puts "error: Parameter does not match,there is not any parameter"
15
- # return nil
16
- # end
17
-
18
- self.parseData
19
-
20
- console_root_path = @@root_path.gsub /[\s]/ , "\\ "
21
- open_dir ="open #{console_root_path}"
22
- system("open #{console_root_path}")
23
- puts "Apple Cert Create Stepper\n"
24
- @@certs.each do |cert|
25
- puts "----------- begin #{cert.profile_id} Cert ----------- \n"
26
- self.createDir @@root_path + "/#{cert.profile_name}"
27
- puts "1. copy email. <press enter>"
28
- self.getUserInput
29
- self.copyToClipboard cert.email
30
- puts "email coppied : #{cert.email}\n"
31
- puts "2. copy password. <press enter>"
32
- self.getUserInput
33
- self.copyToClipboard cert.password
34
- puts "password coppied : #{cert.password}\n"
35
- puts "3.import and export cert"
36
- self.dealCert cert
37
- puts "4. copy profile name. <press enter>"
38
- self.getUserInput
39
- self.copyToClipboard cert.profile_name
40
- puts "name coppied : #{cert.profile_name}\n"
41
- puts "\n5. copy profile id. <press enter>"
42
- self.getUserInput
43
- self.copyToClipboard cert.profile_id
44
- puts "id coppied : #{cert.profile_id}"
45
- puts "\n6. copy profile name. <press enter>"
46
- self.getUserInput
47
- self.copyToClipboard cert.profile_name
48
- puts "name coppied : #{cert.profile_name}\n"
49
- puts "\n7. move profile to destination from download. <press enter>"
50
- self.getUserInput
51
- mobileprovision_name = "#{cert.profile_name}.mobileprovision"
52
- source_file = "#{File.expand_path('~')}/Downloads/#{mobileprovision_name}"
53
- dest_file = "#{@@root_path}/#{cert.profile_name}/#{mobileprovision_name}"
54
- if File.exist? source_file
55
- FileUtils.mv source_file , dest_file
56
- puts "#{mobileprovision_name} moved\n\n"
21
+ class Cert
22
+ attr_accessor :email
23
+ attr_accessor :password
24
+ attr_accessor :profile_id
25
+ attr_accessor :profile_name
26
+ end
27
+
28
+
29
+
30
+ def self.startStep
31
+ # if ARGV.length==0 || ARGV == nil
32
+ # puts "error: Parameter does not match,there is not any parameter"
33
+ # return nil
34
+ # end
35
+
36
+
37
+ file = File.open("#{File.expand_path('~')}/certstepper.log", "w")
38
+ file.write("#{ARGV}\n")
39
+
40
+ begin
41
+ if ARGV[0].start_with? "chrome-extension:"
42
+ finished = false
43
+ while !finished do
44
+ str = self.getUserInput[1..-1]
45
+ str =str.strip_control_characters
46
+
47
+ file.write("#{str}\n")
48
+
49
+
50
+ file.write "start parse #{str.class}\n"
51
+ my_hash = JSON.parse str
52
+ file.write("end parse#{my_hash}\n")
53
+
54
+ start_path = my_hash["start_path"]
55
+ profile_name = my_hash["name"]
56
+ if start_path
57
+ file.write("#start work \n")
58
+ self.startWorkByChromeExtension start_path , profile_name
59
+ finished = true
60
+ end
61
+ end
57
62
  else
58
- puts "#{mobileprovision_name} doesn't exist. Please download and move by yourself !\n\n"
63
+ self.parseData ARGV[0]
64
+ self.startWork
59
65
  end
60
66
 
61
- end
62
- end
67
+ rescue => e
68
+ f.write e.backtrace
69
+ end
70
+
71
+
72
+ file.close
73
+ end
74
+
75
+ def self.startWorkByChromeExtension(root_path,profile_name)
76
+ file = File.open("/Users/mac/Desktop/CertSimplify/some_file", "a")
77
+ console_root_path = root_path.gsub /[\s]/ , "\\ "
78
+ system("open #{console_root_path}")
79
+ self.createDir root_path + "/#{profile_name}"
80
+ self.dealCertByChrome root_path , profile_name
81
+ mobileprovision_name = "#{profile_name}.mobileprovision"
82
+ source_file = "#{File.expand_path('~')}/Downloads/#{mobileprovision_name}"
83
+ dest_file = "#{root_path}/#{profile_name}/#{mobileprovision_name}"
84
+ if File.exist? source_file
85
+ FileUtils.mv source_file , dest_file
86
+ end
87
+
88
+ end
89
+
90
+ def self.startWork
91
+
92
+ console_root_path = @@root_path.gsub /[\s]/ , "\\ "
93
+ open_dir ="open #{console_root_path}"
94
+ system("open #{console_root_path}")
95
+ puts "Apple Cert Create Stepper\n"
96
+ @@certs.each do |cert|
97
+ puts "----------- begin #{cert.profile_id} Cert ----------- \n"
98
+ self.createDir @@root_path + "/#{cert.profile_name}"
99
+ puts "1. copy email. <press enter>"
100
+ self.getUserInput
101
+ self.copyToClipboard cert.email
102
+ puts "email coppied : #{cert.email}\n"
103
+ puts "2. copy password. <press enter>"
104
+ self.getUserInput
105
+ self.copyToClipboard cert.password
106
+ puts "password coppied : #{cert.password}\n"
107
+ puts "3.import and export cert"
108
+ self.dealCert cert
109
+ puts "4. copy profile name. <press enter>"
110
+ self.getUserInput
111
+ self.copyToClipboard cert.profile_name
112
+ puts "name coppied : #{cert.profile_name}\n"
113
+ puts "\n5. copy profile id. <press enter>"
114
+ self.getUserInput
115
+ self.copyToClipboard cert.profile_id
116
+ puts "id coppied : #{cert.profile_id}"
117
+ puts "\n6. copy profile name. <press enter>"
118
+ self.getUserInput
119
+ self.copyToClipboard cert.profile_name
120
+ puts "name coppied : #{cert.profile_name}\n"
121
+ puts "\n7. move profile to destination from download. <press enter>"
122
+ self.getUserInput
123
+ mobileprovision_name = "#{cert.profile_name}.mobileprovision"
124
+ source_file = "#{File.expand_path('~')}/Downloads/#{mobileprovision_name}"
125
+ dest_file = "#{@@root_path}/#{cert.profile_name}/#{mobileprovision_name}"
126
+ if File.exist? source_file
127
+ FileUtils.mv source_file , dest_file
128
+ puts "#{mobileprovision_name} moved\n\n"
129
+ else
130
+ puts "#{mobileprovision_name} doesn't exist. Please download and move by yourself !\n\n"
131
+ end
132
+
133
+ end
134
+ end
63
135
 
64
- def self.parseData
136
+ def self.parseData(start_path)
65
137
  @@certs = Array.new
66
138
  index = 0
67
- file_name = ARGV[0]
139
+ file_name = start_path
68
140
  @@root_path = Pathname.new(file_name).parent.to_s
69
141
  @@file_path
70
142
  new_cert = nil
@@ -106,7 +178,7 @@ module CertStepper
106
178
 
107
179
  def self.getUserInput
108
180
  begin
109
- $stdin.gets
181
+ return $stdin.gets
110
182
  rescue => e
111
183
 
112
184
  end
@@ -119,4 +191,11 @@ module CertStepper
119
191
  system "security delete-keychain 123456"
120
192
  end
121
193
 
194
+ def self.dealCertByChrome(root_path , profile_name)
195
+ system "security create-keychain -P 123456"
196
+ system "security add-trusted-cert -r unspecified -k 123456 #{File.expand_path('~')}/Downloads/ios_development.cer"
197
+ system "security export -k 123456 -t certs -f pkcs12 -o #{root_path}/#{profile_name}/cert.p12"
198
+ system "security delete-keychain 123456"
199
+ end
200
+
122
201
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: certstepper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - chengkai