Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import static org.easymock.EasyMock.anyObject;
Expand Down Expand Up @@ -250,8 +251,8 @@ public void testSimpleDescriptorHandlerQueryStringCredentialAliasCreation() thro
assertEquals("Unexpected cluster name for the alias (should be the topology name).",
testDescriptor.getName(), capturedCluster.getValue());
assertEquals("Unexpected alias name.", "encryptQueryString", capturedAlias.getValue());
assertEquals("Unexpected alias value (should be master secret + topology name.",
testMasterSecret + testDescriptor.getName(), capturedPwd.getValue());
assertEquals("Unexpected alias value.",
String.format(Locale.ROOT, SimpleDescriptorHandler.ENCRYPT_QUERY_STRING_TEMPLATE, testMasterSecret, testDescriptor.getName()), capturedPwd.getValue());

assertEquals(1, NoOpServiceDiscovery.discoveryCalled);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public class SimpleDescriptorHandler {
"CLIENTID",
"HEALTH").collect(Collectors.toSet()));

public static final String ENCRYPT_QUERY_STRING_TEMPLATE = "knox:query-encryption:%s:%s";

public static Map<String, File> handle(GatewayConfig config, File desc, File destDirectory, Service...gatewayServices) throws IOException {
return handle(config, SimpleDescriptorFactory.parse(desc.getAbsolutePath()), desc.getParentFile(), destDirectory, gatewayServices);
}
Expand Down Expand Up @@ -312,7 +314,7 @@ private static boolean provisionQueryParamEncryptionCredential(final String topo
AliasService aliasService = services.getService(ServiceType.ALIAS_SERVICE);
if (aliasService != null) {
// Derive and set the query param encryption password
String queryEncryptionPass = new String(ms.getMasterSecret()) + topologyName;
String queryEncryptionPass = String.format(Locale.ROOT, ENCRYPT_QUERY_STRING_TEMPLATE, new String(ms.getMasterSecret()), topologyName);
aliasService.addAliasForCluster(topologyName, "encryptQueryString", queryEncryptionPass);
result = true;
}
Expand Down
Loading