本文整理汇总了Java中com.mendix.systemwideinterfaces.core.IUser类的典型用法代码示例。如果您正苦于以下问题:Java IUser类的具体用法?Java IUser怎么用?Java IUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IUser类属于com.mendix.systemwideinterfaces.core包,在下文中一共展示了IUser类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findUser
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
private static IUser findUser(IContext c, String openID) throws CoreException {
List<IMendixObject> userList = Core.retrieveXPathQuery(c, String.format("//%s[%s='%s']", USER_ENTITY, USER_ENTITY_NAME, openID));
if (userList.size() > 0) {
IMendixObject userObject = userList.get(0);
String username = userObject.getValue(c, DEFAULT_MENDIX_USERNAME_ATTRIBUTE);
if (LOG.isTraceEnabled())
LOG.trace("Getting System.User using username: '" + username + "'");
return Core.getUser(c, username);
} else {
return null;
}
}
示例2: initializeSessionForUser
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
private static ISession initializeSessionForUser(IContext context, String username) throws CoreException {
IUser user = Core.getUser(context, username);
if (user == null) {
throw new RuntimeException("Assertion: user with username '" + username + "' does not exist");
}
return Core.initializeSession(user, null);
}
示例3: executeAction
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
@Override
public java.lang.Boolean executeAction() throws Exception
{
// BEGIN USER CODE
IUser user = Core.getUser(getContext(), userName);
return user != null && Core.authenticate(getContext(), user, password);
// END USER CODE
}
示例4: executeAction
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
@Override
public Boolean executeAction() throws Exception
{
// BEGIN USER CODE
IUser user = Core.getUser(getContext(), userName);
return user != null && Core.authenticate(getContext(), user, password);
// END USER CODE
}
示例5: findUser
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
private static IUser findUser(IContext c, String openID) throws CoreException {
List<IMendixObject> userList = Core.retrieveXPathQuery(c, String.format("//%s[%s='%s']", USER_ENTITY, USER_ENTITY_NAME, openID));
if (userList.size() > 0) {
IMendixObject userObject = userList.get(0);
String username = userObject.getValue(c, DEFAULT_MENDIX_USERNAME_ATTRIBUTE);
if (log.isTraceEnabled())
log.trace("Getting System.User using username: '" + username + "'");
return Core.getUser(c, username);
} else {
return null;
}
}
示例6: createSessionForUser
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
/**
* Given a username, starts a new session for the user and redirects back to index.html.
* If no matching account is found for the user, a new account will be created automatically.
* @param resp
* @param req
* @param user
* @return
* @throws CoreException
* @throws IOException
* @throws NoSuchMethodException
* @throws SecurityException
*/
static public ISession createSessionForUser(IMxRuntimeResponse resp,
IMxRuntimeRequest req, IUser user) throws Exception {
LOG.info("User " + user.getName() + " authenticated. Starting session..");
String sessionid = req.getCookie(XAS_SESSION_ID);
ISession session = Core.initializeSession(user, sessionid);
// Used to enable Single Sign Off request (from remote sso *server*); must only sign off user in a particular User Agent / Browser
String ua = req.getHeader("User-Agent");
session.setUserAgent(ua);
if (LOG.isDebugEnabled())
LOG.debug("Created session, fingerprint: " + OpenIDUtils.getFingerPrint(session));
writeSessionCookies(resp, session);
return session;
}
示例7: createSessionForUser
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
/**
* Given a username, starts a new session for the user and redirects back to index.html.
* If no matching account is found for the user, a new account will be created automatically.
* @param resp
* @param req
* @param username
* @return
* @throws CoreException
* @throws IOException
* @throws NoSuchMethodException
* @throws SecurityException
*/
static public ISession createSessionForUser(IMxRuntimeResponse resp,
IMxRuntimeRequest req, IUser user) throws Exception {
log.info("User " + user.getName() + " authenticated. Starting session..");
String sessionid = req.getCookie(Core.getConfiguration().getSessionIdCookieName());
ISession session = Core.initializeSession(user, sessionid);
// Used to enable Single Sign Off request (from remote sso *server*); must only sign off user in a particular User Agent / Browser
String ua = req.getHeader("User-Agent");
session.setUserAgent(ua);
if (log.isDebugEnabled())
log.debug("Created session, fingerprint: " + OpenIDUtils.getFingerPrint(session));
writeSessionCookies(resp, session);
return session;
}
示例8: getCurrentUser
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
public IUser getCurrentUser() {
return activeSession.getUser();
}
示例9: authenticate
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
/**
* Authenticate the given user with the given password.
* @param context
* @param user the user.
* @param password the password.
* @return returns true if authentication was successful.
*/
public static boolean authenticate(IContext context, IUser user, String password) throws CoreException
{
return component.core().authenticate(context, user, password);
}
示例10: getUser
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
/**
* Returns a user using the given user name.
* @param context the context.
* @param userName the user name to retrieve a user for.
* @return the retrieved user.
*/
public static IUser getUser(IContext context, String userName) throws CoreException
{
return component.core().getUser(context, userName);
}
示例11: initializeSession
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
/**
* Initialize a new session for the given user.
* @deprecated use initializeSession(user, currentSessionId) instead.
* @param context the context.
* @param user the user for which the session should be initialized.
* @param currentSessionId id of the current session, will be used to transfer data when current session is associated with a guest user.
* @param locale determines the user's language.
* The existing language remains set if available. The default language is used when no language was set and locale is null or empty.
* @return the created session.
*/
@Deprecated
public static ISession initializeSession(@SuppressWarnings("unused") IContext context, IUser user, String currentSessionId, @SuppressWarnings("unused") String locale) throws CoreException
{
return Core.initializeSession(user, currentSessionId);
}
示例12: initializeSession
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
/**
* Initialize a new session for the given user.
* @param user the user for which the session should be initialized.
* @param currentSessionId id of the current session, will be used to transfer data when current session is associated with a guest user.
* @return the created session.
*/
public static ISession initializeSession(IUser user, String currentSessionId) throws CoreException
{
return component.core().initializeSession(user, currentSessionId);
}
示例13: authenticateWithMicroflow
import com.mendix.systemwideinterfaces.core.IUser; //导入依赖的package包/类
private boolean authenticateWithMicroflow(final String microflowName) throws Exception {
try {
// Create a context and transaction, so that headers can be inspected during the execution of the authorization microflow.
final IContext c = Core.createSystemContext();
this.setContext(c);
IMendixObject userobject = withTransaction(new Function<IMendixObject>() {
@Override
public IMendixObject apply() throws CoreException {
return Core.execute(c, microflowName, EMPTY_MAP);
}
});
this.setContext(null); //authentication was in system context, but execution will be in user context
if (userobject == null)
return false;
String username = (String) userobject.getValue(c, User.MemberNames.Name.toString());
if (username == null || username.isEmpty())
throw new IllegalStateException("Trying to authenticate a user without a name"); //yes, this actually went wrong once during testing, due to a broken DB record...
IUser user = Core.getUser(c, username);
ISession session = Core.initializeSession(user, null);
this.autoLogout = true;
this.activeSession = session;
this.setContext(session.createContext());
return true;
} catch (Exception e) {
RestServices.LOGPUBLISH.warn("Failed to authenticate request using microflow '" + microflowName + "', microflow threw an unexpected exception: " + e.getMessage(), e);
throw e;
}
}