@@ -161,7 +161,9 @@ public List<Environment> getAllEnvironments(String tenantDomain) throws APIManag
161
161
allEnvs .addAll (dynamicEnvs );
162
162
163
163
for (Environment env : allEnvs ) {
164
- decryptGatewayConfigurationValues (env );
164
+ if (env .getProvider ().equalsIgnoreCase (APIConstants .EXTERNAL_GATEWAY_VENDOR )) {
165
+ maskValues (env );
166
+ }
165
167
}
166
168
return allEnvs ;
167
169
}
@@ -200,7 +202,7 @@ public Environment addEnvironment(String tenantDomain, Environment environment)
200
202
validateForUniqueVhostNames (environment );
201
203
Environment environmentToStore = new Environment (environment );
202
204
encryptGatewayConfigurationValues (null , environmentToStore );
203
- apiMgtDAO .addEnvironment (tenantDomain , environment );
205
+ apiMgtDAO .addEnvironment (tenantDomain , environmentToStore );
204
206
return environment ;
205
207
}
206
208
@@ -217,6 +219,23 @@ public void deleteEnvironment(String tenantDomain, String uuid) throws APIManage
217
219
apiMgtDAO .deleteEnvironment (uuid );
218
220
}
219
221
222
+ public Environment getEnvironmentWithoutPropertyMasking (String tenantDomain , String uuid ) throws APIManagementException {
223
+ // priority for configured environments over dynamic environments
224
+ // name is the UUID of environments configured in api-manager.xml
225
+ Environment env = APIUtil .getReadOnlyEnvironments ().get (uuid );
226
+ if (env == null ) {
227
+ env = apiMgtDAO .getEnvironment (tenantDomain , uuid );
228
+ if (env == null ) {
229
+ String errorMessage = String .format ("Failed to retrieve Environment with UUID %s. Environment not found" ,
230
+ uuid );
231
+ throw new APIMgtResourceNotFoundException (errorMessage , ExceptionCodes .from (
232
+ ExceptionCodes .GATEWAY_ENVIRONMENT_NOT_FOUND , String .format ("UUID '%s'" , uuid ))
233
+ );
234
+ }
235
+ }
236
+ return env ;
237
+ }
238
+
220
239
@ Override
221
240
public boolean hasExistingDeployments (String tenantDomain , String uuid ) throws APIManagementException {
222
241
Environment existingEnv = getEnvironment (tenantDomain , uuid );
@@ -228,7 +247,7 @@ public boolean hasExistingDeployments(String tenantDomain, String uuid) throws A
228
247
@ Override
229
248
public Environment updateEnvironment (String tenantDomain , Environment environment ) throws APIManagementException {
230
249
// check if the VHost exists in the tenant domain with given UUID, throw error if not found
231
- Environment existingEnv = getEnvironment (tenantDomain , environment .getUuid ());
250
+ Environment existingEnv = getEnvironmentWithoutPropertyMasking (tenantDomain , environment .getUuid ());
232
251
if (existingEnv .isReadOnly ()) {
233
252
String errorMessage = String .format ("Failed to update Environment with UUID '%s'. Environment is read only" ,
234
253
environment .getUuid ());
@@ -247,6 +266,7 @@ public Environment updateEnvironment(String tenantDomain, Environment environmen
247
266
248
267
validateForUniqueVhostNames (environment );
249
268
environment .setId (existingEnv .getId ());
269
+ encryptGatewayConfigurationValues (existingEnv , environment );
250
270
Environment updatedEnvironment = apiMgtDAO .updateEnvironment (environment );
251
271
// If the update is successful without throwing an exception
252
272
// Perform a separate task of updating gateway label names
@@ -849,7 +869,7 @@ private KeyManagerConfigurationDTO decryptKeyManagerConfigurationValues(
849
869
return keyManagerConfigurationDTO ;
850
870
}
851
871
852
- private Environment decryptGatewayConfigurationValues (Environment environment )
872
+ public Environment decryptGatewayConfigurationValues (Environment environment )
853
873
throws APIManagementException {
854
874
855
875
Map <String , String > additionalProperties = environment .getAdditionalProperties ();
0 commit comments