Skip to content

Commit 250a257

Browse files
author
rathnapandi
committed
- jaxb-runtime to use latest version to avoid maven pulling random jaxb-runtime version for ehcache.
- Compare basic auth and ssl passwords if system property is set with com.axway.apimanager.api.model.disable.confidential.fields=false
1 parent dab46ff commit 250a257

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ public void addQuotaConfiguration(API api, boolean addQuota) throws AppException
402402
try {
403403
applicationQuota = quotaAdapter.getQuota(APIManagerQuotaAdapter.Quota.APPLICATION_DEFAULT.getQuotaId(), api, false, false); // Get the Application-Default-Quota
404404
systemQuota = quotaAdapter.getQuota(APIManagerQuotaAdapter.Quota.SYSTEM_DEFAULT.getQuotaId(), api, false, false); // Get the Application-Default-QuotagetQuotaFromAPIManager(); // Get the System-Default-Quota
405+
translateMethodIdsToName(applicationQuota, api.getId());
406+
translateMethodIdsToName(systemQuota, api.getId());
405407
api.setApplicationQuota(applicationQuota);
406408
api.setSystemQuota(systemQuota);
407409
} catch (AppException e) {
@@ -410,6 +412,16 @@ public void addQuotaConfiguration(API api, boolean addQuota) throws AppException
410412
}
411413
}
412414

