本文整理汇总了Java中azkaban.user.UserManagerException类的典型用法代码示例。如果您正苦于以下问题:Java UserManagerException类的具体用法?Java UserManagerException怎么用?Java UserManagerException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserManagerException类属于azkaban.user包,在下文中一共展示了UserManagerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Action(name = "login")
public String login(@ActionParam("username") String username,
@ActionParam("password") String password) throws UserManagerException,
ServletException {
String ip =
(String) this.getContext().getRawRequestContext()
.getLocalAttr("REMOTE_ADDR");
logger
.info("Attempting to login for " + username + " from ip '" + ip + "'");
Session session = createSession(username, password, ip);
logger.info("Session id " + session.getSessionId() + " created for user '"
+ username + "' and ip " + ip);
return session.getSessionId();
}
示例2: handleAjaxLoginAction
import azkaban.user.UserManagerException; //导入依赖的package包/类
protected void handleAjaxLoginAction(HttpServletRequest req, HttpServletResponse resp, Map<String, Object> ret) throws ServletException {
if (hasParam(req, "username") && hasParam(req, "password")) {
Session session = null;
try {
session = createSession(req);
} catch (UserManagerException e) {
ret.put("error", "Incorrect Login. " + e.getMessage());
return;
}
Cookie cookie = new Cookie(SESSION_ID_NAME, session.getSessionId());
cookie.setPath("/");
resp.addCookie(cookie);
getApplication().getSessionCache().addSession(session);
ret.put("status", "success");
ret.put("session.id", session.getSessionId());
}
else {
ret.put("error", "Incorrect Login.");
}
}
示例3: testInvalidIdPropertyThrowsUserManagerException
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void testInvalidIdPropertyThrowsUserManagerException() throws Exception {
thrown.expect(UserManagerException.class);
Props props = getProps();
props.put(LdapUserManager.LDAP_USERID_PROPERTY, "invalidField");
userManager = new LdapUserManager(props);
userManager.getUser("gauss", "password");
}
示例4: getUserFromSessionId
import azkaban.user.UserManagerException; //导入依赖的package包/类
public static User getUserFromSessionId(String sessionId, String ip)
throws UserManagerException {
Session session =
AzkabanWebServer.getInstance().getSessionCache().getSession(sessionId);
if (session == null) {
throw new UserManagerException("Invalid session. Login required");
} else if (!session.getIp().equals(ip)) {
throw new UserManagerException("Invalid session. Session expired.");
}
return session.getUser();
}
示例5: createSession
import azkaban.user.UserManagerException; //导入依赖的package包/类
private Session createSession(String username, String password, String ip)
throws UserManagerException, ServletException {
UserManager manager = getAzkaban().getUserManager();
azkaban.user.User user = manager.getUser(username, password);
String randomUID = UUID.randomUUID().toString();
Session session = new Session(randomUID, user, ip);
getAzkaban().getSessionCache().addSession(session);
return session;
}
示例6: TestFilterNonAdminOnlyFlowParams
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void TestFilterNonAdminOnlyFlowParams() throws IOException,
ExecutorManagerException, UserManagerException {
ExecutableFlow flow = createExecutableFlow();
UserManager manager = TestUtils.createTestXmlUserManager();
User user = manager.getUser("testUser", "testUser");
HttpRequestUtils.filterAdminOnlyFlowParams(manager,
flow.getExecutionOptions(), user);
Assert.assertFalse(flow.getExecutionOptions().getFlowParameters()
.containsKey(ExecutionOptions.FLOW_PRIORITY));
Assert.assertFalse(flow.getExecutionOptions().getFlowParameters()
.containsKey(ExecutionOptions.USE_EXECUTOR));
}
示例7: TestFilterAdminOnlyFlowParams
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void TestFilterAdminOnlyFlowParams() throws IOException,
ExecutorManagerException, UserManagerException {
ExecutableFlow flow = createExecutableFlow();
UserManager manager = TestUtils.createTestXmlUserManager();
User user = manager.getUser("testAdmin", "testAdmin");
HttpRequestUtils.filterAdminOnlyFlowParams(manager,
flow.getExecutionOptions(), user);
Assert.assertTrue(flow.getExecutionOptions().getFlowParameters()
.containsKey(ExecutionOptions.FLOW_PRIORITY));
Assert.assertTrue(flow.getExecutionOptions().getFlowParameters()
.containsKey(ExecutionOptions.USE_EXECUTOR));
}
示例8: testHasAdminPermission
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void testHasAdminPermission() throws UserManagerException {
UserManager manager = TestUtils.createTestXmlUserManager();
User adminUser = manager.getUser("testAdmin", "testAdmin");
Assert.assertTrue(HttpRequestUtils.hasPermission(manager, adminUser,
Type.ADMIN));
}
示例9: testHasOrdinaryPermission
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void testHasOrdinaryPermission() throws UserManagerException {
UserManager manager = TestUtils.createTestXmlUserManager();
User testUser = manager.getUser("testUser", "testUser");
Assert.assertFalse(HttpRequestUtils.hasPermission(manager, testUser,
Type.ADMIN));
}
示例10: createSession
import azkaban.user.UserManagerException; //导入依赖的package包/类
private Session createSession(HttpServletRequest req) throws UserManagerException, ServletException {
String username = getParam(req, "username");
String password = getParam(req, "password");
String ip = req.getRemoteAddr();
return createSession(username, password, ip);
}
示例11: testGetUserWithInvalidPasswordThrowsUserManagerException
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void testGetUserWithInvalidPasswordThrowsUserManagerException() throws Exception {
thrown.expect(UserManagerException.class);
userManager.getUser("gauss", "invalid");
}
示例12: testGetUserWithInvalidUsernameThrowsUserManagerException
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void testGetUserWithInvalidUsernameThrowsUserManagerException() throws Exception {
thrown.expect(UserManagerException.class);
userManager.getUser("invalid", "password");
}
示例13: testGetUserWithEmptyPasswordThrowsUserManagerException
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void testGetUserWithEmptyPasswordThrowsUserManagerException() throws Exception {
thrown.expect(UserManagerException.class);
userManager.getUser("gauss", "");
}
示例14: testGetUserWithEmptyUsernameThrowsUserManagerException
import azkaban.user.UserManagerException; //导入依赖的package包/类
@Test
public void testGetUserWithEmptyUsernameThrowsUserManagerException() throws Exception {
thrown.expect(UserManagerException.class);
userManager.getUser("", "invalid");
}
示例15: createSession
import azkaban.user.UserManagerException; //导入依赖的package包/类
/**
* 创建session对象
*
* @param sessionid
* @param username
* @param password
* @param ip
* @return
* @throws UserManagerException
* @throws ServletException
*/
private Session createSession(String sessionid, String username, String password, String ip)
throws UserManagerException, ServletException {
User user = userManager.getUser(username, password);
Session session = new Session(sessionid, user, ip);
return session;
}