@Override public boolean isStandardDescriptor(String key) { Repository repo = getRepository(); if (repo != null) { return repo.isStandardDescriptor(key); } logger.error("isStandardDescriptor: Repository not available"); return false; } }
/** * 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(); }
/** * Same as calling {@code login(credentials, null)}. * <p> * This method may be overwritten. * * @param credentials The {@code Credentials} to use to login. * @return the result of calling {@link #login(Credentials, String) * login(credentials, null)}. * @throws LoginException If login is not possible * @throws RepositoryException If another error occurrs during login * @see #login(Credentials, String) */ @Override public Session login(final Credentials credentials) throws LoginException, RepositoryException { return this.login(credentials, null); }
/** * 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; }
/** * 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); }
workspace = this.getDefaultWorkspace(); final Repository repository = this.getRepository(); if (this.getRepository() == null) { throw new RepositoryException("Sling Repository not ready");
public final Session loginService(final String subServiceName, final String workspace) throws LoginException, RepositoryException { Session s = createServiceSession(usingBundle, subServiceName, workspace); if (s != null) { return s;
Session admin = null; try { admin = this.createAdministrativeSession(workspace); return admin.impersonate(new SimpleCredentials(serviceUserName, new char[0])); } finally {
Session serviceSession = null; try { serviceSession = createServiceSession(usingBundle, subServiceName, workspaceName); if (serviceSession == null) { throw new LoginException("Cannot create service session for bundle " + usingBundle + " and sub service " + subServiceName);
@Override public String[] getDescriptorKeys() { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptorKeys(); } logger.error("getDescriptorKeys: Repository not available"); return new String[0]; }
/** * Same as calling {@code login(null, null)}. * <p> * This method may be overwritten. * * @return the result of calling {@link #login(Credentials, String) * login(null, null)}. * @throws LoginException If login is not possible * @throws RepositoryException If another error occurrs during login * @see #login(Credentials, String) */ @Override public Session login() throws LoginException, RepositoryException { return this.login(null, null); }
/** * 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(); }
@Override public Value[] getDescriptorValues(String key) { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptorValues(key); } logger.error("getDescriptorValues: Repository not available"); return null; }
/** * Same as calling {@code login(null, workspace)}. * <p> * This method may be overwritten. * * @param workspace The workspace to access or {@code null} to access the * {@link #getDefaultWorkspace() default workspace} * @return the result of calling {@link #login(Credentials, String) * login(null, workspace)}. * @throws LoginException If login is not possible * @throws RepositoryException If another error occurrs during login * @see #login(Credentials, String) */ @Override public Session login(final String workspace) throws LoginException, NoSuchWorkspaceException, RepositoryException { return this.login(null, workspace); }
@Override public String getDescriptor(String name) { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptor(name); } logger.error("getDescriptor: Repository not available"); return null; }
@Override public Value getDescriptorValue(String key) { Repository repo = getRepository(); if (repo != null) { return repo.getDescriptorValue(key); } logger.error("getDescriptorValue: Repository not available"); return null; }
@Override public boolean isSingleValueDescriptor(String key) { Repository repo = getRepository(); if (repo != null) { return repo.isSingleValueDescriptor(key); } logger.error("isSingleValueDescriptor: Repository not available"); return false; }