javax.jcr.LoginException Java Examples

The following examples show how to use javax.jcr.LoginException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JackrabbitRepositoryWrapper.java    From sling-whiteboard with Apache License 2.0 5 votes vote down vote up
@Override
public Session login(Credentials credentials, String workspaceName, Map<String, Object> attributes) throws LoginException, NoSuchWorkspaceException, RepositoryException {
    Session jcrSession = jcr.login(credentials, workspaceName, attributes);

    if (attributes == null) {
        attributes = new HashMap<>();
    }
    attributes.put(RepositoryWrapper.class.getPackage().getName() + ".PARENT_SESSION", jcrSession);

    return jcrSession instanceof JackrabbitSession ?
            new JackrabbitSessionWrapper(this, (JackrabbitSession) jcrSession) :
            new SessionWrapper<>(this, jcrSession);
}
 
Example #2
Source File: CheckPassword.java    From APM with Apache License 2.0 5 votes vote down vote up
private boolean checkLogin(Repository repository) throws RepositoryException {
  boolean loginSuccessful = true;
  Credentials credentials = new SimpleCredentials(userId, userPassword.toCharArray());
  try {
    repository.login(credentials).logout();
  } catch (LoginException e) {
    loginSuccessful = false;
  }
  return loginSuccessful;
}
 
Example #3
Source File: AggregateManagerImpl.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new artifact manager that is rooted at the given path using
 * the provided repository, credentials and workspace to create the
 * session.
 *
 * @param config fs config
 * @param wspFilter the workspace filter
 * @param rep the jcr repository
 * @param credentials the credentials
 * @param mountpoint the address of the mountpoint
 * @return an artifact manager
 * @throws RepositoryException if an error occurs.
 */
public static AggregateManager mount(VaultFsConfig config,
                                     WorkspaceFilter wspFilter,
                                     Repository rep,
                                     Credentials credentials,
                                     RepositoryAddress mountpoint)
throws RepositoryException {
    if (config == null) {
        config = getDefaultConfig();
    }
    if (wspFilter == null) {
        wspFilter = getDefaultWorkspaceFilter();
    }
    Node rootNode;
    String wspName = mountpoint.getWorkspace();
    try {
        rootNode = rep.login(credentials, wspName).getNode(mountpoint.getPath());
    } catch (LoginException e) {
        if (wspName == null) {
            // try again with default workspace
            // todo: make configurable
            rootNode = rep.login(credentials, "crx.default").getNode(mountpoint.getPath());
        } else {
            throw e;
        }
    }
    return new AggregateManagerImpl(config, wspFilter, mountpoint, rootNode, true);
}
 
Example #4
Source File: RepositoryWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public Session login(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
    return objectWrapper.wrap(this, jcr.login(credentials, workspaceName));
}
 
Example #5
Source File: RepositoryWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public Session login(Credentials credentials) throws LoginException, RepositoryException {
    return login(credentials, null);
}
 
Example #6
Source File: RepositoryWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public Session login(String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
    return login(null, workspaceName);
}
 
Example #7
Source File: RepositoryWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public Session login() throws LoginException, RepositoryException {
    return login(null, null);
}
 
Example #8
Source File: SessionWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException {
    return wrappedSession.impersonate(credentials);
}
 
Example #9
Source File: SessionImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException {
    return this;
}
 
Example #10
Source File: RepositoryImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Session login(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
    return session;
}
 
Example #11
Source File: RepositoryImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Session login(Credentials credentials) throws LoginException, RepositoryException {
    return session;
}
 
Example #12
Source File: RepositoryImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Session login(String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
    return session;
}
 
Example #13
Source File: RepositoryImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Session login() throws LoginException, RepositoryException {
    return session;
}
 
Example #14
Source File: RepositoryImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Session loginService(String s, String s1) throws LoginException, RepositoryException {
    return session;
}
 
Example #15
Source File: SessionFactoryUtils.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Jcr exception translator - it converts specific JSR-170 checked exceptions into unchecked Spring DA
 * exception.
 * @author Guillaume Bort <[email protected]>
 * @author Costin Leau
 * @author Sergio Bossa
 * @author Salvatore Incandela
 * @param ex
 * @return
 */
public static DataAccessException translateException(RepositoryException ex) {
    if (ex instanceof AccessDeniedException) {
        return new DataRetrievalFailureException("Access denied to this data", ex);
    }
    if (ex instanceof ConstraintViolationException) {
        return new DataIntegrityViolationException("Constraint has been violated", ex);
    }
    if (ex instanceof InvalidItemStateException) {
        return new ConcurrencyFailureException("Invalid item state", ex);
    }
    if (ex instanceof InvalidQueryException) {
        return new DataRetrievalFailureException("Invalid query", ex);
    }
    if (ex instanceof InvalidSerializedDataException) {
        return new DataRetrievalFailureException("Invalid serialized data", ex);
    }
    if (ex instanceof ItemExistsException) {
        return new DataIntegrityViolationException("An item already exists", ex);
    }
    if (ex instanceof ItemNotFoundException) {
        return new DataRetrievalFailureException("Item not found", ex);
    }
    if (ex instanceof LoginException) {
        return new DataAccessResourceFailureException("Bad login", ex);
    }
    if (ex instanceof LockException) {
        return new ConcurrencyFailureException("Item is locked", ex);
    }
    if (ex instanceof MergeException) {
        return new DataIntegrityViolationException("Merge failed", ex);
    }
    if (ex instanceof NamespaceException) {
        return new InvalidDataAccessApiUsageException("Namespace not registred", ex);
    }
    if (ex instanceof NoSuchNodeTypeException) {
        return new InvalidDataAccessApiUsageException("No such node type", ex);
    }
    if (ex instanceof NoSuchWorkspaceException) {
        return new DataAccessResourceFailureException("Workspace not found", ex);
    }
    if (ex instanceof PathNotFoundException) {
        return new DataRetrievalFailureException("Path not found", ex);
    }
    if (ex instanceof ReferentialIntegrityException) {
        return new DataIntegrityViolationException("Referential integrity violated", ex);
    }
    if (ex instanceof UnsupportedRepositoryOperationException) {
        return new InvalidDataAccessApiUsageException("Unsupported operation", ex);
    }
    if (ex instanceof ValueFormatException) {
        return new InvalidDataAccessApiUsageException("Incorrect value format", ex);
    }
    if (ex instanceof VersionException) {
        return new DataIntegrityViolationException("Invalid version graph operation", ex);
    }
    // fallback
    return new JcrSystemException(ex);
}