Package org.apache.jackrabbit.api

Examples of org.apache.jackrabbit.api.JackrabbitSession


        try {
            ResourceResolver resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);

            Session session = resourceResolver.adaptTo(Session.class);

            JackrabbitSession jackrabbitSession = (JackrabbitSession) session;

            UserManager userManager =  jackrabbitSession.getUserManager();


            if (userManager.getAuthorizable("testUser") == null) {
                userManager.createUser("testUser", "password");
            }
View Full Code Here


   * @throws RepositoryException Forwarded from the
     *             <code>getUserManager</code> method call.
   */
  public static UserManager getUserManager(Session session)
                    throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
    JackrabbitSession jackrabbitSession = getJackrabbitSession(session);
    if(jackrabbitSession != null) {
      return jackrabbitSession.getUserManager();
    } else {
      return safeInvokeRepoMethod(session, METHOD_GET_USER_MANAGER, UserManager.class);
    }
  }
View Full Code Here

   * @throws RepositoryException Forwarded from the
     *             <code>PrincipalManager</code> method call.
   */
  public static PrincipalManager getPrincipalManager(Session session)
                    throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
    JackrabbitSession jackrabbitSession = getJackrabbitSession(session);
    if(jackrabbitSession != null) {
      return jackrabbitSession.getPrincipalManager();
    } else {
      return safeInvokeRepoMethod(session, METHOD_GET_PRINCIPAL_MANAGER, PrincipalManager.class);
    }
  }
View Full Code Here

        if (type == Session.class) {
            return (AdapterType) session;
        } else if (type == Principal.class) {
            try {
                if (this.session instanceof JackrabbitSession && session.getUserID() != null) {
                    JackrabbitSession s =((JackrabbitSession) this.session);
                    final UserManager um = s.getUserManager();
                    if (um != null) {
                        final Authorizable auth = um.getAuthorizable(s.getUserID());
                        if (auth != null) {
                            return (AdapterType) auth.getPrincipal();
                        }
                    }
                }
View Full Code Here

  private <AdapterType> AdapterType getAdapter(Session session,
      Class<AdapterType> type) {
      if ( session instanceof JackrabbitSession) {
        String userID = session.getUserID();
        JackrabbitSession jrSession = (JackrabbitSession) session;
        try {
          Authorizable authorizable = jrSession.getUserManager()
              .getAuthorizable(userID);
          String userHome = authorizable.getPath();

          // tries to get tenant information from user home
          // i.e. /home/users/tenant1/a/admin
View Full Code Here

        return session;
    }

    protected UserManager getUserManager(final Session session) throws RepositoryException {
        if (session instanceof JackrabbitSession) {
            final JackrabbitSession jackrabbitSession = (JackrabbitSession) session;
            return jackrabbitSession.getUserManager();
        } else {
            logger.error("Cannot get UserManager from session: not a Jackrabbit session");
            return null;
        }
    }
View Full Code Here

   * @throws RepositoryException Forwarded from the
     *             <code>getUserManager</code> method call.
   */
  public static UserManager getUserManager(Session session)
                    throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
    JackrabbitSession jackrabbitSession = getJackrabbitSession(session);
    if(jackrabbitSession != null) {
      return jackrabbitSession.getUserManager();
    } else {
      return safeInvokeRepoMethod(session, METHOD_GET_USER_MANAGER, UserManager.class);
    }
  }
View Full Code Here

   * @throws RepositoryException Forwarded from the
     *             <code>PrincipalManager</code> method call.
   */
  public static PrincipalManager getPrincipalManager(Session session)
                    throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
    JackrabbitSession jackrabbitSession = getJackrabbitSession(session);
    if(jackrabbitSession != null) {
      return jackrabbitSession.getPrincipalManager();
    } else {
      return safeInvokeRepoMethod(session, METHOD_GET_PRINCIPAL_MANAGER, PrincipalManager.class);
    }
  }
View Full Code Here

        assertTrue("user admin should have admin permissions", AdminPermissionChecker.hasAdministrativePermissions(admin));
    }

    @After
    public void after() throws RepositoryException {
        JackrabbitSession jackrabbitSession = (JackrabbitSession) admin;
        Authorizable vip = jackrabbitSession.getUserManager().getAuthorizable(TEST_USER);
        if (vip != null) {
            vip.remove();
        }
        jackrabbitSession.save();
    }
View Full Code Here

        jackrabbitSession.save();
    }

    @Test
    public void testNotAdminUser() throws Exception {
        JackrabbitSession jackrabbitSession = (JackrabbitSession) admin;
        Authorizable vip = jackrabbitSession.getUserManager().getAuthorizable(TEST_USER);
        if (vip == null) {
            jackrabbitSession.getUserManager().createUser(TEST_USER, TEST_USER);
        }
        admin.save();
        Session session = repository.login(new SimpleCredentials(TEST_USER, TEST_USER.toCharArray()));
        try {
            assertFalse(
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.JackrabbitSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.