fastlane-plugin-samsungknox 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.md +53 -0
- data/lib/fastlane/plugin/samsungknox/actions/knox_configure_library_upload_app_action.rb +90 -0
- data/lib/fastlane/plugin/samsungknox/helper/knox_configure_error_message.rb +31 -0
- data/lib/fastlane/plugin/samsungknox/helper/knox_configure_library_already_exists_app_version_check.rb +33 -0
- data/lib/fastlane/plugin/samsungknox/helper/knox_configure_library_upload_app.rb +31 -0
- data/lib/fastlane/plugin/samsungknox/helper/knox_configure_upload_application_to_library.rb +0 -0
- data/lib/fastlane/plugin/samsungknox/helper/knox_token_generator.rb +121 -0
- data/lib/fastlane/plugin/samsungknox/version.rb +5 -0
- data/lib/fastlane/plugin/samsungknox.rb +16 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 687b05c8ca644f58b824440eb3432392a52c5fa773de88bfe372c736568b5cf8
|
4
|
+
data.tar.gz: '08b1eede7d6c7141ce4e503c8417d77a5ab6ee91c1de7a9890f7a28fec80f450'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1c7a159f8251cac45b64f7b34a64064dabbc7154c6ce85562aa8324000bfa765b87b4b04d286e1405d09ba27dec76ae89dcaa19ef4a6130a16a47c068a9630d0
|
7
|
+
data.tar.gz: 0c636b4e3f83bea1cd84d3b9163800db4aadca4b4a5b2d3fb02866c88215ea3c4fa97b36def2a245448bc9841377666b2a420adb0b02cf0e2d28c46bf04057b3
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# samsungknox plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-samsungknox)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-samsungknox`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin samsungknox
|
11
|
+
```
|
12
|
+
|
13
|
+
## About samsungknox
|
14
|
+
|
15
|
+
SamsungKnox products to Fastlanehttps://redredgroup.github.io/samsungknox/docs/knox-fastlane
|
16
|
+
|
17
|
+
**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
|
18
|
+
|
19
|
+
## Example
|
20
|
+
|
21
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
22
|
+
|
23
|
+
**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
|
24
|
+
|
25
|
+
## Run tests for this plugin
|
26
|
+
|
27
|
+
To run both the tests, and code style validation, run
|
28
|
+
|
29
|
+
```
|
30
|
+
rake
|
31
|
+
```
|
32
|
+
|
33
|
+
To automatically fix many of the styling issues, use
|
34
|
+
|
35
|
+
```
|
36
|
+
rubocop -a
|
37
|
+
```
|
38
|
+
|
39
|
+
## Issues and Feedback
|
40
|
+
|
41
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
42
|
+
|
43
|
+
## Troubleshooting
|
44
|
+
|
45
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
46
|
+
|
47
|
+
## Using _fastlane_ Plugins
|
48
|
+
|
49
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
50
|
+
|
51
|
+
## About _fastlane_
|
52
|
+
|
53
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/knox_token_generator'
|
3
|
+
# require_relative '../helper/knox_configure_library_already_exists_app_version_check'
|
4
|
+
require_relative '../helper/knox_configure_library_upload_app'
|
5
|
+
|
6
|
+
module Fastlane
|
7
|
+
module Actions
|
8
|
+
class KnoxConfigureLibraryUploadAppAction < Action
|
9
|
+
def self.run(params)
|
10
|
+
UI.message("Welcome to Knox Configure Library Application Upload Fastlane!")
|
11
|
+
|
12
|
+
credential = {
|
13
|
+
path: params[:credential_path],
|
14
|
+
key: params[:credential_key]
|
15
|
+
}
|
16
|
+
|
17
|
+
access_token = KnoxTokenGenerator.generate_knox_access_token(
|
18
|
+
credential,
|
19
|
+
params[:clientIdentifierJwtToken]
|
20
|
+
)
|
21
|
+
|
22
|
+
# application_info = KnoxConfigureLibraryAlreadyExistsAppVersionCheck.search_by_package_name(
|
23
|
+
# access_token[:token],
|
24
|
+
# params[:package_name]
|
25
|
+
# )
|
26
|
+
|
27
|
+
KnoxConfigureLibraryUploadApp.upload_app(
|
28
|
+
access_token[:token],
|
29
|
+
params[:app_file_path]
|
30
|
+
)
|
31
|
+
|
32
|
+
UI.success(access_token)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.description
|
37
|
+
"fastlane plugin for Samsung Knox Configure Library"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.authors
|
41
|
+
["jieey1140"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.return_value
|
45
|
+
# If your method provides a return value, you can describe here what it does
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.details
|
49
|
+
"upload applications built using the Samsung Knox Configure Library in fastlane."
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.available_options
|
53
|
+
[
|
54
|
+
# FastlaneCore::ConfigItem.new(key: :app_name,
|
55
|
+
# env_name: "KC_APP_NAME",
|
56
|
+
# description: "",
|
57
|
+
# optional: false),
|
58
|
+
# FastlaneCore::ConfigItem.new(key: :package_name,
|
59
|
+
# env_name: "KC_PACKAGE_NAME",
|
60
|
+
# description: "",
|
61
|
+
# optional: false),
|
62
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
63
|
+
env_name: "KC_APP_DESCRIPTION",
|
64
|
+
description: "",
|
65
|
+
optional: true),
|
66
|
+
FastlaneCore::ConfigItem.new(key: :app_file_path,
|
67
|
+
env_name: "KC_APP_FILE_PATH",
|
68
|
+
description: "Path to your APK file",
|
69
|
+
optional: true),
|
70
|
+
FastlaneCore::ConfigItem.new(key: :credential_key,
|
71
|
+
env_name: "KNOX_CREDENTIAL_KEY",
|
72
|
+
description: "",
|
73
|
+
optional: true),
|
74
|
+
FastlaneCore::ConfigItem.new(key: :credential_path,
|
75
|
+
env_name: "KNOX_CREDENTIAL_PATH",
|
76
|
+
description: "",
|
77
|
+
optional: true),
|
78
|
+
FastlaneCore::ConfigItem.new(key: :clientIdentifierJwtToken,
|
79
|
+
env_name: "KNOX_CLIENT_IEDNTIFIER_JWT_TOKEN",
|
80
|
+
description: "",
|
81
|
+
optional: false),
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.is_supported?(platform)
|
86
|
+
[:android].include?(platform)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ErrorMessage
|
2
|
+
INVALID_JWT = 'clientIdentifierJwtToken is not a json web token type. check your clientIdentifierJwtToken'
|
3
|
+
BOTH_CREDENTIAL_DETECTED = "credentials exceeded one. You must specify either key or path."
|
4
|
+
CREDENTIAL_IS_NOT_JSON_TYPE = "credential is not json type. Please check the credential file or path"
|
5
|
+
CREDENTIAL_MISSING = "credential is missing. Please check the credential file or path"
|
6
|
+
CREDENTIAL_FILE_NOT_FOUND = "credential read failed. Please check the credential path"
|
7
|
+
IDENTIFIER_MISSING = 'credential -> identifier is missing. Please check the credential file or path.'
|
8
|
+
PRIVATE_MISSING = 'credential -> Private is missing. Please check the credential file or path.'
|
9
|
+
PUBLIC_MISSING = 'credential -> Public is missing. Please check the credential file or path.'
|
10
|
+
|
11
|
+
|
12
|
+
def self.aab_upload_error(aab_state)
|
13
|
+
"Failed to process the AAB: #{aab_state}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.binary_not_found(binary_type)
|
17
|
+
"Could not find the #{binary_type}. Make sure you set the #{binary_type} path parameter to point to your #{binary_type}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.parse_binary_metadata_error(binary_type)
|
21
|
+
"Failed to extract #{binary_type} metadata from the #{binary_type} path"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.upload_binary_error(binary_type)
|
25
|
+
"App Distribution halted because it had a problem uploading the #{binary_type}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.binary_processing_error(binary_type)
|
29
|
+
"App Distribution failed to process the #{binary_type}"
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module Fastlane
|
3
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
4
|
+
|
5
|
+
module KnoxConfigureLibraryAlreadyExistsAppVersionCheck
|
6
|
+
|
7
|
+
def self.search_by_package_name(access_token, package_name)
|
8
|
+
uri = URI("https://eu-kcs-api.samsungknox.com/kcs/v1/kc/applications?packageName=#{package_name}")
|
9
|
+
|
10
|
+
UI.message(access_token)
|
11
|
+
request = Net::HTTP::Get.new(uri)
|
12
|
+
request["Content-Type"] = "application/json"
|
13
|
+
request["X-KNOX-APITOKEN"] = access_token
|
14
|
+
|
15
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
16
|
+
http.use_ssl = true if uri.scheme == 'https'
|
17
|
+
|
18
|
+
response = http.request(request)
|
19
|
+
|
20
|
+
if response.is_a?(Net::HTTPSuccess)
|
21
|
+
data = JSON.parse(response.body)
|
22
|
+
# UI.success(data)
|
23
|
+
|
24
|
+
|
25
|
+
# UI.success('✅ ams accessToken generated successfully!')
|
26
|
+
return data["accessToken"]
|
27
|
+
else
|
28
|
+
raise "Request failed with response: #{response.body}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'net/http/post/multipart'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
6
|
+
|
7
|
+
module KnoxConfigureLibraryUploadApp
|
8
|
+
def self.upload_app(access_token, app_file_path)
|
9
|
+
uri = URI('https://eu-kcs-api.samsungknox.com/kcs/v1/kc/applications/upload')
|
10
|
+
|
11
|
+
File.open(app_file_path) do |file|
|
12
|
+
request = Net::HTTP::Post::Multipart.new uri,
|
13
|
+
"file" => UploadIO.new(file, "multipart/form-data", File.basename(app_file_path))
|
14
|
+
|
15
|
+
request['X-KNOX-APITOKEN'] = access_token
|
16
|
+
|
17
|
+
UI.message("⌛ Uploading the #{'APP'}.")
|
18
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
19
|
+
http.request(request)
|
20
|
+
end
|
21
|
+
|
22
|
+
if response.is_a?(Net::HTTPSuccess)
|
23
|
+
data = JSON.parse(response.body)
|
24
|
+
UI.success(data)
|
25
|
+
else
|
26
|
+
raise "Request failed with response: #{response.body}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
require 'jwt'
|
3
|
+
require 'openssl'
|
4
|
+
require 'base64'
|
5
|
+
require 'securerandom'
|
6
|
+
|
7
|
+
module Fastlane
|
8
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
9
|
+
|
10
|
+
module KnoxTokenGenerator
|
11
|
+
def self.read_credential(credential)
|
12
|
+
UI.crash!(ErrorMessage::BOTH_CREDENTIAL_DETECTED) if credential[:path] && credential[:key]
|
13
|
+
UI.crash!(ErrorMessage::NO_CREDENTIAL_PROVIDED) unless credential[:path] || credential[:key]
|
14
|
+
|
15
|
+
begin
|
16
|
+
credential_manifest = if credential[:path]
|
17
|
+
begin
|
18
|
+
JSON.parse(File.read(credential[:path]))
|
19
|
+
rescue Errno::ENOENT, Errno::EACCES => e
|
20
|
+
raise ErrorMessage::CREDENTIAL_FILE_NOT_FOUND, e.message
|
21
|
+
end
|
22
|
+
elsif credential[:key]
|
23
|
+
JSON.parse(credential[:key])
|
24
|
+
end
|
25
|
+
|
26
|
+
raise TypeError.new(ErrorMessage::IDENTIFIER_MISSING) if credential_manifest['Identifier'].nil? || credential_manifest['Identifier'].empty?
|
27
|
+
raise TypeError.new(ErrorMessage::PRIVATE_MISSING) if credential_manifest['Private'].nil? || credential_manifest['Private'].empty?
|
28
|
+
raise TypeError.new(ErrorMessage::PUBLIC_MISSING) if credential_manifest['Public'].nil? || credential_manifest['Public'].empty?
|
29
|
+
|
30
|
+
credential_manifest
|
31
|
+
rescue JSON::ParserError
|
32
|
+
raise ErrorMessage::CREDENTIAL_IS_NOT_JSON_TYPE
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.generate_jwt_id
|
37
|
+
SecureRandom.uuid + SecureRandom.uuid
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.export_credential_private_key(private_key_str)
|
41
|
+
pem_header = "-----BEGIN PRIVATE KEY-----\n"
|
42
|
+
pem_footer = "\n-----END PRIVATE KEY-----"
|
43
|
+
full_key = pem_header + private_key_str + pem_footer
|
44
|
+
OpenSSL::PKey::RSA.new(full_key)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.export_credential_public_der_key(public_key_str)
|
48
|
+
pem_header = "-----BEGIN PUBLIC KEY-----\n"
|
49
|
+
pem_footer = "\n-----END PUBLIC KEY-----"
|
50
|
+
full_key = pem_header + public_key_str + pem_footer
|
51
|
+
rsa_public_key = OpenSSL::PKey::RSA.new(full_key)
|
52
|
+
der_public_key = rsa_public_key.to_der
|
53
|
+
base64_public_key = Base64.encode64(der_public_key)
|
54
|
+
base64_public_key
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.get_access_token(validity_for_access_token_in_minutes, base64_encoded_string_public_key, client_identifier_jwt)
|
58
|
+
uri = URI('https://eu-kcs-api.samsungknox.com/ams/v1/users/accesstoken')
|
59
|
+
|
60
|
+
request_body = {
|
61
|
+
base64EncodedStringPublicKey: base64_encoded_string_public_key,
|
62
|
+
clientIdentifierJwt: client_identifier_jwt
|
63
|
+
}
|
64
|
+
request_body[:validityForAccessTokenInMinutes] = validity_for_access_token_in_minutes unless validity_for_access_token_in_minutes.nil?
|
65
|
+
|
66
|
+
response = Net::HTTP.post(uri, request_body.to_json, "Content-Type" => "application/json")
|
67
|
+
|
68
|
+
if response.is_a?(Net::HTTPSuccess)
|
69
|
+
data = JSON.parse(response.body)
|
70
|
+
UI.success('✅ ams accessToken generated successfully!')
|
71
|
+
return data["accessToken"]
|
72
|
+
else
|
73
|
+
raise "Request failed with response: #{response.body}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.generate_knox_access_token(credential, clientIdentifierJwtToken)
|
78
|
+
UI.header('Step: 🔐 KNOX ACCESS TOKEN GENERATE STEP 🔐 ')
|
79
|
+
|
80
|
+
UI.message('⏳ Sign the knox token using the credential...')
|
81
|
+
generate_signed_jwt_result = generate_signed_jwt(credential, clientIdentifierJwtToken, true)
|
82
|
+
|
83
|
+
base64_encoding_public_Key = generate_signed_jwt_result[:public_key]
|
84
|
+
sign_by_client_identifier_jwt_token = generate_signed_jwt_result[:token]
|
85
|
+
|
86
|
+
UI.message('⏳ Request the knox client identifier jwt ams access token...')
|
87
|
+
ams_access_token = get_access_token(30, base64_encoding_public_Key, sign_by_client_identifier_jwt_token)
|
88
|
+
UI.message('⏳ Sign the knox token using the ams access token and private key...')
|
89
|
+
token = generate_signed_jwt(credential, ams_access_token, false)
|
90
|
+
|
91
|
+
return { token: token[:token] }
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.generate_signed_jwt(credential, token_or_access, is_client_identifier)
|
95
|
+
|
96
|
+
cred_data = read_credential(credential)
|
97
|
+
|
98
|
+
private_key_str = cred_data['Private']
|
99
|
+
public_key_str = cred_data['Public']
|
100
|
+
|
101
|
+
private_key = export_credential_private_key(private_key_str)
|
102
|
+
public_key = export_credential_public_der_key(public_key_str).gsub(/\n/, '')
|
103
|
+
|
104
|
+
payload = { publicKey: public_key }
|
105
|
+
payload[:clientIdentifier] = token_or_access if is_client_identifier
|
106
|
+
payload[:accessToken] = token_or_access unless is_client_identifier
|
107
|
+
|
108
|
+
payload[:aud] = 'KnoxWSM'
|
109
|
+
payload[:exp] = Time.now.to_i + (30 * 60)
|
110
|
+
payload[:iat] = Time.now.to_i
|
111
|
+
payload[:algorithm] = 'RS512'
|
112
|
+
payload[:jti] = generate_jwt_id
|
113
|
+
|
114
|
+
|
115
|
+
token = JWT.encode(payload, private_key, 'RS512')
|
116
|
+
|
117
|
+
UI.success('✅ token generated successfully!')
|
118
|
+
return { public_key: public_key, token: token }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/samsungknox/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Samsungknox
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::Samsungknox.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-samsungknox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jieey1140
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fastlane
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.217.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.217.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec_junit_formatter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.50.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.50.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-performance
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-require_tools
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description:
|
154
|
+
email: seihoonkim@redredgroup.com
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- LICENSE
|
160
|
+
- README.md
|
161
|
+
- lib/fastlane/plugin/samsungknox.rb
|
162
|
+
- lib/fastlane/plugin/samsungknox/actions/knox_configure_library_upload_app_action.rb
|
163
|
+
- lib/fastlane/plugin/samsungknox/helper/knox_configure_error_message.rb
|
164
|
+
- lib/fastlane/plugin/samsungknox/helper/knox_configure_library_already_exists_app_version_check.rb
|
165
|
+
- lib/fastlane/plugin/samsungknox/helper/knox_configure_library_upload_app.rb
|
166
|
+
- lib/fastlane/plugin/samsungknox/helper/knox_configure_upload_application_to_library.rb
|
167
|
+
- lib/fastlane/plugin/samsungknox/helper/knox_token_generator.rb
|
168
|
+
- lib/fastlane/plugin/samsungknox/version.rb
|
169
|
+
homepage: https://github.com/REDREDGROUP/samsungknox
|
170
|
+
licenses:
|
171
|
+
- Apache-2.0
|
172
|
+
metadata:
|
173
|
+
rubygems_mfa_required: 'true'
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options: []
|
176
|
+
require_paths:
|
177
|
+
- lib
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '2.6'
|
183
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
requirements: []
|
189
|
+
rubygems_version: 3.4.14
|
190
|
+
signing_key:
|
191
|
+
specification_version: 4
|
192
|
+
summary: SamsungKnox products to Fastlane https://redredgroup.github.io/samsungknox/docs/knox-fastlane
|
193
|
+
test_files: []
|