Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

#459 Implemented DeploySecureCredentialsCommand #460

Merged
merged 1 commit into from
Dec 20, 2022
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
4 changes: 4 additions & 0 deletions src/main/java/com/marklogic/appdeployer/ConfigDir.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,8 @@ public void setDefaultContentDatabaseFilename(String contentDatabaseFilename) {
public File getProjectDir() {
return projectDir;
}

public File getSecureCredentialsDir() {
return new File(getSecurityDir(), "secure-credentials");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private void addCommandsThatDoNotWriteToDatabases(Map<String, List<Command>> map
securityCommands.add(new DeployCertificateAuthoritiesCommand());
securityCommands.add(new InsertCertificateHostsTemplateCommand());
securityCommands.add(new DeployExternalSecurityCommand());
securityCommands.add(new DeploySecureCredentialsCommand());
securityCommands.add(new DeployPrivilegesCommand());
securityCommands.add(new DeployPrivilegeRolesCommand());
securityCommands.add(new DeployProtectedCollectionsCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public abstract class SortOrderConstants {
public static Integer INSERT_HOST_CERTIFICATES = 28;

public static Integer DEPLOY_EXTERNAL_SECURITY = 35;
public static Integer DEPLOY_SECURE_CREDENTIALS = 36;
public static Integer DEPLOY_PROTECTED_COLLECTIONS = 40;
public static Integer DEPLOY_MIMETYPES = 45;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.marklogic.appdeployer.command.security;

import com.marklogic.appdeployer.command.AbstractResourceCommand;
import com.marklogic.appdeployer.command.CommandContext;
import com.marklogic.appdeployer.command.SortOrderConstants;
import com.marklogic.mgmt.resource.ResourceManager;
import com.marklogic.mgmt.resource.security.SecureCredentialsManager;

import java.io.File;

public class DeploySecureCredentialsCommand extends AbstractResourceCommand {

public DeploySecureCredentialsCommand() {
setExecuteSortOrder(SortOrderConstants.DEPLOY_SECURE_CREDENTIALS);
setUndoSortOrder(SortOrderConstants.DEPLOY_SECURE_CREDENTIALS);
}

@Override
protected File[] getResourceDirs(CommandContext context) {
return findResourceDirs(context, configDir -> configDir.getSecureCredentialsDir());
}

@Override
protected ResourceManager getResourceManager(CommandContext context) {
return new SecureCredentialsManager(context.getManageClient());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.marklogic.mgmt.resource.security;

import com.marklogic.mgmt.ManageClient;
import com.marklogic.mgmt.resource.AbstractResourceManager;

public class SecureCredentialsManager extends AbstractResourceManager {
public SecureCredentialsManager(ManageClient client) {
super(client);
}

@Override
public String getResourcesPath() {
return "/manage/v2/credentials/secure";
}

@Override
protected String getIdFieldName() {
return "name";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.marklogic.appdeployer.command.security;

import com.marklogic.appdeployer.command.AbstractManageResourceTest;
import com.marklogic.appdeployer.command.Command;
import com.marklogic.mgmt.resource.ResourceManager;
import com.marklogic.mgmt.resource.security.SecureCredentialsManager;

public class DeploySecureCredentialsTest extends AbstractManageResourceTest {

@Override
protected ResourceManager newResourceManager() {
return new SecureCredentialsManager(manageClient);
}

@Override
protected Command newCommand() {
return new DeploySecureCredentialsCommand();
}

@Override
protected String[] getResourceNames() {
return new String[]{"sec-creds1"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "sec-creds1",
"description": "Secure Credentials",
"username": "sample-app-jane",
"password": "password",
"signing": false,
"target": [
{
"uri-pattern": "http://.*:8080/test/",
"authentication": "basic"
},
{
"uri-pattern": "https://.*:443/test/",
"authentication": "basic"
}
],
"permission": [
{
"role-name": "rest-reader",
"capability": "read"
}
]
}