本文整理汇总了Java中com.ibm.xsp.designer.context.XSPContext.getUser方法的典型用法代码示例。如果您正苦于以下问题:Java XSPContext.getUser方法的具体用法?Java XSPContext.getUser怎么用?Java XSPContext.getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.xsp.designer.context.XSPContext
的用法示例。
在下文中一共展示了XSPContext.getUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMyGroupsAndRoles
import com.ibm.xsp.designer.context.XSPContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<String> getMyGroupsAndRoles() {
List<String> lstRC = new ArrayList<String>();
try {
XSPContext xsp = ExtLibUtil.getXspContext();
DirectoryUser dirUser = xsp.getUser();
Name nonUser = ExtLibUtil.getCurrentSession().createName(ExtLibUtil.getCurrentSession().getEffectiveUserName());
lstRC.add(nonUser.getCanonical());
lstRC.add(nonUser.getAbbreviated());
lstRC.add(nonUser.getCommon());
lstRC.addAll(dirUser.getGroups());
lstRC.addAll(dirUser.getRoles());
} catch (Exception e) {
e.printStackTrace();
}
return lstRC;
}
示例2: isLoggedIn
import com.ibm.xsp.designer.context.XSPContext; //导入方法依赖的package包/类
protected boolean isLoggedIn() {
XSPContext ctx = XSPContext.getXSPContext(FacesContext.getCurrentInstance());
if(ctx!=null) {
com.ibm.designer.runtime.directory.DirectoryUser user = ctx.getUser();
return !user.isAnonymous();
}
return false;
}
示例3: getCustomVars
import com.ibm.xsp.designer.context.XSPContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public ArrayList<Entry<String, String>> getCustomVars() {
ArrayList customVars = new ArrayList<Entry<String,String>>();
try {
XSPContext context = XSPContext.getXSPContext(FacesContext.getCurrentInstance());
DirectoryUser currentUser = context.getUser();
Name n = getSession().createName(effectiveUserName);
Vector<String> groups = new Vector(currentUser.getGroups());
groups.remove(effectiveUserName);
groups.remove(n.getCommon());
extLibVersion = getExtLibVersion();
ExternalContext extCon = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest httpServletRequest = (HttpServletRequest) extCon.getRequest();
customVars.add( new AbstractMap.SimpleEntry("title", "User"));
customVars.add( new AbstractMap.SimpleEntry("username", effectiveUserName));
customVars.add( new AbstractMap.SimpleEntry("access level", getReadableAccessLevel(getCurrentDatabase().getCurrentAccessLevel())));
customVars.add( new AbstractMap.SimpleEntry("roles", (userRoles.size()>0 ? userRoles.toString() : "(no roles enabled)") ));
customVars.add( new AbstractMap.SimpleEntry("groups", (groups.size()>0 ? groups.toString() : "(user not listed in any group)")));
customVars.add( new AbstractMap.SimpleEntry("title", "Browser"));
customVars.add( new AbstractMap.SimpleEntry("name", context.getUserAgent().getBrowser() + " " + context.getUserAgent().getBrowserVersion()));
customVars.add( new AbstractMap.SimpleEntry("user agent", context.getUserAgent().getUserAgent()));
customVars.add( new AbstractMap.SimpleEntry("language", context.getLocale().getDisplayName() + " (" + context.getLocaleString() + ")"));
customVars.add( new AbstractMap.SimpleEntry("timezone", context.getTimeZoneString()));
customVars.add( new AbstractMap.SimpleEntry("title", "Server") );
customVars.add( new AbstractMap.SimpleEntry("name", getCurrentDatabase().getServer() ) );
customVars.add( new AbstractMap.SimpleEntry("version", notesVersion ) );
customVars.add( new AbstractMap.SimpleEntry("platform", getSession().getPlatform() ) );
customVars.add( new AbstractMap.SimpleEntry("extension library version", extLibVersion ) );
customVars.add( new AbstractMap.SimpleEntry("title", "Database") );
customVars.add( new AbstractMap.SimpleEntry("name", currentDbTitle ) );
customVars.add( new AbstractMap.SimpleEntry("path", currentDbFilePath ) );
customVars.add( new AbstractMap.SimpleEntry("size", DebugToolbar.getReadableSize( (long) getCurrentDatabase().getSize())));
customVars.add( new AbstractMap.SimpleEntry("created", getCurrentDatabase().getCreated().toString()) );
customVars.add( new AbstractMap.SimpleEntry("last modified", getCurrentDatabase().getLastModified().toString()));
customVars.add( new AbstractMap.SimpleEntry("full text indexed?", (getCurrentDatabase().isFTIndexed() ? "yes (last update: " + getCurrentDatabase().getLastFTIndexed().toString() + ")" : "no")));
customVars.add( new AbstractMap.SimpleEntry("title", "Request"));
customVars.add( new AbstractMap.SimpleEntry("query string", context.getUrl().getQueryString()));
customVars.add( new AbstractMap.SimpleEntry("remote address", httpServletRequest.getRemoteAddr()));
customVars.add( new AbstractMap.SimpleEntry("cookies", getCookieDump(extCon.getRequestCookieMap()) ));
} catch (Exception e) {
error(e, "getCustomVars");
}
return customVars;
}