/** * Returns the actual repository to which all JCR Repository interface * methods implemented by this class are delegated. * * @return The delegated repository. */ protected final Repository getRepository() { return this.getSlingRepositoryManager().getRepository(); }
/** * Returns the default workspace to login to if any of the {@code login} and * {@code createSession} methods is called without an explicit workspace * name. * <p> * This method may return {@code null} in which case the actual default * workspace used depends on the underlying JCR Repository implementation. */ @Override public final String getDefaultWorkspace() { return this.getSlingRepositoryManager().getDefaultWorkspace(); }
/** * Login as an administrative user. This method is deprecated and its use * can be completely disabled by setting {@code disableLoginAdministrative} * to {@code true}. * <p> * This implementation cannot be overwritten but, unless disabled, forwards * to the {@link #createAdministrativeSession(String)} method. * * @param workspace The workspace to access or {@code null} to access the * {@link #getDefaultWorkspace() default workspace} * @return An administrative session * @throws RepositoryException If the login fails or has been disabled */ @Override public final Session loginAdministrative(final String workspace) throws RepositoryException { final boolean whitelisted = getSlingRepositoryManager().allowLoginAdministrativeForBundle(usingBundle); if(!whitelisted) { final String symbolicName = usingBundle.getSymbolicName(); logger.error("Bundle {} is NOT whitelisted to use SlingRepository.loginAdministrative", symbolicName); throw new LoginException("Bundle " + symbolicName +" is NOT whitelisted"); } else if (this.getSlingRepositoryManager().isDisableLoginAdministrative()) { logger.error("SlingRepository.loginAdministrative is disabled. Please use SlingRepository.loginService."); throw new LoginException("SlingRepository.loginAdministrative is disabled."); } logger.debug("SlingRepository.loginAdministrative is deprecated. Please use SlingRepository.loginService."); return createAdministrativeSession(workspace); }
/** * Creates a new service-session. This method is used by {@link #loginService(String, String)} * and {@link #impersonateFromService(String, Credentials, String)} to avoid * code duplication. * * @param usingBundle The bundle using a service session. * @param subServiceName The optional name of the subservice. * @param workspaceName The JCR workspace name or {@code null}. * @return A new service session or {@code null} if neither a user-name nor a * principal names mapping has been defined. * @throws RepositoryException If an error occurs while creating the service session. */ private Session createServiceSession(Bundle usingBundle, String subServiceName, String workspaceName) throws RepositoryException { final ServiceUserMapper serviceUserMapper = this.getSlingRepositoryManager().getServiceUserMapper(); if (serviceUserMapper != null) { final Iterable<String> principalNames = serviceUserMapper.getServicePrincipalNames(usingBundle, subServiceName); if (principalNames != null) { return createServiceSession(principalNames, workspaceName); } final String userName = serviceUserMapper.getServiceUserID(usingBundle, subServiceName); if (userName != null) { return createServiceSession(userName, workspaceName); } } return null; }