|
4 | 4 | import com.fasterxml.jackson.core.type.TypeReference; |
5 | 5 | import com.fasterxml.jackson.databind.ObjectMapper; |
6 | 6 | import com.google.gson.Gson; |
| 7 | +import org.apache.commons.lang3.StringUtils; |
7 | 8 | import org.slf4j.Logger; |
8 | 9 | import org.slf4j.LoggerFactory; |
9 | 10 |
|
|
25 | 26 | public class CxAuth { |
26 | 27 | private Logger log = LoggerFactory.getLogger(CxAuth.class.getName()); |
27 | 28 | private String baseuri; |
| 29 | + private String baseAuthUri; |
| 30 | + private String tenant; |
28 | 31 | private String key; |
29 | 32 | private String secret; |
30 | 33 | private String apikey; |
31 | 34 | private URI executable = null; |
32 | 35 | private static final Gson gson = new Gson(); |
33 | 36 |
|
34 | 37 | public CxAuth(CxScanConfig scanConfig, Logger log) |
35 | | - throws InterruptedException, IOException, URISyntaxException, CxExeception { |
36 | | - if (scanConfig == null) throw new CxExeception("CxScanConfig object returned as null!"); |
| 38 | + throws IOException, URISyntaxException, CxException { |
| 39 | + if (scanConfig == null) throw new CxException("CxScanConfig object returned as null!"); |
| 40 | + |
37 | 41 | this.baseuri = scanConfig.getBaseUri(); |
38 | | - if (scanConfig.getClientId() != null && scanConfig.getClientSecret() != null) { |
39 | | - this.key = scanConfig.getClientId(); |
40 | | - this.secret = scanConfig.getClientSecret(); |
41 | | - } else if (scanConfig.getApiKey() != null) { |
42 | | - this.apikey = scanConfig.getApiKey(); |
43 | | - } |
| 42 | + this.baseAuthUri = scanConfig.getBaseAuthUri(); |
| 43 | + this.tenant = scanConfig.getTenant(); |
| 44 | + this.key = scanConfig.getClientId(); |
| 45 | + this.secret = scanConfig.getClientSecret(); |
| 46 | + this.apikey = scanConfig.getApiKey(); |
| 47 | + |
44 | 48 | if (scanConfig.getPathToExecutable() != null && !scanConfig.getPathToExecutable().isEmpty()) { |
45 | 49 | File file = new File(scanConfig.getPathToExecutable()); |
46 | 50 | this.executable = file.toURI(); |
@@ -157,6 +161,7 @@ public CxScan cxScanShow(String id) throws IOException, InterruptedException { |
157 | 161 | List<String> commands = initialCommands(); |
158 | 162 | commands.add("scan"); |
159 | 163 | commands.add("show"); |
| 164 | + commands.add("--scan-id"); |
160 | 165 | commands.add(id); |
161 | 166 | CxScan scanObject = runExecutionCommands(commands); |
162 | 167 | if (scanObject != null) |
@@ -197,10 +202,23 @@ public List<String> initialCommands() { |
197 | 202 | List<String> commands = new ArrayList<String>(); |
198 | 203 | commands.add(executable.getPath()); |
199 | 204 | addAuthCredentials(commands); |
| 205 | + |
| 206 | + if (!StringUtils.isEmpty(this.tenant)) { |
| 207 | + commands.add("--tenant"); |
| 208 | + commands.add(this.tenant); |
| 209 | + } |
| 210 | + |
200 | 211 | commands.add("--base-uri"); |
201 | 212 | commands.add(baseuri); |
| 213 | + |
| 214 | + if (!StringUtils.isEmpty(this.baseAuthUri)) { |
| 215 | + commands.add("--base-auth-uri"); |
| 216 | + commands.add(this.baseAuthUri); |
| 217 | + } |
| 218 | + |
202 | 219 | commands.add("--format"); |
203 | 220 | commands.add("json"); |
| 221 | + |
204 | 222 | return commands; |
205 | 223 | } |
206 | 224 |
|
|
0 commit comments