Ok, I've been reading up on:
https://sling.apache.org/documentation/the-sling-engine/service-authentication.html

and looking at the config for:
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl

Things are getting a little clearer, but I still don't see how I can actually 
use it… I've been looking through the sling source code and I haven't found 
anything that uses the new system yet. Are there any examples?

I just want to get hold of a ResourceResolver using the new system, and this 
should be the repository's admin user. I'm only writing a simple datastore 
garbage collector service. In fact, all of my services will probably run as the 
admin user - at this time I have no plans for users/user management.

This will happen in one of my services. Even if I add my service to the 
ServiceUserMapperImpl configuration it looks like I still need to have the 
credentials for the admin user.

Rob

On Oct 19, 2013, at 11:14 PM, Robert A. Decker wrote:

> Ok, I'm not proud of this, but so far this is what I've come up with for 
> getting the admin password from the repository configuration so that I can 
> use the new resourceResolverFactory.getServiceResourceResolver(credentials) 
> way.
> 
> Configuration[] configs = 
> configAdmin.listConfigurations("(service.factoryPid=org.apache.sling.jcr.jackrabbit.server.SlingServerRepository)");
> 
>            for (Configuration aConfig : configs) {
>                Dictionary props = aConfig.getProperties();
>                LOGGER.debug(props != null ? 
> props.get("admin.password").toString() : "null");
>            }
> 
> I can put this in my service to get the admin user's password. 
> 
> But is there a more straightforward way? This pulls it out of the 
> configuration, but is there a way to pull it out of the repository/user 
> itself?
> 
> Should I instead be using the 
> org.apache.jackrabbit.api.security.user.UserManager to get the User, then 
> org.apache.jackrabbit.api.security.user.User getCredentials method? 
> 
> Rob
> 
> 
> On Oct 19, 2013, at 5:57 PM, Robert A. Decker wrote:
> 
>> Hi,
>> 
>> I'm trying out the new recommended way of getting access to your repository 
>> (no longer using loginAdministrative/getAdministrativeResourceResolver).
>> 
>> I see that you can get credentials from SlingServerRepository:
>> SlingServerRepository.getAdministrativeCredentials(String adminUser) to get 
>> my admin user's credential information.
>> 
>> But it doesn't look like it's exposed through a service.
>> 
>> If you go to:
>> http://server/system/console/status-Configurations
>> 
>> You can see your admin user's credentials.
>> 
>> Is there a recommended way to access a user's credentials? I don't want to 
>> put them in config files.
>> 
>> Rob
> 
> 

Reply via email to