Skip to content

Commit 5778070

Browse files
committed
Optionally allow to also remove IMS group admins which are no longer
configured Add toString, equals and hashCode methods to deserialized JSON objects Add InstallationOptions argument for installer methods Expose all installation options in Touch UI This closes #798
1 parent 2e45374 commit 5778070

File tree

42 files changed

+916
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+916
-131
lines changed

accesscontroltool-apps-package/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
1717
<artifactId>accesscontroltool</artifactId>
18-
<version>3.5.2-SNAPSHOT</version>
18+
<version>3.6.0-SNAPSHOT</version>
1919
</parent>
2020

2121
<!-- ====================================================================== -->

accesscontroltool-bundle/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
1313
<artifactId>accesscontroltool</artifactId>
14-
<version>3.5.2-SNAPSHOT</version>
14+
<version>3.6.0-SNAPSHOT</version>
1515
</parent>
1616

1717
<!-- ====================================================================== -->

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/AcInstallationService.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,39 @@ public interface AcInstallationService {
2121
/** Applies the full configuration as stored at the path configured at PID biz.netcentric.cq.tools.actool.impl.AcInstallationServiceImpl
2222
* to the repository.
2323
*
24-
* @return the installation log */
24+
* @return the installation log
25+
* @deprecated use {@link #apply(InstallationOptions)} instead
26+
*/
27+
@Deprecated
2528
public InstallationLog apply();
2629

2730
/** Applies the configuration as stored at the given configurationRootPath to the repository.
2831
*
2932
* @param configurationRootPath the root path for configuration files
30-
* @return the installation log */
33+
* @return the installation log
34+
* @deprecated use {@link #apply(InstallationOptions)} instead
35+
*/
36+
@Deprecated
3137
public InstallationLog apply(String configurationRootPath);
3238

3339
/** Applies parts of the configuration (based on given paths)
3440
*
3541
* @param restrictedToPaths only apply ACLs to root paths as given
36-
* @return the installation log */
42+
* @return the installation log
43+
* @deprecated use {@link #apply(InstallationOptions)} instead
44+
*/
45+
@Deprecated
3746
public InstallationLog apply(String[] restrictedToPaths);
3847

3948
/** Applies the configuration as stored at the given configurationRootPath to the repository, but only apply ACEs to given
4049
* restrictedToPaths.
4150
*
4251
* @param restrictedToPaths only apply ACLs to root paths as given
4352
* @param configurationRootPath the root path for configuration files
44-
* @return the installation log */
53+
* @return the installation log
54+
* @deprecated use {@link #apply(InstallationOptions)} instead
55+
*/
56+
@Deprecated
4557
public InstallationLog apply(String configurationRootPath, String[] restrictedToPaths);
4658

4759

@@ -51,10 +63,20 @@ public interface AcInstallationService {
5163
* @param restrictedToPaths only apply ACLs to root paths as given
5264
* @param configurationRootPath the root path for configuration files
5365
* @param skipIfConfigUnchanged will check if the config is unchanged compared to last execution with same parameters
54-
* @return the installation log */
66+
* @return the installation log
67+
* @deprecated use {@link #apply(InstallationOptions)} instead
68+
*/
69+
@Deprecated
5570
public InstallationLog apply(String configurationRootPath, String[] restrictedToPaths, boolean skipIfConfigUnchanged);
5671

57-
72+
/** Applies the configuration
73+
*
74+
* @param options the installation options which further specify the installation
75+
* @return the installation log
76+
* @since 3.6.0
77+
*/
78+
public InstallationLog apply(InstallationOptions options);
79+
5880
/** purges all acls of the node specified by path (no deletion of acls of subnodes)
5981
*
6082
* @param path the path from which to purge the ACL
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package biz.netcentric.cq.tools.actool.api;
2+
3+
/*-
4+
* #%L
5+
* Access Control Tool Bundle
6+
* %%
7+
* Copyright (C) 2015 - 2025 Cognizant Netcentric
8+
* %%
9+
* All rights reserved. This program and the accompanying materials
10+
* are made available under the terms of the Eclipse Public License v1.0
11+
* which accompanies this distribution, and is available at
12+
* http://www.eclipse.org/legal/epl-v10.html
13+
* #L%
14+
*/
15+
16+
import java.util.List;
17+
import java.util.Optional;
18+
19+
import org.osgi.annotation.versioning.ProviderType;
20+
21+
import biz.netcentric.cq.tools.actool.impl.AcInstallationServiceImpl;
22+
23+
/**
24+
* Options to be used when applying the configuration.
25+
* Create an instance using {@link InstallationOptionsBuilder}.
26+
* @since 3.6.0
27+
*/
28+
@ProviderType
29+
public interface InstallationOptions {
30+
31+
/**
32+
*
33+
* @return the root path of the configuration files. If not set the one configured in {@link AcInstallationServiceImpl} is used.
34+
*/
35+
public Optional<String> getConfigurationRootPath();
36+
37+
/**
38+
*
39+
* @return the list of root path entry below which ACLs should be modified. Note this does not restrict the installation of authorizables (users/groups) only the ACEs.
40+
*/
41+
public List<String> getRestrictedToPaths();
42+
43+
/**
44+
*
45+
* @return {@code true} if the installation should be skipped if the configuration is unchanged compared to last execution with same parameters
46+
*/
47+
public boolean shouldSkipIfConfigUnchanged();
48+
49+
/**
50+
*
51+
* @return {@code true} if the installation should also update existing external groups. By default only new ones are created but existing ones not touched.
52+
*/
53+
public boolean shouldUpdateExistingExternalGroups();
54+
55+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
package biz.netcentric.cq.tools.actool.api;
2+
3+
/*-
4+
* #%L
5+
* Access Control Tool Bundle
6+
* %%
7+
* Copyright (C) 2015 - 2025 Cognizant Netcentric
8+
* %%
9+
* All rights reserved. This program and the accompanying materials
10+
* are made available under the terms of the Eclipse Public License v1.0
11+
* which accompanies this distribution, and is available at
12+
* http://www.eclipse.org/legal/epl-v10.html
13+
* #L%
14+
*/
15+
16+
import java.util.Arrays;
17+
import java.util.Collection;
18+
import java.util.LinkedList;
19+
import java.util.List;
20+
import java.util.Objects;
21+
import java.util.Optional;
22+
23+
/** Builder for {@link InstallationOptions}.
24+
*
25+
* @since 3.6.0 */
26+
public final class InstallationOptionsBuilder {
27+
28+
private Optional<String> configurationRootPath;
29+
private List<String> restrictedToPaths;
30+
private boolean skipIfConfigUnchanged;
31+
private boolean updateExistingExternalGroups;
32+
33+
public InstallationOptionsBuilder() {
34+
this.configurationRootPath = Optional.empty();
35+
this.restrictedToPaths = new LinkedList<>();
36+
this.skipIfConfigUnchanged = false;
37+
this.updateExistingExternalGroups = false;
38+
}
39+
40+
public InstallationOptionsBuilder(InstallationOptions options) {
41+
this.configurationRootPath = options.getConfigurationRootPath();
42+
this.restrictedToPaths = new LinkedList<>();
43+
this.restrictedToPaths.addAll(options.getRestrictedToPaths());
44+
this.skipIfConfigUnchanged = options.shouldSkipIfConfigUnchanged();
45+
this.updateExistingExternalGroups = options.shouldUpdateExistingExternalGroups();
46+
}
47+
48+
public InstallationOptionsBuilder withConfigurationRootPath(String configurationRootPath) {
49+
this.configurationRootPath = Optional.of(configurationRootPath);
50+
return this;
51+
}
52+
53+
public InstallationOptionsBuilder withRestrictedToPaths(String... restrictedToPaths) {
54+
this.restrictedToPaths.addAll(Arrays.asList(restrictedToPaths));
55+
return this;
56+
}
57+
58+
public InstallationOptionsBuilder withRestrictedToPaths(Collection<String> restrictedToPaths) {
59+
this.restrictedToPaths.addAll(restrictedToPaths);
60+
return this;
61+
}
62+
63+
public InstallationOptionsBuilder skipIfConfigUnchanged() {
64+
this.skipIfConfigUnchanged = true;
65+
return this;
66+
}
67+
68+
public InstallationOptionsBuilder updateExistingExternalGroups() {
69+
this.updateExistingExternalGroups = true;
70+
return this;
71+
}
72+
73+
public InstallationOptions build() {
74+
return new InstallationOptionsImpl(this);
75+
}
76+
77+
private static final class InstallationOptionsImpl implements InstallationOptions {
78+
private final Optional<String> configurationRootPath;
79+
private final List<String> restrictedToPaths;
80+
private final boolean skipIfConfigUnchanged;
81+
private final boolean updateExistingExternalGroups;
82+
83+
public InstallationOptionsImpl(InstallationOptionsBuilder builder) {
84+
this.configurationRootPath = builder.configurationRootPath;
85+
this.restrictedToPaths = builder.restrictedToPaths;
86+
this.skipIfConfigUnchanged = builder.skipIfConfigUnchanged;
87+
this.updateExistingExternalGroups = builder.updateExistingExternalGroups;
88+
}
89+
90+
@Override
91+
public Optional<String> getConfigurationRootPath() {
92+
return configurationRootPath;
93+
}
94+
95+
@Override
96+
public List<String> getRestrictedToPaths() {
97+
return restrictedToPaths;
98+
}
99+
100+
@Override
101+
public boolean shouldSkipIfConfigUnchanged() {
102+
return skipIfConfigUnchanged;
103+
}
104+
105+
@Override
106+
public boolean shouldUpdateExistingExternalGroups() {
107+
return updateExistingExternalGroups;
108+
}
109+
110+
@Override
111+
public int hashCode() {
112+
return Objects.hash(configurationRootPath, restrictedToPaths, skipIfConfigUnchanged, updateExistingExternalGroups);
113+
}
114+
115+
@Override
116+
public boolean equals(Object obj) {
117+
if (this == obj)
118+
return true;
119+
if (obj == null)
120+
return false;
121+
if (getClass() != obj.getClass())
122+
return false;
123+
InstallationOptionsImpl other = (InstallationOptionsImpl) obj;
124+
return Objects.equals(configurationRootPath, other.configurationRootPath)
125+
&& Objects.equals(restrictedToPaths, other.restrictedToPaths) && skipIfConfigUnchanged == other.skipIfConfigUnchanged
126+
&& updateExistingExternalGroups == other.updateExistingExternalGroups;
127+
}
128+
129+
@Override
130+
public String toString() {
131+
return "InstallationOptionsImpl [configurationRootPath=" + configurationRootPath + ", restrictedToPaths=" + restrictedToPaths
132+
+ ", skipIfConfigUnchanged=" + skipIfConfigUnchanged + ", updateExistingExternalGroups=" + updateExistingExternalGroups
133+
+ "]";
134+
}
135+
}
136+
}

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@Version("3.0.0")
1+
@Version("3.1.0")
22
package biz.netcentric.cq.tools.actool.api;
33

44
/*-

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/authorizableinstaller/AuthorizableInstallerService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.sling.api.resource.LoginException;
2323

24+
import biz.netcentric.cq.tools.actool.api.InstallationOptions;
2425
import biz.netcentric.cq.tools.actool.configmodel.AcConfiguration;
2526
import biz.netcentric.cq.tools.actool.configmodel.AuthorizablesConfig;
2627
import biz.netcentric.cq.tools.actool.history.InstallationLogger;
@@ -30,6 +31,6 @@ public interface AuthorizableInstallerService {
3031
void installAuthorizables(
3132
AcConfiguration acConfiguration,
3233
AuthorizablesConfig authorizablesConfigBeans,
33-
final Session session, InstallationLogger installLog)
34+
final Session session, InstallationLogger installLog, InstallationOptions options)
3435
throws RepositoryException, AuthorizableCreatorException, LoginException, IOException, GeneralSecurityException;
3536
}

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/authorizableinstaller/impl/AuthorizableInstallerServiceImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import com.adobe.granite.keystore.KeyStoreNotInitialisedException;
6464
import com.adobe.granite.keystore.KeyStoreService;
6565

66+
import biz.netcentric.cq.tools.actool.api.InstallationOptions;
6667
import biz.netcentric.cq.tools.actool.authorizableinstaller.AuthorizableCreatorException;
6768
import biz.netcentric.cq.tools.actool.authorizableinstaller.AuthorizableInstallerService;
6869
import biz.netcentric.cq.tools.actool.configmodel.AcConfiguration;
@@ -117,7 +118,7 @@ public class AuthorizableInstallerServiceImpl implements
117118
public void installAuthorizables(
118119
AcConfiguration acConfiguration,
119120
AuthorizablesConfig authorizablesConfigBeans,
120-
final Session session, InstallationLogger installLog)
121+
final Session session, InstallationLogger installLog, InstallationOptions options)
121122
throws RepositoryException, AuthorizableCreatorException, LoginException, IOException, GeneralSecurityException {
122123

123124
AuthInstallerUserManager userManager = new AuthInstallerUserManagerPrefetchingImpl(AccessControlUtils.getUserManagerAutoSaveDisabled(session), session.getValueFactory(), installLog);
@@ -136,16 +137,16 @@ public void installAuthorizables(
136137
}
137138

138139
installLog.addMessage(LOG, "Created "+installLog.getCountAuthorizablesCreated() + " authorizables (moved "+installLog.getCountAuthorizablesMoved() + " authorizables)");
139-
syncWithExternalGroupManagement(groupsToSyncWithExternalUserMgmt, installLog);
140+
syncWithExternalGroupManagement(groupsToSyncWithExternalUserMgmt, installLog, options);
140141

141142
}
142143

143-
private void syncWithExternalGroupManagement(Collection<AuthorizableConfigBean> groupConfigBeans, InstallationLogger installLog) throws IOException {
144+
private void syncWithExternalGroupManagement(Collection<AuthorizableConfigBean> groupConfigBeans, InstallationLogger installLog, InstallationOptions options) throws IOException {
144145
if (groupConfigBeans.isEmpty()) {
145146
return;
146147
}
147148
for (ExternalGroupManagement externalGroupManagement : externalGroupManagementServices) {
148-
int numGroupsSynced = externalGroupManagement.updateGroups(groupConfigBeans);
149+
int numGroupsSynced = externalGroupManagement.updateGroups(groupConfigBeans, options);
149150
installLog.addMessage(LOG, "Synchronized " + numGroupsSynced + " groups with external user management " + externalGroupManagement.getLabel());
150151
}
151152
}

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/externalusermanagement/ExternalGroupManagement.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.io.IOException;
1717
import java.util.Collection;
1818

19+
import biz.netcentric.cq.tools.actool.api.InstallationOptions;
1920
import biz.netcentric.cq.tools.actool.configmodel.AuthorizableConfigBean;
2021

2122
/**
@@ -25,10 +26,11 @@ public interface ExternalGroupManagement {
2526
/**
2627
* Updates the groups in the external directory.
2728
* @param groupConfigs the groups to be updated
29+
* @param options the installation options
2830
* @return the effective number of groups updated (may be less than the number of groups in {@code groupConfigs}) if some are considered up to date
2931
* @throws IOException
3032
*/
31-
int updateGroups(Collection<AuthorizableConfigBean> groupConfigs) throws IOException;
33+
int updateGroups(Collection<AuthorizableConfigBean> groupConfigs, InstallationOptions options) throws IOException;
3234

3335
/**
3436
*

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcConfigChangeTracker.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
2727

28+
import biz.netcentric.cq.tools.actool.api.InstallationOptions;
2829
import biz.netcentric.cq.tools.actool.helper.runtime.RuntimeHelper;
2930
import biz.netcentric.cq.tools.actool.history.impl.HistoryUtils;
3031

@@ -35,10 +36,10 @@
3536
public class AcConfigChangeTracker {
3637
private static final Logger LOG = LoggerFactory.getLogger(AcConfigChangeTracker.class);
3738

38-
public boolean configIsUnchangedComparedToLastExecution(Map<String, String> configFiles, String[] restrictedToPaths, Session session) {
39+
public boolean configIsUnchangedComparedToLastExecution(Map<String, String> configFiles, Session session, InstallationOptions options) {
3940

4041

41-
String executionKey = createExecutionKey(configFiles, restrictedToPaths, session);
42+
String executionKey = createExecutionKey(configFiles, session, options);
4243

4344
try {
4445
String hashOfConfigFilesThisExecution = createHashOverConfigFiles(configFiles);
@@ -65,9 +66,9 @@ public boolean configIsUnchangedComparedToLastExecution(Map<String, String> conf
6566
return false;
6667
}
6768

68-
private String createExecutionKey(Map<String, String> configFiles, String[] restrictedToPaths, Session session) {
69+
private String createExecutionKey(Map<String, String> configFiles, Session session, InstallationOptions options) {
6970
boolean isCompositeNodeStore= RuntimeHelper.isCompositeNodeStore(session);
70-
String restrictedToPathsKey = restrictedToPaths==null || restrictedToPaths.length==0 ? "ALL_PATHS" : StringUtils.join(restrictedToPaths, "+").replace("$", "").replace("^", "");
71+
String restrictedToPathsKey = options.getRestrictedToPaths().isEmpty() ? "ALL_PATHS" : String.join("+", options.getRestrictedToPaths()).replace("$", "").replace("^", "");
7172
String effectiveRootPathOfConfigs = getEffectiveConfigRootPath(configFiles);
7273
String executionKey = "hash("+StringUtils.removeEnd(effectiveRootPathOfConfigs, "/").replace('/', '\\') + "," + restrictedToPathsKey.replace('/', '\\').replace(':', '_')+","+(isCompositeNodeStore?"compNodeStore":"stdRepo")+")";
7374
return executionKey;

0 commit comments

Comments
 (0)