Skip to content

Commit 437e91a

Browse files
Merge pull request #927 from adobe/develop
v2.5.6 release
2 parents 2bfdf62 + d9b4c3a commit 437e91a

File tree

37 files changed

+120
-110
lines changed

37 files changed

+120
-110
lines changed

all/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
<plugin>
185185
<groupId>com.adobe.aem</groupId>
186186
<artifactId>aemanalyser-maven-plugin</artifactId>
187-
<version>1.4.20</version> <!-- Make sure to use the latest release -->
187+
<version>1.5.8</version> <!-- Make sure to use the latest release -->
188188
<executions>
189189
<execution>
190190
<id>aem-analyser</id>

core/src/main/java/com/adobe/aem/commons/assetshare/components/actions/share/ShareService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface ShareService {
4343
*
4444
* @param request the request that provides context of which Asset Share instance the request is coming to.
4545
* @param response the response
46-
* @param shareParameters a &lt;String, Object&gt; map or parameters; This is initially constructed from the request.getParameterMap() but can be augmented in the ShareService implementationa s needed.
46+
* @param shareParameters a &lt;String, Object&gt; map or parameters; This is initially constructed from the request.getParameterMap() but can be augmented in the ShareService implementation as needed.
4747
* @throws ShareException is thrown if an error occurs with sharing (required share params are missing) or with the sharing initiation itself.
4848
*/
4949
void share(SlingHttpServletRequest request, SlingHttpServletResponse response, ValueMap shareParameters) throws ShareException;

core/src/main/java/com/adobe/aem/commons/assetshare/components/actions/share/impl/EmailShareServiceImpl.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.apache.sling.api.resource.ResourceResolver;
5353
import org.apache.sling.api.resource.ValueMap;
5454
import org.apache.sling.api.scripting.SlingBindings;
55+
import org.apache.sling.api.wrappers.ValueMapDecorator;
5556
import org.apache.sling.models.factory.ModelFactory;
5657
import org.apache.sling.scripting.core.ScriptHelper;
5758
import org.apache.sling.xss.XSSAPI;
@@ -66,6 +67,7 @@
6667
import org.slf4j.LoggerFactory;
6768

6869
import javax.jcr.RepositoryException;
70+
import javax.jcr.Value;
6971
import java.util.ArrayList;
7072
import java.util.Arrays;
7173
import java.util.HashMap;
@@ -116,6 +118,8 @@ public boolean accepts(final SlingHttpServletRequest request) {
116118

117119
@Override
118120
public final void share(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final ValueMap shareParameters) throws ShareException {
121+
final ValueMap unprotectedShareParameters = new ValueMapDecorator(new HashMap<>());
122+
unprotectedShareParameters.putAll(shareParameters);
119123

120124
/** Work around for regression issue introduced in AEM 6.4 **/
121125
SlingBindings bindings = new SlingBindings();
@@ -127,10 +131,11 @@ public final void share(final SlingHttpServletRequest request, final SlingHttpSe
127131
final EmailShare emailShare = request.adaptTo(EmailShare.class);
128132

129133
shareParameters.putAll(xssProtectUserData(emailShare.getUserData()));
130-
//shareParameters.putAll(emailShare.getUserData());
134+
unprotectedShareParameters.putAll(emailShare.getUserData());
131135

132136
// Configured data supersedes user data
133137
shareParameters.putAll(emailShare.getConfiguredData());
138+
unprotectedShareParameters.putAll(emailShare.getConfiguredData());
134139

135140
// Except for signature which we may or may not want to use from configured data, depending on flags in configured data
136141
shareParameters.put(SIGNATURE, getSignature(emailShare, userProperties));
@@ -141,12 +146,13 @@ public final void share(final SlingHttpServletRequest request, final SlingHttpSe
141146
shareParameters.put(EmailService.REPLY_TO, replyToAddress);
142147
}
143148

144-
share(request.adaptTo(Config.class), shareParameters, StringUtils.defaultIfBlank(emailShare.getEmailTemplatePath(), cfg.emailTemplate()));
149+
share(request.adaptTo(Config.class), unprotectedShareParameters, shareParameters, StringUtils.defaultIfBlank(emailShare.getEmailTemplatePath(), cfg.emailTemplate()));
145150
}
146151

147-
private final void share(final Config config, final ValueMap shareParameters, final String emailTemplatePath) throws ShareException {
148-
final String[] emailAddresses = StringUtils.split(shareParameters.get(EMAIL_ADDRESSES, ""), ",");
149-
final String[] assetPaths = Arrays.stream(shareParameters.get(ASSET_PATHS, ArrayUtils.EMPTY_STRING_ARRAY))
152+
private final void share(final Config config, final ValueMap unprotectedShareParameters, final ValueMap shareParameters, final String emailTemplatePath) throws ShareException {
153+
final String[] emailAddresses = StringUtils.split(unprotectedShareParameters.get(EMAIL_ADDRESSES, ""), ",");
154+
155+
final String[] assetPaths = Arrays.stream(unprotectedShareParameters.get(ASSET_PATHS, ArrayUtils.EMPTY_STRING_ARRAY))
150156
.filter(StringUtils::isNotBlank)
151157
.map(path -> config.getResourceResolver().getResource(path))
152158
.filter(Objects::nonNull)
@@ -155,6 +161,10 @@ private final void share(final Config config, final ValueMap shareParameters, fi
155161
.map(Asset::getPath)
156162
.toArray(String[]::new);
157163

164+
if (log.isDebugEnabled()) {
165+
log.debug("Sharing [ {} ] to [ {} ]", StringUtils.join(unprotectedShareParameters.get(ASSET_PATHS, ArrayUtils.EMPTY_STRING_ARRAY), ", "), StringUtils.join(emailAddresses, ", "));
166+
}
167+
158168
// Check to ensure the minimum set of e-mail parameters are provided; Throw exception if not.
159169
if (emailAddresses == null || emailAddresses.length == 0) {
160170
throw new ShareException("At least one e-mail address is required to share");
@@ -163,7 +173,7 @@ private final void share(final Config config, final ValueMap shareParameters, fi
163173
}
164174

165175
// Convert provided params to <String, String>; anything that needs to be accessed in its native type should be accessed and manipulated via shareParameters.get(..)
166-
final Map<String, String> emailParameters = new HashMap<String, String>();
176+
final Map<String, String> emailParameters = new HashMap<>();
167177
for (final String key : shareParameters.keySet()) {
168178
emailParameters.put(key, shareParameters.get(key, String.class));
169179
}
@@ -288,7 +298,6 @@ private boolean isValidUser(SlingHttpServletRequest request) {
288298
private Map<String, Object> xssProtectUserData(Map<String, Object> dirtyUserData) {
289299
Map<String, Object> cleanUserData = new HashMap<String, Object>();
290300
for (final Map.Entry<String, Object> entry : dirtyUserData.entrySet()) {
291-
292301
if (entry.getValue() instanceof String[]) {
293302
cleanUserData.put(entry.getKey(), xssCleanData((String[]) entry.getValue()));
294303
} else if (entry.getValue() instanceof String) {

core/src/main/java/com/adobe/aem/commons/assetshare/components/actions/share/impl/ShareServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private final void share(SlingHttpServletRequest request, SlingHttpServletRespon
8282
try {
8383
shareService.share(request, response,
8484
// Make map write-able
85-
new ValueMapDecorator(new HashMap<String, Object>(request.getParameterMap())));
85+
new ValueMapDecorator(new HashMap<>(request.getParameterMap())));
8686
counter.incrementAndGet();
8787
} catch (ShareException e) {
8888
if (log.isErrorEnabled()) {
@@ -96,7 +96,7 @@ private final void share(SlingHttpServletRequest request, SlingHttpServletRespon
9696
if (counter.get() == 0) {
9797
defaultShareService.share(request, response,
9898
// Make map write-able
99-
new ValueMapDecorator(new HashMap<String, Object>(request.getParameterMap())));
99+
new ValueMapDecorator(new HashMap<>(request.getParameterMap())));
100100
}
101101
} catch (ShareException ex) {
102102
log.error("Unable to share assets from Asset Share Commons", ex);

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<!-- the minimum AEM 6.5 version being supported -->
7373
<aem.classic.api.version>6.5.7.0003</aem.classic.api.version><!-- actually one of https://repo1.maven.org/maven2/io/wcm/maven/io.wcm.maven.aem-dependencies/ -->
7474
<!-- the minimum AEMaaCS version being supported -->
75-
<aem.sdk.api.version>2022.9.8722.20220912T101352Z-220800</aem.sdk.api.version><!-- actually one of https://repo1.maven.org/maven2/com/adobe/aem/aem-sdk-api/ -->
75+
<aem.sdk.api.version>2023.3.11382.20230315T073850Z-230200</aem.sdk.api.version><!-- actually one of https://repo1.maven.org/maven2/com/adobe/aem/aem-sdk-api/ -->
7676
<core.wcm.components.version>2.17.14</core.wcm.components.version>
7777
<frontend-maven-plugin.version>1.9.0</frontend-maven-plugin.version>
7878
<node.version>v13.7.0</node.version>
@@ -107,7 +107,7 @@
107107
<plugin>
108108
<groupId>org.apache.maven.plugins</groupId>
109109
<artifactId>maven-release-plugin</artifactId>
110-
<version>3.0.0-M6</version>
110+
<version>3.0.0</version>
111111
<configuration>
112112
<tagNameFormat>asset-share-commons-@{project.version}</tagNameFormat>
113113
<scmCommentPrefix>[maven-scm] :</scmCommentPrefix>
@@ -121,7 +121,7 @@
121121
<dependency>
122122
<groupId>org.apache.maven.release</groupId>
123123
<artifactId>maven-release-oddeven-policy</artifactId>
124-
<version>3.0.0-M7</version>
124+
<version>3.0.0</version>
125125
</dependency>
126126
</dependencies>
127127
</plugin>
@@ -254,7 +254,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
254254
<plugin>
255255
<groupId>org.apache.maven.plugins</groupId>
256256
<artifactId>maven-resources-plugin</artifactId>
257-
<version>3.2.0</version>
257+
<version>3.3.1</version>
258258
</plugin>
259259
<!-- Maven Compiler Plugin -->
260260
<plugin>
@@ -462,7 +462,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
462462
<!-- Maven Javadoc Plugin -->
463463
<plugin>
464464
<artifactId>maven-javadoc-plugin</artifactId>
465-
<version>3.4.1</version>
465+
<version>3.5.0</version>
466466
<configuration>
467467
<encoding>${project.build.sourceEncoding}</encoding>
468468
<excludePackageNames>
@@ -546,7 +546,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
546546
<plugin>
547547
<groupId>org.owasp</groupId>
548548
<artifactId>dependency-check-maven</artifactId>
549-
<version>7.1.1</version>
549+
<version>8.2.1</version>
550550
<configuration>
551551
<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
552552
</configuration>

ui.apps/src/main/content/jcr_root/apps/asset-share-commons/components/details/action-buttons/action-buttons.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
~ limitations under the License.
1717
*/-->
1818

19-
<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
20-
data-sly-test.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
21-
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
19+
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
20+
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
2221
data-sly-use.actionButtons="com.adobe.aem.commons.assetshare.components.details.ActionButtons"
23-
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
22+
data-sly-set.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
23+
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
2424
data-sly-test.ready="${actionButtons.ready}">
2525

2626
<div class="ui basic segment">

ui.apps/src/main/content/jcr_root/apps/asset-share-commons/components/details/editor-links/editor-links.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
~ limitations under the License.
1717
*/-->
1818

19-
<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
20-
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
19+
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
20+
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
21+
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
2122
data-sly-use.editorLinks="com.adobe.aem.commons.assetshare.components.details.EditorLinks"
22-
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
23-
data-sly-test.ready="${editorLinks.ready}">
23+
data-sly-test.ready="${editorLinks.ready}"
24+
>
2425

2526
<h4 class="ui header"
2627
data-sly-test="${!properties['hideLabel']}">${properties['label'] @ i18n}</h4>

ui.apps/src/main/content/jcr_root/apps/asset-share-commons/components/details/image/image.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
~ limitations under the License.
1717
*/-->
1818

19-
<sly data-sly-use.image="com.adobe.aem.commons.assetshare.components.details.Image"
20-
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
21-
data-sly-test.ready="${image.ready}">
19+
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
20+
data-sly-use.image="com.adobe.aem.commons.assetshare.components.details.Image"
21+
data-sly-test.ready="${image.ready}">
2222

2323
<div class="cmp-wrapper image background">
2424
<!--/* Img element with a max height */-->

ui.apps/src/main/content/jcr_root/apps/asset-share-commons/components/details/metadata/metadata.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
~ limitations under the License.
1717
*/-->
1818

19-
<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
20-
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
21-
data-sly-use.field="com.adobe.aem.commons.assetshare.components.details.Metadata"
22-
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
19+
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
2320
data-sly-use.fieldTypesTemplate="templates/field-types.html"
21+
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
22+
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
23+
data-sly-use.field="com.adobe.aem.commons.assetshare.components.details.Metadata"
2424
data-sly-test.ready="${field.ready}">
2525

2626
<div class="ui basic segment">

ui.apps/src/main/content/jcr_root/apps/asset-share-commons/components/details/renditions/renditions.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
~ limitations under the License.
1717
*/-->
1818

19-
<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
20-
data-sly-test.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
21-
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
19+
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
20+
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
21+
data-sly-set.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
22+
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
2223
data-sly-use.renditions="com.adobe.aem.commons.assetshare.components.details.Renditions"
23-
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
2424
data-sly-test.ready="${renditions.ready}">
2525

2626
<div class="ui basic segment">

0 commit comments

Comments
 (0)