Skip to content

Commit d1fae6c

Browse files
committed
Add functionality to export users in CSV format
This format is compatible with https://helpx.adobe.com/enterprise/using/bulk-upload-users.html#csv-format Fix Web Console deployment with sling-m-p This closes #703 This closes #443 This closes #707
1 parent 33e19ad commit d1fae6c

File tree

6 files changed

+358
-78
lines changed

6 files changed

+358
-78
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* (C) Copyright 2024 Cognizant Netcentric.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/legal/epl-v10.html
8+
*/
9+
package biz.netcentric.cq.tools.actool.helper;
10+
11+
import java.util.Objects;
12+
13+
import javax.jcr.RepositoryException;
14+
15+
/**
16+
* Wraps a {@link RepositoryException} with an unchecked exception.
17+
* This is useful for usage within lambdas.
18+
*
19+
*/
20+
public class UncheckedRepositoryException extends RuntimeException {
21+
22+
private static final long serialVersionUID = 2727436608772501551L;
23+
24+
/**
25+
* Constructs an instance of this class.
26+
*
27+
* @param cause
28+
* the {@code RepositoryException}
29+
*
30+
* @throws NullPointerException
31+
* if the cause is {@code null}
32+
*/
33+
public UncheckedRepositoryException(RepositoryException cause) {
34+
super(Objects.requireNonNull(cause));
35+
}
36+
37+
/**
38+
* Returns the cause of this exception.
39+
*
40+
* @return the {@code RepositoryException} which is the cause of this exception.
41+
*/
42+
@Override
43+
public synchronized RepositoryException getCause() {
44+
return (RepositoryException) super.getCause();
45+
}
46+
}

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/ui/AcToolTouchUiServlet.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,66 +37,24 @@ public class AcToolTouchUiServlet extends SlingAllMethodsServlet {
3737

3838
private static final Logger LOG = LoggerFactory.getLogger(AcToolTouchUiServlet.class);
3939

40-
@Reference(policyOption = ReferencePolicyOption.GREEDY)
41-
private WebConsoleConfigTracker webConsoleConfigTracker;
42-
4340
@Reference(policyOption = ReferencePolicyOption.GREEDY)
4441
private AcToolUiService acToolUiService;
4542

4643
@Override
4744
protected void doGet(SlingHttpServletRequest req, SlingHttpServletResponse resp) throws ServletException, IOException {
48-
4945
if (StringUtils.isBlank(req.getRequestPathInfo().getSuffix())) {
5046
String targetUrl = req.getResourceResolver().resolve(req.getPathInfo()).getPath() + ".html/" + AcToolUiService.PAGE_NAME;
5147
resp.getWriter().println("<script type=\"text/javascript\">location.href='" + targetUrl + "'</script>");
5248
return;
5349
}
54-
5550
acToolUiService.doGet(req, resp, req.getRequestPathInfo().getResourcePath(), true);
56-
5751
}
5852

5953
@Override
6054
protected void doPost(SlingHttpServletRequest req, SlingHttpServletResponse resp) throws ServletException, IOException {
61-
62-
if (!mayApplyConfig(req.getResourceResolver().adaptTo(User.class))) {
63-
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "You do not have sufficent permissions to apply the configuration");
64-
return;
65-
}
66-
6755
acToolUiService.doPost(req, resp);
6856
LOG.debug("Applied AC tool config via Touch UI by user {}", req.getUserPrincipal());
6957
}
7058

71-
private boolean mayApplyConfig(User requestUser) {
72-
73-
try {
74-
75-
if (requestUser != null) {
76-
if (StringUtils.equals(requestUser.getID(), "admin")) {
77-
LOG.debug("Admin user is allowed to apply AC Tool");
78-
return true;
79-
}
80-
81-
if (ArrayUtils.contains(webConsoleConfigTracker.getAllowedUsers(), requestUser.getID())) {
82-
LOG.debug("User {} is allowed to apply AC Tool (allowed users: {})", requestUser.getID(), ArrayUtils.toString(webConsoleConfigTracker.getAllowedUsers()));
83-
return true;
84-
}
85-
86-
Iterator<Group> memberOfIt = requestUser.memberOf();
87-
88-
while (memberOfIt.hasNext()) {
89-
Group memberOfGroup = memberOfIt.next();
90-
if (ArrayUtils.contains(webConsoleConfigTracker.getAllowedGroups(), memberOfGroup.getID())) {
91-
LOG.debug("Group {} is allowed to apply AC Tool (allowed groups: {})", memberOfGroup.getID(), ArrayUtils.toString(webConsoleConfigTracker.getAllowedGroups()));
92-
return true;
93-
}
94-
}
95-
}
96-
return false;
97-
} catch (Exception e) {
98-
throw new IllegalStateException("Could not check if user may apply AC Tool configuration: " + e, e);
99-
}
100-
}
10159

10260
}

0 commit comments

Comments
 (0)