本文整理了Java中javax.jcr.Session.getUserID()
方法的一些代码示例,展示了Session.getUserID()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getUserID()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:getUserID
[英]Gets the user ID associated with this Session
. How the user ID is set is up to the implementation, it may be a string passed in as part of the credentials or it may be a string acquired in some other way. This method is free to return an "anonymous user ID" or null
.
[中]获取与此Session
关联的用户ID。用户ID的设置方式取决于实现,它可能是作为凭据的一部分传入的字符串,也可能是以其他方式获取的字符串。此方法可以自由返回“匿名用户ID”或null
。
代码示例来源:origin: apache/jackrabbit
/**
* @inheritDoc
*/
public String getUserID() {
return session.getUserID();
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
/**
* {@inheritDoc}
*/
public String getUserId() {
return session.getUserID();
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
/**
* Forwards the method call to the underlying session.
*/
public String getUserID() {
return session.getUserID();
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jca
/**
* Return the user id.
*/
public String getUserID() {
return getSession().getUserID();
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
/**
* 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());
}
}
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@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;
}
代码示例来源:origin: pentaho/pentaho-platform
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 );
}
代码示例来源:origin: apache/jackrabbit
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());
}
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* 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());
}
代码示例来源:origin: org.apache.sling/org.apache.sling.jcr.resource
@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;
}
代码示例来源:origin: org.onehippo.cms7.hst/hst-client
@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;
}
}
代码示例来源:origin: apache/jackrabbit-oak
public void testByIdAndNullType() throws Exception {
try {
userMgr.getAuthorizable(superuser.getUserID(), null);
fail("Wrong Authorizable type is not detected.");
} catch (AuthorizableTypeException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Before
@Override
protected void setUp() throws Exception {
super.setUp();
group.addMember(userMgr.getAuthorizable(superuser.getUserID()));
group.addMember(user);
members.add(superuser.getUserID());
members.add(user.getID());
superuser.save();
}
代码示例来源:origin: apache/jackrabbit-oak
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));
}
代码示例来源:origin: apache/jackrabbit-oak
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));
}
代码示例来源:origin: apache/jackrabbit-oak
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());
}
代码示例来源:origin: apache/jackrabbit-oak
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
}
}
代码示例来源:origin: apache/jackrabbit
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.");
}
代码示例来源:origin: apache/jackrabbit-oak
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.");
}
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!