- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.xpn.xwiki.user.api.XWikiUser.getUser()
方法的一些代码示例,展示了XWikiUser.getUser()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWikiUser.getUser()
方法的具体详情如下:
包路径:com.xpn.xwiki.user.api.XWikiUser
类名称:XWikiUser
方法名:getUser
暂无
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
public String getUser()
{
if (this.user != null) {
return this.user.getUser();
} else {
return XWikiRightService.GUEST_USER_FULLNAME;
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* Check if the user belongs to a group or not.
*
* @param groupName The group to check.
* @param context The current {@link XWikiContext context}.
* @return <tt>true</tt> if the user does belong to the specified group, false otherwise or if
* an exception occurs.
* @throws XWikiException If an error occurs when checking the groups.
* @since Platform-1.3
*/
public boolean isUserInGroup(String groupName, XWikiContext context) throws XWikiException
{
if (!StringUtils.isEmpty(getUser())) {
XWikiGroupService groupService = context.getWiki().getGroupService(context);
DocumentReference groupReference = this.currentMixedDocumentReferenceResolver.resolve(groupName);
Collection<DocumentReference> groups = groupService.getAllGroupsReferencesForMember(getUserReference(context), 0, 0, context);
if (groups.contains(groupReference)) {
return true;
}
}
return false;
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
public String toString()
{
return getUser();
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
private DocumentReference getUserReference(XWikiContext context)
{
return this.currentMixedDocumentReferenceResolver.resolve(getUser());
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server
/**
* <p>
* Retrieve the XWiki user associated to the current XWiki context
* </p>
*
* @param componentManager The component manager to be used to retrieve the execution context.
* @return The user associated to the current XWiki context.
*/
public static String getXWikiUser(ComponentManager componentManager)
{
XWikiUser user = getXWikiContext(componentManager).getXWikiUser();
if (user == null) {
return "XWiki.Guest";
}
return user.getUser();
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException
{
if (action.equals("skin") && (doc.getSpace().equals("skins") || doc.getSpace().equals("resources"))) {
// We still need to call checkAuth to set the proper user.
XWikiUser user = checkAuth(context);
if (user != null) {
context.setUser(user.getUser());
}
return true;
}
return getRightService().checkAccess(action, doc, context);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-gwt-api
@Override
public String login(String username, String password, boolean rememberme) throws XWikiGWTException
{
try {
XWikiContext context = getXWikiContext();
XWikiUser user =
context.getWiki().getAuthService().checkAuth(username, password, rememberme ? "yes" : "no", context);
if (user == null)
return "XWiki.XWikiGuest";
else
return user.getUser();
} catch (Exception e) {
throw getXWikiGWTException(e);
}
}
代码示例来源:origin: org.phenotips/lims-integration-api
@Override
public boolean hasAccessLevel(String right, String username, String docname, XWikiContext context)
throws XWikiException
{
if (context != null && context.getRequest() != null && context.getRequest().getSession() != null) {
LimsAuthentication limsAuth =
(LimsAuthentication) context.getRequest().getSession().getAttribute(Lims247AuthServiceImpl.SESSION_KEY);
@SuppressWarnings("deprecation")
XWikiDocument doc = context.getWiki().getDocument(docname, context);
String access = (String) context.getRequest().getSession().getAttribute(Lims247AuthServiceImpl.ACCESS_KEY);
if (doc.getXObject(Patient.CLASS_REFERENCE) != null && limsAuth != null
&& StringUtils.equals(limsAuth.getUser().getUser(), username) && StringUtils.isNotEmpty(access)) {
Right requested = actionToRight(right);
Right granted = actionToRight(access);
return requested.compareTo(granted) <= 0;
}
}
return super.hasAccessLevel(right, username, docname, context);
}
}
代码示例来源:origin: org.phenotips/lims-integration-api
@Override
public XWikiUser checkAuth(XWikiContext context) throws XWikiException
{
XWikiUser user = getUserFromSession(context);
if (user != null) {
this.logger.debug("Previously authenticated LIMS user found in the session: [{}]", user.getUser());
setupContextForLims(context);
storeAccesMode(context);
return user;
}
XWikiRequest request = context.getRequest();
String pn = request.get(LimsServer.INSTANCE_IDENTIFIER_KEY);
String username = request.get(LimsServer.USERNAME_KEY);
String token = request.get(LimsServer.TOKEN_KEY);
if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(token)) {
user = checkLocalToken(token, username, context);
if (user == null && StringUtils.isNotEmpty(pn)) {
user = checkRemoteToken(token, username, pn, context);
}
if (user != null) {
storeUserInSession(new LimsAuthentication(token, user, pn), context);
setupContextForLims(context);
storeAccesMode(context);
return user;
}
}
// LIMS authentication failed, try with the default form-based authentication
return super.checkAuth(context);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-security-bridge
/**
* Ensure user authentication if needed.
*
* @param context Current XWikiContext
*/
private void authenticateUser(XWikiContext context)
{
DocumentReference contextUserReference = context.getUserReference();
DocumentReference userReference = contextUserReference;
if (userReference == null && context.getMode() != XWikiContext.MODE_XMLRPC) {
try {
XWikiUser user = context.getWiki().checkAuth(context);
if (user != null) {
userReference = resolveUserName(user.getUser(), new WikiReference(context.getWikiId()));
}
} catch (XWikiException e) {
LOGGER.error("Caught exception while authenticating user.", e);
}
}
if (userReference != null && XWikiConstants.GUEST_USER.equals(userReference.getName())) {
// Public users (not logged in) should be passed as null in the new API. It may happen that badly
// design code, and poorly written API does not take care, so we prevent security issue here.
userReference = null;
}
if (userReference != contextUserReference
&& (userReference == null || !userReference.equals(contextUserReference))) {
context.setUserReference(userReference);
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* API to retrieve the e-mail address of this user. This e-mail address is taken from the user
* profile. If the user hasn't changed his profile, then this is the e-mail address he filled in
* the registration form.
*
* @return The e-mail address from the user profile, or <tt>null</tt> if there is an error
* retrieving the email.
* @since 1.1.3
* @since 1.2.2
* @since 1.3M2
*/
public String getEmail()
{
XWikiDocument userDoc;
try {
userDoc = getXWikiContext().getWiki().getDocument(user.getUser(), getXWikiContext());
BaseObject obj = userDoc.getObject("XWiki.XWikiUsers");
return obj.getStringValue("email");
} catch (Exception e) {
// APIs should never throw errors, as velocity cannot catch them, and scripts should be
// as robust as possible. Instead, the code using this should know that null means there
// was an error, if it really needs to report these exceptions.
return null;
}
}
}
代码示例来源:origin: org.phenotips/phenotips-security-bridge
/**
* Get the current user associated with this context.
*
* @param context the current request context
* @return a reference to the current user's profile, or {@code null} if the user isn't authenticated (guest)
*/
private DocumentReference getCurrentUser(XWikiContext context)
{
DocumentReference contextUserReference = context.getUserReference();
DocumentReference userReference = contextUserReference;
if (userReference == null) {
try {
XWikiUser user = context.getWiki().checkAuth(context);
if (user != null) {
userReference = resolveUserName(user.getUser(), new WikiReference(context.getWikiId()));
}
} catch (XWikiException e) {
// Authentication failure, this should have been logged downstream
}
}
if (userReference != null && XWikiConstants.GUEST_USER.equals(userReference.getName())) {
// Public users (not logged in) should be passed as null in the new API. It may happen that badly
// design code, and poorly written API does not take care, so we prevent security issue here.
userReference = null;
}
if (userReference != contextUserReference) {
context.setUserReference(userReference);
}
return userReference;
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* Make sure we can't loose context user if the context wiki change (i.e. set the prefixed full name of the user in
* the context).
*
* @deprecated this method does not exists and is useless in version 3.1 and more
*/
@Deprecated
private void normalizedContextUser(XWikiContext context)
{
if (context.getXWikiUser() != null) {
context.setUser(this.defaultEntityReferenceSerializer.serialize(this.currentMixedDocumentReferenceResolver
.resolve(context.getXWikiUser().getUser(),
new SpaceReference("XWiki", new WikiReference(context.getDatabase()))), context.getXWikiUser()
.isMain()));
}
}
代码示例来源:origin: phenotips/phenotips
/**
* Get the current user associated with this context.
*
* @param context the current request context
* @return a reference to the current user's profile, or {@code null} if the user isn't authenticated (guest)
*/
private DocumentReference getCurrentUser(XWikiContext context)
{
DocumentReference contextUserReference = context.getUserReference();
DocumentReference userReference = contextUserReference;
if (userReference == null) {
try {
XWikiUser user = context.getWiki().checkAuth(context);
if (user != null) {
userReference = resolveUserName(user.getUser(), new WikiReference(context.getWikiId()));
}
} catch (XWikiException e) {
// Authentication failure, this should have been logged downstream
}
}
if (userReference != null && XWikiConstants.GUEST_USER.equals(userReference.getName())) {
// Public users (not logged in) should be passed as null in the new API. It may happen that badly
// design code, and poorly written API does not take care, so we prevent security issue here.
userReference = null;
}
if (userReference != contextUserReference) {
context.setUserReference(userReference);
}
return userReference;
}
代码示例来源:origin: org.phenotips/lims-integration-api
(LimsAuthentication) context.getRequest().getSession().getAttribute(Lims247AuthServiceImpl.SESSION_KEY);
if (limsAuth != null && StringUtils.equals(limsAuth.getToken(), token)
&& StringUtils.equals(StringUtils.substringAfter(limsAuth.getUser().getUser(), "."), username)) {
return true;
代码示例来源:origin: org.phenotips/lims-integration-api
@Override
public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException
{
if (context != null && context.getRequest() != null) {
XWikiUser user = context.getWiki().checkAuth(context);
if (user != null) {
DocumentReference userReference =
this.userAndGroupReferenceResolver
.resolve(user.getUser(), new WikiReference(context.getDatabase()));
context.setUserReference(userReference);
} else {
context.setUserReference(null);
}
LimsAuthentication limsAuth =
(LimsAuthentication) context.getRequest().getSession().getAttribute(Lims247AuthServiceImpl.SESSION_KEY);
String access = (String) context.getRequest().getSession().getAttribute(Lims247AuthServiceImpl.ACCESS_KEY);
if (doc.getXObject(Patient.CLASS_REFERENCE) != null && limsAuth != null
&& StringUtils.isNotEmpty(access)) {
Right requested = actionToRight(action);
Right granted = actionToRight(access);
return requested.compareTo(granted) <= 0;
}
}
return super.checkAccess(action, doc, context);
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
} finally {
if (originalAuthor != null) {
xcontext.setUser(originalAuthor.getUser(), originalAuthor.isMain());
} else {
xcontext.setUser(null);
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* {@inheritDoc}
*
* @see DocumentAccessBridge#getCurrentUser()
*/
public String getCurrentUser()
{
XWikiUser user = getContext().getXWikiUser();
// Make sure to always return the full reference of the user
if (user != null) {
return this.defaultEntityReferenceSerializer.serialize(this.currentMixedDocumentReferenceResolver.resolve(
user.getUser(), new SpaceReference("XWiki", new WikiReference(getContext().getDatabase()))));
} else {
return XWikiRightService.GUEST_USER_FULLNAME;
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-gwt-api
/**
* Initialize XWiki Context and XWiki Container Objects.
*/
private void initXWiki() throws Exception
{
XWikiEngineContext engine = new XWikiServletContext(getServletContext());
XWikiRequest request = new XWikiServletRequest(getThreadLocalRequest());
XWikiResponse response = new XWikiServletResponse(getThreadLocalResponse());
XWikiContext context = Utils.prepareContext("", request, response, engine);
context.setMode(XWikiContext.MODE_GWT);
context.setWikiId("xwiki");
initializeContainerComponent(context);
XWiki xwiki = XWiki.getXWiki(context);
XWikiURLFactory urlf = xwiki.getURLFactoryService().createURLFactory(context.getMode(), context);
context.setURLFactory(urlf);
xwiki.prepareResources(context);
String username = "XWiki.XWikiGuest";
if (context.getMode() == XWikiContext.MODE_GWT_DEBUG) {
username = "XWiki.superadmin";
}
XWikiUser user = context.getWiki().checkAuth(context);
if (user != null) {
username = user.getUser();
}
context.setUser(username);
if (context.getDoc() == null) {
context.setDoc(new XWikiDocument("Fake", "Document"));
}
context.put("ajax", new Boolean(true));
}
代码示例来源:origin: org.phenotips/lims-integration-api
this.referenceResolver.resolve(auth.getUser().getUser(), EntityType.DOCUMENT).getName());
result.put(LimsServer.TOKEN_KEY, auth.getToken());
} else if (context.getUserReference() != null) {
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!