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

Commit 687a89c

Browse files
authored
Merge pull request #460 from marklogic-community/issue-459
#459 Implemented DeploySecureCredentialsCommand
2 parents 24705fc + 47a533e commit 687a89c

File tree

7 files changed

+100
-0
lines changed

7 files changed

+100
-0
lines changed

src/main/java/com/marklogic/appdeployer/ConfigDir.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,8 @@ public void setDefaultContentDatabaseFilename(String contentDatabaseFilename) {
243243
public File getProjectDir() {
244244
return projectDir;
245245
}
246+
247+
public File getSecureCredentialsDir() {
248+
return new File(getSecurityDir(), "secure-credentials");
249+
}
246250
}

src/main/java/com/marklogic/appdeployer/command/CommandMapBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ private void addCommandsThatDoNotWriteToDatabases(Map<String, List<Command>> map
145145
securityCommands.add(new DeployCertificateAuthoritiesCommand());
146146
securityCommands.add(new InsertCertificateHostsTemplateCommand());
147147
securityCommands.add(new DeployExternalSecurityCommand());
148+
securityCommands.add(new DeploySecureCredentialsCommand());
148149
securityCommands.add(new DeployPrivilegesCommand());
149150
securityCommands.add(new DeployPrivilegeRolesCommand());
150151
securityCommands.add(new DeployProtectedCollectionsCommand());

src/main/java/com/marklogic/appdeployer/command/SortOrderConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public abstract class SortOrderConstants {
1717
public static Integer INSERT_HOST_CERTIFICATES = 28;
1818

1919
public static Integer DEPLOY_EXTERNAL_SECURITY = 35;
20+
public static Integer DEPLOY_SECURE_CREDENTIALS = 36;
2021
public static Integer DEPLOY_PROTECTED_COLLECTIONS = 40;
2122
public static Integer DEPLOY_MIMETYPES = 45;
2223

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.marklogic.appdeployer.command.security;
2+
3+
import com.marklogic.appdeployer.command.AbstractResourceCommand;
4+
import com.marklogic.appdeployer.command.CommandContext;
5+
import com.marklogic.appdeployer.command.SortOrderConstants;
6+
import com.marklogic.mgmt.resource.ResourceManager;
7+
import com.marklogic.mgmt.resource.security.SecureCredentialsManager;
8+
9+
import java.io.File;
10+
11+
public class DeploySecureCredentialsCommand extends AbstractResourceCommand {
12+
13+
public DeploySecureCredentialsCommand() {
14+
setExecuteSortOrder(SortOrderConstants.DEPLOY_SECURE_CREDENTIALS);
15+
setUndoSortOrder(SortOrderConstants.DEPLOY_SECURE_CREDENTIALS);
16+
}
17+
18+
@Override
19+
protected File[] getResourceDirs(CommandContext context) {
20+
return findResourceDirs(context, configDir -> configDir.getSecureCredentialsDir());
21+
}
22+
23+
@Override
24+
protected ResourceManager getResourceManager(CommandContext context) {
25+
return new SecureCredentialsManager(context.getManageClient());
26+
}
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.marklogic.mgmt.resource.security;
2+
3+
import com.marklogic.mgmt.ManageClient;
4+
import com.marklogic.mgmt.resource.AbstractResourceManager;
5+
6+
public class SecureCredentialsManager extends AbstractResourceManager {
7+
public SecureCredentialsManager(ManageClient client) {
8+
super(client);
9+
}
10+
11+
@Override
12+
public String getResourcesPath() {
13+
return "/manage/v2/credentials/secure";
14+
}
15+
16+
@Override
17+
protected String getIdFieldName() {
18+
return "name";
19+
}
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.marklogic.appdeployer.command.security;
2+
3+
import com.marklogic.appdeployer.command.AbstractManageResourceTest;
4+
import com.marklogic.appdeployer.command.Command;
5+
import com.marklogic.mgmt.resource.ResourceManager;
6+
import com.marklogic.mgmt.resource.security.SecureCredentialsManager;
7+
8+
public class DeploySecureCredentialsTest extends AbstractManageResourceTest {
9+
10+
@Override
11+
protected ResourceManager newResourceManager() {
12+
return new SecureCredentialsManager(manageClient);
13+
}
14+
15+
@Override
16+
protected Command newCommand() {
17+
return new DeploySecureCredentialsCommand();
18+
}
19+
20+
@Override
21+
protected String[] getResourceNames() {
22+
return new String[]{"sec-creds1"};
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "sec-creds1",
3+
"description": "Secure Credentials",
4+
"username": "sample-app-jane",
5+
"password": "password",
6+
"signing": false,
7+
"target": [
8+
{
9+
"uri-pattern": "http://.*:8080/test/",
10+
"authentication": "basic"
11+
},
12+
{
13+
"uri-pattern": "https://.*:443/test/",
14+
"authentication": "basic"
15+
}
16+
],
17+
"permission": [
18+
{
19+
"role-name": "rest-reader",
20+
"capability": "read"
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)