415+
public void translateMethodIdsToName(APIQuota apiQuota, String apiId) throws AppException {
416+
if(apiQuota != null) {
417+
APIManagerAPIMethodAdapter methodAdapter = APIManagerAdapter.getInstance().getMethodAdapter();
418+
List<QuotaRestriction> quotaRestrictions = apiQuota.getRestrictions();
419+
for (QuotaRestriction quotaRestriction : quotaRestrictions) {
420+
quotaRestriction.setMethod(methodAdapter.getMethodForId(apiId, quotaRestriction.getApiId()).getName());
421+
}
422+
}
423+
}
424+
413425
private void addExistingClientAppQuotas(API api, boolean addQuota) throws AppException {
414426
if (!addQuota || !APIManagerAdapter.getInstance().hasAdminAccount()) return;
415427
if (api.getApplications() == null || api.getApplications().isEmpty()) return;
@@ -418,8 +430,9 @@ private void addExistingClientAppQuotas(API api, boolean addQuota) throws AppExc
418430
} else {
419431
LOG.info("Loading application quotas for {} subscribed applications.", api.getApplications().size());
420432
}
433+
APIManagerQuotaAdapter quotaAdapter = APIManagerAdapter.getInstance().getQuotaAdapter();
421434
for (ClientApplication app : api.getApplications()) {
422-
APIQuota appQuota = APIManagerAdapter.getInstance().getQuotaAdapter().getQuota(app.getId(), null, true, true);
435+
APIQuota appQuota = quotaAdapter.getQuota(app.getId(), null, true, true);
423436
app.setAppQuota(appQuota);
424437
}
425438
}

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
public class AuthenticationProfile {
1111

12+
public static final String PASSWORD = "password";
1213
private String name;
1314

1415
private boolean isDefault;
@@ -64,16 +65,20 @@ public boolean equals(Object other) {
6465
Map<String, Object> thisParameters = this.getParameters();
6566
otherParameters.remove("_id_");
6667
thisParameters.remove("_id_");
67-
if(StringUtils.equals(authenticationProfile.getName(), this.getName())
68-
&& authenticationProfile.getIsDefault() == this.getIsDefault()
69-
&& StringUtils.equals(authenticationProfile.getType().name(), this.getType().name())){
70-
if(authenticationProfile.getType().equals(AuthType.ssl) || authenticationProfile.getType().equals(AuthType.http_basic)){
68+
if (StringUtils.equals(authenticationProfile.getName(), this.getName())
69+
&& authenticationProfile.getIsDefault() == this.getIsDefault()
70+
&& StringUtils.equals(authenticationProfile.getType().name(), this.getType().name())) {
71+
if (authenticationProfile.getType().equals(AuthType.ssl) || authenticationProfile.getType().equals(AuthType.http_basic)) {
7172
Map<String, Object> otherParametersCopy = new HashMap<>(otherParameters);
72-
otherParametersCopy.remove("password");
7373
Map<String, Object> thisParametersCopy = new HashMap<>(thisParameters);
74-
thisParametersCopy.remove("password");
74+
// Passwords are no longer exposed by API-Manager REST-API - Can't use it anymore to compare the state, but can be overridden by setting
75+
// system property com.axway.apimanager.api.model.disable.confidential.fields=false in API Gateway
76+
if (otherParametersCopy.get(PASSWORD) == null || thisParametersCopy.get(PASSWORD) == null) {
77+
otherParametersCopy.remove(PASSWORD);
78+
thisParametersCopy.remove(PASSWORD);
79+
}
7580
return otherParametersCopy.equals(thisParametersCopy);
76-
}else {
81+
} else {
7782
return otherParameters.equals(thisParameters);
7883
}
7984
}
@@ -90,7 +95,7 @@ public String toString() {
9095
parametersString = "{trustAll=" + this.getParameters().get("trustAll") + ", password=" + Utils.getEncryptedPassword() + ", pfx=" + pfx + "}";
9196
}
9297
return "AuthenticationProfile [name=" + name + ", isDefault=" + isDefault + ", parameters=" + parametersString
93-
+ ", type=" + type + "]";
98+
+ ", type=" + type + "]";
9499
}
95100

96101
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,18 @@ public static void addCustomPropertiesForEntity(List<? extends CustomPropertiesE
273273
if (filter.getCustomProperties() == null || entities.isEmpty()) {
274274
return;
275275
}
276-
Map<String, JsonNode> enitityAsJsonMappedWithId = new HashMap<>();
276+
Map<String, JsonNode> entityAsJsonMappedWithId = new HashMap<>();
277277
JsonNode jsonPayload = mapper.readTree(json);
278278
// Create a map based on the API-ID containing the original JSON-Payload received from API-Manager
279279
for (JsonNode node : jsonPayload) {
280280
String apiId = node.get("id").asText();
281-
enitityAsJsonMappedWithId.put(apiId, node);
281+
entityAsJsonMappedWithId.put(apiId, node);
282282
}
283283
Map<String, String> customProperties = new LinkedHashMap<>();
284284
// Iterate over all APIs (at this point not yet having the custom-properties serialized)
285285
for (CustomPropertiesEntity entity : entities) {
286286
// Get the original JSON-Payload for the current API fetched from API-Manager
287-
JsonNode node = enitityAsJsonMappedWithId.get(entity.getId());
287+
JsonNode node = entityAsJsonMappedWithId.get(entity.getId());
288288
// Iterate over all requested Custom-Properties that should be returned
289289
for (String customPropKey : filter.getCustomProperties()) {
290290
// Try to get the value for that custom property from the JSON-Payload

pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,18 @@
231231
<groupId>org.ehcache</groupId>
232232
<artifactId>ehcache</artifactId>
233233
<version>3.10.8</version>
234+
<exclusions>
235+
<exclusion>
236+
<groupId>org.glassfish.jaxb</groupId>
237+
<artifactId> jaxb-runtime</artifactId>
238+
</exclusion>
239+
</exclusions>
234240
</dependency>
241+
<!-- used by ehcache to read xml configuration-->
235242
<dependency>
236243
<groupId>org.glassfish.jaxb</groupId>
237244
<artifactId>jaxb-runtime</artifactId>
238-
<version>2.3.8</version>
245+
<version>4.0.5</version>
239246
</dependency>
240247
<!-- Used by olingo -->
241248
<dependency>

0 commit comments

Comments
 (0)