Author: fmeschbe
Date: Wed Jul 3 08:42:50 2013
New Revision: 1499263
URL: http://svn.apache.org/r1499263
Log:
Implement support for service based ResourceResolver and Session access
- Adapt to new property service.info location
- Reuse authenticationInfo map for getResourceResolver
- make sure to not leak unused properties like password and bundle
Modified:
sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
Modified:
sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java?rev=1499263&r1=1499262&r2=1499263&view=diff
==============================================================================
---
sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
(original)
+++
sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
Wed Jul 3 08:42:50 2013
@@ -73,48 +73,50 @@ public class ResourceResolverFactoryImpl
// ---------- Resource Resolver Factory
------------------------------------
- public ResourceResolver getServiceResourceResolver(String serviceInfo)
throws LoginException {
- final String userName =
this.serviceUserMapper.getUserForService(this.usingBundle, serviceInfo);
+ public ResourceResolver getServiceResourceResolver(Map<String, Object>
authenticationInfo) throws LoginException {
+
+ // clean authenticaiton from password and get service info
+ final String serviceInfo;
+ if (authenticationInfo != null) {
+ authenticationInfo.remove(PASSWORD);
+ final Object info = authenticationInfo.get(SERVICE_INFO);
+ serviceInfo = (info instanceof String) ? (String) info : null;
+ } else {
+ authenticationInfo = new HashMap<String, Object>();
+ serviceInfo = null;
+ }
- // TODO: What to do if userName is null ????
+ // Ensure a mapped user name ... TODO: may this be null ??
+ final String userName =
this.serviceUserMapper.getUserForService(this.usingBundle, serviceInfo);
if (userName == null) {
throw new LoginException("Cannot derive user name for service "
+ this.serviceUserMapper.getServiceName(this.usingBundle,
serviceInfo));
}
- HashMap<String, Object> props = new HashMap<String, Object>();
- props.put(ResourceResolverFactory.USER, userName);
- props.put(ResourceProviderFactory.SERVICE_BUNDLE, this.usingBundle);
- if (serviceInfo != null) {
- props.put(ResourceProviderFactory.SERVICE_INFO, serviceInfo);
- }
+ // ensure proper user name and service bundle
+ authenticationInfo.put(ResourceResolverFactory.USER, userName);
+ authenticationInfo.put(ResourceProviderFactory.SERVICE_BUNDLE,
this.usingBundle);
- return getResourceResolverInternal(props, false);
+ return getResourceResolverInternal(authenticationInfo, false);
}
- /**
- * @see
org.apache.sling.api.resource.ResourceResolverFactory#getAdministrativeResourceResolver(java.util.Map)
- */
public ResourceResolver getAdministrativeResourceResolver(final
Map<String, Object> authenticationInfo) throws LoginException {
// make sure there is no leaking of service bundle and info props
if (authenticationInfo != null) {
authenticationInfo.remove(ResourceProviderFactory.SERVICE_BUNDLE);
- authenticationInfo.remove(ResourceProviderFactory.SERVICE_INFO);
+ authenticationInfo.remove(SERVICE_INFO);
}
return getResourceResolverInternal(authenticationInfo, true);
}
- /**
- * @see
org.apache.sling.api.resource.ResourceResolverFactory#getResourceResolver(java.util.Map)
- */
public ResourceResolver getResourceResolver(final Map<String, Object>
authenticationInfo) throws LoginException {
// make sure there is no leaking of service bundle and info props
if (authenticationInfo != null) {
authenticationInfo.remove(ResourceProviderFactory.SERVICE_BUNDLE);
- authenticationInfo.remove(ResourceProviderFactory.SERVICE_INFO);
+ authenticationInfo.remove(SERVICE_INFO);
}
return getResourceResolverInternal(authenticationInfo, false);