/** * @inheritDoc */ public String getUserID() { return session.getUserID(); }
/** * {@inheritDoc} */ public String getUserId() { return session.getUserID(); }
/** * Forwards the method call to the underlying session. */ public String getUserID() { return session.getUserID(); }
/** * Return the user id. */ public String getUserID() { return getSession().getUserID(); }
/** * Check whether a session belongs to an administrative user. */ private boolean isAdminUser(Session session) { if (session instanceof SessionImpl) { return ((SessionImpl) session).isAdmin(); } else { // fallback. use hardcoded default admin ID return "admin".equals(session.getUserID()); } } }
@Override public org.apache.jackrabbit.api.security.user.Authorizable getUser() { if (this.session != null && this.session instanceof JackrabbitSession) { try { UserManager userManager = ((JackrabbitSession) this.session).getUserManager(); return userManager.getAuthorizable(this.session.getUserID()); } catch (RepositoryException e) { log.error("Could not obtain a Jackrabbit UserManager", e); } } return null; }
private PentahoUserManagerImpl getUserManager( ITenant theTenant, Session session ) throws RepositoryException { Properties tenantProperties = new Properties(); tenantProperties.put( PentahoUserManagerImpl.PARAM_USERS_PATH, PentahoUserManagerImpl.USERS_PATH + theTenant.getRootFolderAbsolutePath() ); tenantProperties.put( PentahoUserManagerImpl.PARAM_GROUPS_PATH, PentahoUserManagerImpl.GROUPS_PATH + theTenant.getRootFolderAbsolutePath() ); return new PentahoUserManagerImpl( getSessionImpl( session ), session.getUserID(), tenantProperties ); }
public void testConnect() throws RepositoryException { System.out.println("UserID: " + superuser.getUserID()); for (NodeIterator it = superuser.getRootNode().getNodes(); it.hasNext(); ) { System.out.println(it.nextNode().getPath()); } } }
/** * Helper method to set page properties, create page calls this method. you could call this method anytime to create * working page properties. */ protected void setMetaData(MetaData md) throws RepositoryException, AccessDeniedException { md.setCreationDate(); md.setModificationDate(); md.setAuthorId(this.jcrSession.getUserID()); }
@Override public Object getAttribute(final @Nonnull ResolveContext<JcrProviderState> ctx, final @Nonnull String name) { if (isAttributeVisible(name)) { if (ResourceResolverFactory.USER.equals(name)) { return ctx.getProviderState().getSession().getUserID(); } return ctx.getProviderState().getSession().getAttribute(name); } return null; }
@Override public BinaryPage createBinaryPage(final String resourcePath, final Session session) throws RepositoryException{ final BinaryPage binaryPage = new BinaryPage(resourcePath); binaryPage.setCacheKey(new CacheKey(session.getUserID(), resourcePath)); initBinaryPageValues(session, binaryPage); return binaryPage; } }
public void testByIdAndNullType() throws Exception { try { userMgr.getAuthorizable(superuser.getUserID(), null); fail("Wrong Authorizable type is not detected."); } catch (AuthorizableTypeException e) { // success } }
public void testCreatedBy() throws RepositoryException { Node testNode = testSession.getNode(testRoot); Node folder = testNode.addNode("folder", JcrConstants.NT_FOLDER); testSession.save(); // EXERCISE: explain why the folder node must have a jcr:created property. assertTrue(folder.hasProperty(NodeTypeConstants.JCR_CREATEDBY)); assertEquals(testSession.getUserID(), folder.getProperty(NodeTypeConstants.JCR_CREATEDBY).getString()); removeTestUser(); testSession.refresh(false); // EXERCISE: do you expect jcr:createdBy property to be still present? explain why and fix the test if necessary. assertTrue(folder.hasProperty(NodeTypeConstants.JCR_CREATEDBY)); }
public void testLastModifiedBy() throws RepositoryException { Node testNode = testSession.getNode(testRoot); testNode.addMixin(NodeTypeConstants.MIX_LASTMODIFIED); testNode.setProperty(propertyName1, "any value"); testSession.save(); assertTrue(testNode.hasProperty(NodeTypeConstants.JCR_LASTMODIFIEDBY)); assertEquals(testSession.getUserID(), testNode.getProperty(NodeTypeConstants.JCR_LASTMODIFIEDBY).getString()); removeTestUser(); testSession.refresh(false); // EXERCISE: do you expect the property to be still present? explain why and fix the test if necessary. assertTrue(testNode.hasProperty(NodeTypeConstants.JCR_LASTMODIFIEDBY)); }
public void testAnonymousSimpleCredentialsLoginSuccess() throws RepositoryException { testSession = repository.login(new GuestCredentials()); String anonymousID = testSession.getUserID(); // EXERCISE: how to you need to modify the test-case that this would work? Session anonymousUserSession = repository.login(new SimpleCredentials(anonymousID, new char[0])); assertEquals(UserConstants.DEFAULT_ANONYMOUS_ID, testSession.getUserID()); }
public void testAnonymousSimpleCredentialsLogin() throws RepositoryException { testSession = repository.login(new GuestCredentials()); String anonymousID = testSession.getUserID(); testSession.logout(); try { testSession = repository.login(new SimpleCredentials(anonymousID, new char[0])); fail("Anonymous cannot login with simple credentials."); } catch (LoginException e) { // success // EXERCISE: explain why } }
protected User getTestUser(Session session) throws NotExecutableException, RepositoryException { Authorizable auth = getUserManager(session).getAuthorizable(session.getUserID()); if (auth != null && !auth.isGroup()) { return (User) auth; } // should never happen. An Session should always have a corresponding User. throw new NotExecutableException("Unable to retrieve a User."); }
protected User getTestUser(Session session) throws NotExecutableException, RepositoryException { Authorizable auth = getUserManager(session).getAuthorizable(session.getUserID()); if (auth != null && !auth.isGroup()) { return (User) auth; } // should never happen. An Session should always have a corresponding User. throw new NotExecutableException("Unable to retrieve a User."); }
public void testImpersonateOneSelf() throws RepositoryException { // EXERCISE: walk through this impersonation. does it work? if it does: why? Session testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID())); sessionList.add(testSession); Session impersonated = testSession.impersonate(new SimpleCredentials(testUser.getID(), new char[0])); sessionList.add(impersonated); assertEquals(testUser.getID(), impersonated.getUserID()); }