本文整理了Java中javax.jcr.Session.impersonate()
方法的一些代码示例,展示了Session.impersonate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.impersonate()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:impersonate
[英]Returns a new session in accordance with the specified (new) Credentials. Allows the current user to "impersonate" another using incomplete or relaxed credentials requirements (perhaps including a user name but no password, for example), assuming that this Session
gives them that permission.
The new Session
is tied to a new Workspace
instance. In other words, Workspace
instances are not re-used. However, the Workspace
instance returned represents the same actual persistent workspace entity in the repository as is represented by the Workspace
object tied to this Session
.
[中]根据指定的(新)凭据返回新会话。允许当前用户使用不完整或宽松的凭据要求(例如,可能包括用户名但没有密码)来“模拟”另一个用户,前提是此Session
授予他们该权限。
新的Session
绑定到一个新的Workspace
实例。换句话说,Workspace
实例不会被重复使用。但是,返回的Workspace
实例表示存储库中的实际持久工作区实体,与绑定到此[$6$]的Workspace
对象表示的实体相同。
代码示例来源:origin: org.onehippo.cms7/hippo-repository-api
/**
* Create a session with the given credentials.
* Caller must log out the returned session after use.
*/
public Session createSession(Credentials credentials) throws LoginException, RepositoryException {
// since the backing systemSession can be shared by different RepositoryJobExecutionContext's and there can
// be multiple threads involved, we need to synchronize on systemSession during impersonation
synchronized (systemSession) {
return systemSession.impersonate(credentials);
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public void runTest() throws RepositoryException {
for (int i = 0; i < COUNT; i++) {
admin.impersonate(creds).logout();
}
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
/**
* Forwards the method call to the underlying session. The returned
* session is wrapped into a session decorator using the decorator factory.
*
* @return decorated session
*/
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException {
Session newSession = session.impersonate(credentials);
return factory.getSessionDecorator(repository, newSession);
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
@Override
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException {
Session newSession = session.impersonate(credentials);
return DecoratorFactoryImpl.getSessionDecorator(newSession, credentials);
}
代码示例来源:origin: net.adamcin.oakpal/oakpal-core
@Override
public Session impersonate(Credentials credentials) throws RepositoryException {
Session impersonateDelegate = delegate.impersonate(credentials);
return SessionFacade.findBestWrapper(impersonateDelegate, true);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException {
return getWrappedSession().impersonate(credentials);
}
代码示例来源:origin: ModeShape/modeshape
@Override
public Session impersonate( Credentials c ) throws LoginException, RepositoryException {
return session().impersonate(c);
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
public Session createImpersonatedSession() throws RepositoryException {
final Session session = node.getSession();
return session.impersonate(new SimpleCredentials(session.getUserID(), new char[]{}));
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@Override
default Session impersonate(final Credentials credentials) throws LoginException, RepositoryException {
return wrapSession(unwrapSession().impersonate(credentials));
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
public WorkflowManagerImpl(Session session) throws RepositoryException {
this.userSession = session;
SimpleCredentials workflowuser = new SimpleCredentials("workflowuser", new char[]{});
workflowuser.setAttribute(NO_SYSTEM_IMPERSONATION, Boolean.TRUE);
this.workflowSession = session.impersonate(workflowuser);
((HippoSession)workflowSession).disableVirtualLayers();
configurationId = session.getRootNode().getNode(CONFIGURATION_PATH + "/" + WORKFLOWS_PATH).getIdentifier();
workflowLogger = new WorkflowLogger(workflowSession);
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public RemoteSession impersonate(Credentials credentials)
throws RepositoryException, RemoteException {
try {
Session newSession = session.impersonate(credentials);
return getFactory().getRemoteSession(newSession);
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
@Override
public Session login() throws RepositoryException {
final SimpleCredentials credentials = new SimpleCredentials("system", new char[]{});
return DecoratorFactoryImpl.getSessionDecorator(repositoryImpl.getRootSession(workspaceName).impersonate(credentials), credentials);
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
protected ConfigurationServiceImpl initializeConfiguration(final Session rootSession) throws RepositoryException {
log.info("LocalHippoRepository initialize configuration");
final SimpleCredentials credentials = new SimpleCredentials("system", new char[]{});
final Session configurationServiceSession = DecoratorFactoryImpl.getSessionDecorator(rootSession.impersonate(credentials), credentials);
migrateToV12IfNeeded(configurationServiceSession, false);
return new ConfigurationServiceImpl().start(configurationServiceSession,() -> start(rootSession));
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
protected void start(final Session rootSession) throws RepositoryException {
jackrabbitRepository.enableVirtualLayer(true);
moduleManager = new ModuleManager(rootSession.impersonate(new SimpleCredentials("system", new char[]{})));
moduleManager.start();
nodeTypesChangeTracker = new NodeTypesChangeTracker(rootSession.impersonate(new SimpleCredentials("system", new char[]{})));
nodeTypesChangeTracker.start();
((HippoSecurityManager) jackrabbitRepository.getSecurityManager()).configure();
}
代码示例来源:origin: apache/jackrabbit
/**
* {@inheritDoc}
*/
public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws LoginException, RepositoryException {
Credentials duplicate = SessionInfoImpl.duplicateCredentials(credentials);
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
return new SessionInfoImpl(sInfo.getSession().impersonate(credentials), duplicate, getNameFactory(), getPathFactory());
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr
/**
* {@inheritDoc}
*/
public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws LoginException, RepositoryException {
Credentials duplicate = SessionInfoImpl.duplicateCredentials(credentials);
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
return new SessionInfoImpl(sInfo.getSession().impersonate(credentials), duplicate, getNameFactory(), getPathFactory());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testImpersonateDisabledUser() throws Exception {
user.disable("readonly user is disabled!");
superuser.save();
// -> impersonating this user must fail
try {
Session ss = superuser.impersonate(new SimpleCredentials(user.getID(), new char[0]));
ss.logout();
fail("A disabled user cannot be impersonated any more.");
} catch (LoginException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit-oak
public void testAdminCanImpersonateEveryone() throws RepositoryException {
// EXERCISE: walk through this impersonation. does it work? if it does: why?
Session impersonated = superuser.impersonate(new SimpleCredentials(anotherUser.getID(), new char[0]));
sessionList.add(impersonated);
assertEquals(anotherUser.getID(), impersonated.getUserID());
}
代码示例来源:origin: apache/jackrabbit-oak
public void testImpersonateTestUser() throws RepositoryException {
Principal principal = null; // EXERCISE: fill in the correct principal such that the test passes.
Impersonation impersonation = anotherUser.getImpersonation();
impersonation.grantImpersonation(principal);
superuser.save();
Session testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID()));
sessionList.add(testSession);
Session impersonated = testSession.impersonate(new SimpleCredentials(anotherUser.getID(), new char[0]));
sessionList.add(impersonated);
assertEquals(anotherUser.getID(), impersonated.getUserID());
}
代码示例来源:origin: apache/jackrabbit-oak
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());
}
内容来源于网络,如有侵权,请联系作者删除!