Skip to content

Commit 2643a7d

Browse files
author
Chris Wiechmann
committed
Merge branch 'develop' into test-with-7.7-20200130
2 parents 955f3fc + 744c7ac commit 2643a7d

28 files changed

Lines changed: 498 additions & 51 deletions

File tree

CHANGELOG.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,30 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
8+
### Fixed
9+
- Created BE-API response was parsing the response wrong. This could lead to an issue, if the API contains a createdOn field. (See issue [#112](https://github.com/Axway-API-Management-Plus/apim-cli/issues/112))
10+
- Unicode API-Name was not shown correctly in the Backend-API overview (See issue [#113](https://github.com/Axway-API-Management-Plus/apim-cli/issues/113))
11+
- Application-Subscription not restored, when API is Republished to be updated (See issue [#114](https://github.com/Axway-API-Management-Plus/apim-cli/issues/114))
12+
13+
### Added
14+
- Support to use a proxy for the API-Manager communication (See issue [#109](https://github.com/Axway-API-Management-Plus/apim-cli/issues/109))
15+
16+
## [1.3.0] 2020-11-10
817
### Added
918
- Search for APIs based on configured Inbound- and Outbound-Security (See issue [#86](https://github.com/Axway-API-Management-Plus/apim-cli/issues/86))
1019
- Added support for API-Manager Config/Alerts/Remote-Hosts (See issue [#68](https://github.com/Axway-API-Management-Plus/apim-cli/issues/68))
1120
- APIs now updated without Re-Creating them if possible (See issue [#95](https://github.com/Axway-API-Management-Plus/apim-cli/issues/95))
1221
- Support to manage the full Remote-Host introduced with the API-Manager September/2020 release
1322
- Capability to filter APIs based on their organization
1423
- New command to approve one or more APIs that are in pending state (See issue [#97](https://github.com/Axway-API-Management-Plus/apim-cli/issues/97))
15-
- Script apim.sh and apim.bat now optionally use AXWAY_APIM_CLI_HOME to setup the classpath (See issue [#100](https://github.com/Axway-API-Management-Plus/apim-cli/issues/100))
24+
- Scripts apim.sh and apim.bat now optionally use AXWAY_APIM_CLI_HOME to setup the classpath (See issue [#100](https://github.com/Axway-API-Management-Plus/apim-cli/issues/100))
1625
- Staging support for applications, users and organizations
1726
- Support for custom properties for applications, users and organizations (See issue [#93](https://github.com/Axway-API-Management-Plus/apim-cli/issues/93))
18-
- Support to read API-Description from a local markdown See issue [#110](https://github.com/Axway-API-Management-Plus/apim-cli/issues/110))
27+
- Support to read the API-Description from a local markdown file See issue [#110](https://github.com/Axway-API-Management-Plus/apim-cli/issues/110))
1928

2029
### Fixed
21-
- Avoid NPE during API-Export if custom-properties config is inconsistent (See issue [#90](https://github.com/Axway-API-Management-Plus/apim-cli/issues/90))
22-
- Disabled applications not created as disabled (See issue [#89](https://github.com/Axway-API-Management-Plus/apim-cli/issues/89))
30+
- Avoid NPE during API-Export if API-Custom-properties are not configured (See issue [#90](https://github.com/Axway-API-Management-Plus/apim-cli/issues/90))
31+
- Disabled applications not created as disabled in API-Manager (See issue [#89](https://github.com/Axway-API-Management-Plus/apim-cli/issues/89))
2332
- Support for special characters like an accent (See issue [#88](https://github.com/Axway-API-Management-Plus/apim-cli/issues/88))
2433
- Organizations now validated based on given stage (See issue [#58](https://github.com/Axway-API-Management-Plus/apim-cli/issues/58))
2534
- API-Import is now stopped if host and backendBasepath is missing (See issue [#53](https://github.com/Axway-API-Management-Plus/apim-cli/issues/53))
@@ -29,6 +38,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2938
### Changed
3039
- APIs no longer Re-Created if not needed (See issue [#95](https://github.com/Axway-API-Management-Plus/apim-cli/issues/95))
3140
- CLI Options parser refactored to be more flexible and support future requirements (See PR [#103](https://github.com/Axway-API-Management-Plus/apim-cli/pull/103))
41+
- Updated Commons-text from version 1.8 to version 1.9
42+
- Updated Jackson-Databind from version 2.9.10.5 to 2.9.10.6
43+
- Updated commons-lang3 from version 3.10 to 3.11
44+
- Updated commons-io from version 2.7 to 2.8.0
45+
- Updated org.apache.httpcomponents httpclient from version 4.5.12 to 4.5.13
46+
- Updated Jackson from 2.9.10 to 2.11.3
3247

3348
## [1.2.3] 2020-09-24
3449
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Watch this video (28 min): https://youtu.be/2i8i1zMAMps to get an overview + dem
1212

1313
With that, an API developer or the operations team is just providing the desired state configuration of the API, Application. When checked in, the [CI/CD-Pipeline](https://github.com/Axway-API-Management-Plus/apim-cli/wiki/7.-Pipeline-integration) picks it up and replicates it into the API Manager.
1414

15-
![API Manager Swagger-Promote overview](https://github.com/Axway-API-Management-Plus/apim-cli/blob/develop/misc/images/apimanager-swagger-promote-overview.png )
15+
![API Manager CLI overview](https://github.com/Axway-API-Management-Plus/apim-cli/blob/develop/misc/images/apim-cli-overview.png )
1616

1717
## Supported commands
1818

distribution/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.github.axway-api-management-plus.apim-cli</groupId>
77
<artifactId>parent</artifactId>
8-
<version>1.3.0-SNAPSHOT</version>
8+
<version>1.3.1-SNAPSHOT</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

modules/apim-adapter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.github.axway-api-management-plus.apim-cli</groupId>
66
<artifactId>parent</artifactId>
7-
<version>1.3.0-SNAPSHOT</version>
7+
<version>1.3.1-SNAPSHOT</version>
88
<relativePath>../../pom.xml</relativePath>
99
</parent>
1010

modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAdapter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,9 @@ public API importBackendAPI(API api) throws AppException {
718718
jsonNode = importFromSwagger(api);
719719
}
720720
API createdAPI = new APIBaseDefinition();
721-
createdAPI.setApiId(jsonNode.findPath("id").asText());
722-
createdAPI.setName(jsonNode.findPath("name").asText());
723-
createdAPI.setCreatedOn(Long.parseLong(jsonNode.findPath("createdOn").asText()));
721+
createdAPI.setApiId(jsonNode.get("id").asText());
722+
createdAPI.setName(jsonNode.get("name").asText());
723+
createdAPI.setCreatedOn(Long.parseLong(jsonNode.get("createdOn").asText()));
724724
return createdAPI;
725725
} catch (Exception e) {
726726
throw new AppException("Can't import definition / Create BE-API.", ErrorCode.CANT_CREATE_BE_API, e);
@@ -788,10 +788,10 @@ private JsonNode importFromSwagger(API api) throws URISyntaxException, AppExcept
788788
}
789789
try {
790790
entity = MultipartEntityBuilder.create()
791-
.addTextBody("name", api.getName())
791+
.addTextBody("name", api.getName(), ContentType.create("text/plain", StandardCharsets.UTF_8))
792792
.addTextBody("type", "swagger")
793793
.addBinaryBody("file", api.getApiDefinition().getApiSpecificationContent(), ContentType.create("application/json"), "filename")
794-
.addTextBody("fileName", "XYZ").addTextBody("organizationId", api.getOrganization().getId())
794+
.addTextBody("fileName", "XYZ").addTextBody("organizationId", api.getOrganization().getId(), ContentType.create("text/plain", StandardCharsets.UTF_8))
795795
.addTextBody("integral", "false").addTextBody("uploadType", "html5").build();
796796
RestAPICall importSwagger = new POSTRequest(entity, uri);
797797
importSwagger.setContentType(null);

modules/apim-adapter/src/main/java/com/axway/apim/adapter/clientApps/APIMgrAppsAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void addApplicationCredentials(ClientApplication app, boolean addCredentials) th
225225
for(int i=0; i<types.length; i++) {
226226
try {
227227
String type = types[i];
228-
TypeReference classType = classTypes[i];
228+
TypeReference<List<ClientAppCredential>> classType = classTypes[i];
229229
if(!applicationsCredentialCache.containsKey(app.getId()+"|"+type)) {
230230
uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/applications/"+app.getId()+"/"+type)
231231
.build();
@@ -272,7 +272,7 @@ private void addOauthResources(ClientApplication app, boolean includeOauthResour
272272
LOG.error("Error reading application oauth resources. Response-Code: "+statusCode+". Got response: '"+response+"'");
273273
throw new AppException("Error creating application' Response-Code: "+statusCode+"", ErrorCode.API_MANAGER_COMMUNICATION);
274274
}
275-
TypeReference classType = new TypeReference<List<ClientAppOauthResource>>() {};
275+
TypeReference<List<ClientAppOauthResource>> classType = new TypeReference<List<ClientAppOauthResource>>() {};
276276
oauthResources = mapper.readValue(response, classType);
277277
app.getOauthResources().addAll(oauthResources);
278278
} catch (Exception e) {

modules/apim-adapter/src/main/java/com/axway/apim/api/API.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ public void setState(String state) {
249249
* To make Desired and Actual API comparable this method is encapsulating the difference.
250250
* @see com.axway.apim.api.API#getState()
251251
* @return the state of the API (unpublished, deprecated, etc.)
252-
* @throws AppException in case of an error
253252
*/
254253
public String getState() {
255254
if(this.deprecated!=null

modules/apim-adapter/src/main/java/com/axway/apim/lib/CoreCLIOptions.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public Parameters getParams() throws AppException {
3838
// Also support -f for backwards compatibility
3939
if(!params.isForce()) params.setForce(Boolean.parseBoolean(getValue("f")));
4040

41+
params.setProxyHost(getValue("httpProxyHost"));
42+
params.setProxyPort((getValue("httpProxyPort")!=null) ? Integer.valueOf(getValue("httpProxyPort")) : null);
43+
params.setProxyUsername(getValue("httpProxyUsername"));
44+
params.setProxyPassword(getValue("httpProxyPassword"));
45+
4146
return (Parameters) params;
4247
}
4348

@@ -116,6 +121,26 @@ public void addOptions() {
116121
option.setRequired(false);
117122
option.setArgName("true");
118123
cliOptions.addInternalOption(option);
124+
125+
option = new Option("httpProxyHost", true, "Name of the proxy host");
126+
option.setRequired(false);
127+
option.setArgName("true");
128+
cliOptions.addInternalOption(option);
129+
130+
option = new Option("httpProxyPort", true, "The proxy port");
131+
option.setRequired(false);
132+
option.setArgName("true");
133+
cliOptions.addInternalOption(option);
134+
135+
option = new Option("httpProxyUsername", true, "The proxy username");
136+
option.setRequired(false);
137+
option.setArgName("true");
138+
cliOptions.addInternalOption(option);
139+
140+
option = new Option("httpProxyPassword", true, "The proxy username");
141+
option.setRequired(false);
142+
option.setArgName("true");
143+
cliOptions.addInternalOption(option);
119144
}
120145

121146
@Override

modules/apim-adapter/src/main/java/com/axway/apim/lib/CoreParameters.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ public static Mode valueOfDefault(String key) {
9090

9191
private String apimCLIHome;
9292

93+
private String proxyHost;
94+
95+
private Integer proxyPort;
96+
97+
private String proxyUsername;
98+
99+
private String proxyPassword;
100+
93101
public CoreParameters() {
94102
super();
95103
CoreParameters.instance = this;
@@ -358,6 +366,39 @@ public void setApimCLIHome(String apimCLIHome) {
358366
this.apimCLIHome = apimCLIHome;
359367
}
360368

369+
public String getProxyHost() {
370+
return proxyHost;
371+
}
372+
373+
public void setProxyHost(String proxyHost) {
374+
this.proxyHost = proxyHost;
375+
}
376+
377+
public Integer getProxyPort() {
378+
if(proxyPort == null) return -1;
379+
return proxyPort;
380+
}
381+
382+
public void setProxyPort(Integer proxyPort) {
383+
this.proxyPort = proxyPort;
384+
}
385+
386+
public String getProxyUsername() {
387+
return proxyUsername;
388+
}
389+
390+
public void setProxyUsername(String proxyUsername) {
391+
this.proxyUsername = proxyUsername;
392+
}
393+
394+
public String getProxyPassword() {
395+
return proxyPassword;
396+
}
397+
398+
public void setProxyPassword(String proxyPassword) {
399+
this.proxyPassword = proxyPassword;
400+
}
401+
361402
public List<CacheType> clearCaches() {
362403
if(getClearCache()==null) return null;
363404
if(cachesToClear!=null) return cachesToClear;

modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/APIMHttpClient.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,26 @@
55
import java.util.Map;
66

77
import org.apache.http.HttpHost;
8+
import org.apache.http.auth.AuthScope;
9+
import org.apache.http.auth.UsernamePasswordCredentials;
10+
import org.apache.http.client.CredentialsProvider;
811
import org.apache.http.client.HttpClient;
912
import org.apache.http.client.config.CookieSpecs;
1013
import org.apache.http.client.config.RequestConfig;
1114
import org.apache.http.client.protocol.HttpClientContext;
1215
import org.apache.http.config.Registry;
1316
import org.apache.http.config.RegistryBuilder;
1417
import org.apache.http.conn.routing.HttpRoute;
18+
import org.apache.http.conn.routing.HttpRoutePlanner;
1519
import org.apache.http.conn.socket.ConnectionSocketFactory;
1620
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
1721
import org.apache.http.conn.ssl.NoopHostnameVerifier;
1822
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
1923
import org.apache.http.conn.ssl.TrustAllStrategy;
2024
import org.apache.http.impl.client.BasicCookieStore;
25+
import org.apache.http.impl.client.BasicCredentialsProvider;
2126
import org.apache.http.impl.client.HttpClientBuilder;
27+
import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
2228
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
2329
import org.apache.http.ssl.SSLContextBuilder;
2430

@@ -104,13 +110,27 @@ private void createConnection(String apiManagerURL) throws AppException {
104110
// We have make sure, that cookies are correclty parsed!
105111
RequestConfig defaultRequestConfig = RequestConfig.custom()
106112
.setCookieSpec(CookieSpecs.STANDARD).build();
107-
108-
this.httpClient = HttpClientBuilder.create()
113+
CoreParameters params = CoreParameters.getInstance();
114+
115+
HttpClientBuilder clientBuilder = HttpClientBuilder.create()
109116
.disableRedirectHandling()
110117
.setConnectionManager(cm)
111118
.useSystemProperties()
112-
.setDefaultRequestConfig(defaultRequestConfig)
113-
.build();
119+
.setDefaultRequestConfig(defaultRequestConfig);
120+
121+
// Check if a proxy is configured
122+
if(params.getProxyHost()!=null) {
123+
HttpHost proxyHost = new HttpHost(params.getProxyHost(), params.getProxyPort());
124+
HttpRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxyHost);
125+
clientBuilder.setRoutePlanner(routePlanner);
126+
if(params.getProxyUsername()!=null) {
127+
CredentialsProvider credentialsPovider = new BasicCredentialsProvider();
128+
credentialsPovider.setCredentials(new AuthScope(params.getProxyHost(), params.getPort()), new UsernamePasswordCredentials(params.getProxyUsername(), params.getProxyPassword()));
129+
clientBuilder.setDefaultCredentialsProvider(credentialsPovider);
130+
}
131+
}
132+
133+
this.httpClient = clientBuilder.build();
114134
} catch (Exception e) {
115135
throw new AppException("Can't create connection to API-Manager.", ErrorCode.API_MANAGER_COMMUNICATION);
116136
}

0 commit comments

Comments
 (0)