You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by as...@apache.org on 2014/10/09 21:27:46 UTC
svn commit: r1630567 - in /sling/trunk/bundles/jcr/resource: pom.xml
src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
Author: asanso
Date: Thu Oct 9 19:27:46 2014
New Revision: 1630567
URL: http://svn.apache.org/r1630567
Log:
SLING-3991 - Support Password Change Upon Expiry Via SimpleCredentials Attribute (applied slightly modified patch from Dominique Jaeggi)
Modified:
sling/trunk/bundles/jcr/resource/pom.xml
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
Modified: sling/trunk/bundles/jcr/resource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/pom.xml?rev=1630567&r1=1630566&r2=1630567&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/pom.xml (original)
+++ sling/trunk/bundles/jcr/resource/pom.xml Thu Oct 9 19:27:46 2014
@@ -143,7 +143,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
- <version>2.8.0</version>
+ <version>2.8.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java?rev=1630567&r1=1630566&r2=1630567&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java Thu Oct 9 19:27:46 2014
@@ -410,32 +410,38 @@ public class JcrResourceProviderFactory
* @return A credentials object or <code>null</code>
*/
private Credentials getCredentials(final Map<String, Object> authenticationInfo) {
- if (authenticationInfo == null) {
- return null;
- }
- final Object credentialsObject = authenticationInfo.get(JcrResourceConstants.AUTHENTICATION_INFO_CREDENTIALS);
- if (credentialsObject instanceof Credentials) {
- return (Credentials) credentialsObject;
- }
+ Credentials creds = null;
+ if (authenticationInfo != null) {
- // otherwise try to create SimpleCredentials if the userId is set
- final Object userId = authenticationInfo.get(ResourceResolverFactory.USER);
- if (userId instanceof String) {
- final Object password = authenticationInfo.get(ResourceResolverFactory.PASSWORD);
- final SimpleCredentials credentials = new SimpleCredentials(
- (String) userId, ((password instanceof char[])
- ? (char[]) password
- : new char[0]));
+ final Object credentialsObject = authenticationInfo.get(JcrResourceConstants.AUTHENTICATION_INFO_CREDENTIALS);
- // add attributes
- copyAttributes(credentials, authenticationInfo);
+ if (credentialsObject instanceof Credentials) {
+ creds = (Credentials) credentialsObject;
+ } else {
+ // otherwise try to create SimpleCredentials if the userId is set
+ final Object userId = authenticationInfo.get(ResourceResolverFactory.USER);
+ if (userId instanceof String) {
+ final Object password = authenticationInfo.get(ResourceResolverFactory.PASSWORD);
+ final SimpleCredentials credentials = new SimpleCredentials(
+ (String) userId, ((password instanceof char[])
+ ? (char[]) password
+ : new char[0]));
- return credentials;
+ // add attributes
+ copyAttributes(credentials, authenticationInfo);
+
+ creds = credentials;
+ }
+ }
}
- // no user id (or not a String)
- return null;
+ if (creds instanceof SimpleCredentials
+ && authenticationInfo.get(ResourceResolverFactory.NEW_PASSWORD) instanceof String) {
+ ((SimpleCredentials) creds).setAttribute(ResourceResolverFactory.NEW_PASSWORD, authenticationInfo.get(ResourceResolverFactory.NEW_PASSWORD));
+ }
+
+ return creds;
}
/**