当前位置: 首页>>代码示例>>Java>>正文


Java UserNotFoundException类代码示例

本文整理汇总了Java中org.androidpn.server.service.UserNotFoundException的典型用法代码示例。如果您正苦于以下问题:Java UserNotFoundException类的具体用法?Java UserNotFoundException怎么用?Java UserNotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UserNotFoundException类属于org.androidpn.server.service包,在下文中一共展示了UserNotFoundException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticate

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
/**
 * Authenticates a user with a username and plain text password, and
 * returns an AuthToken.
 * 
 * @param username the username
 * @param password the password
 * @return an AuthToken
 * @throws UnauthenticatedException if the username and password do not match
 */
public static AuthToken authenticate(String username, String password)
        throws UnauthenticatedException {
    if (username == null || password == null) {
        throw new UnauthenticatedException();
    }
    username = username.trim().toLowerCase();
    if (username.contains("@")) {
        int index = username.indexOf("@");
        String domain = username.substring(index + 1);
        if (domain.equals(XmppServer.getInstance().getServerName())) {
            username = username.substring(0, index);
        } else {
            throw new UnauthenticatedException();
        }
    }
    try {
        if (!password.equals(getPassword(username))) {
            throw new UnauthenticatedException();
        }
    } catch (UserNotFoundException unfe) {
        throw new UnauthenticatedException();
    }
    return new AuthToken(username);
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:34,代码来源:AuthManager.java

示例2: authenticate

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
public static AuthToken authenticate(String username, String password)
        throws UnauthorizedException {
    if (username == null || password == null) {
        throw new UnauthorizedException();
    }
    username = username.trim().toLowerCase();
    if (username.contains("@")) {
        // Check that the specified domain matches the server's domain
        int index = username.indexOf("@");
        String domain = username.substring(index + 1);
        if (domain.equals(XmppServer.getInstance().getServerName())) {
            username = username.substring(0, index);
        } else {
            throw new UnauthorizedException();
        }
    }
    try {
        if (!password.equals(getPassword(username))) {
            throw new UnauthorizedException();
        }
    } catch (UserNotFoundException unfe) {
        throw new UnauthorizedException();
    }
    return new AuthToken(username);
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:26,代码来源:AuthManager.java

示例3: authenticate

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
public static AuthToken authenticate(String username, String password)
        throws UnauthorizedException {
    if (username == null || password == null) {
        throw new UnauthorizedException();
    }
    username = username.trim().toLowerCase();
    if (username.contains("@")) {
        int index = username.indexOf("@");
        String domain = username.substring(index + 1);
        if (domain.equals(XmppServer.getInstance().getServerName())) {
            username = username.substring(0, index);
        } else {
            throw new UnauthorizedException();
        }
    }
    try {
        if (!password.equals(getPassword(username))) {
            throw new UnauthorizedException();
        }
    } catch (UserNotFoundException unfe) {
        throw new UnauthorizedException();
    }
    return new AuthToken(username);
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:25,代码来源:AuthManager.java

示例4: authenticate

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
/**
 * Authenticates a user with a username and plain text password, and
 * returns an AuthToken.
 * 
 * @param username the username
 * @param password the password
 * @return an AuthToken
 * @throws UnauthorizedException if the username and password do not match
 */
public static AuthToken authenticate(String username, String password)
        throws UnauthorizedException {
    if (username == null || password == null) {
        throw new UnauthorizedException();
    }
    username = username.trim().toLowerCase();
    if (username.contains("@")) {
        int index = username.indexOf("@");
        String domain = username.substring(index + 1);
        if (domain.equals(XmppServer.getInstance().getServerName())) {
            username = username.substring(0, index);
        } else {
            throw new UnauthorizedException();
        }
    }
    try {
        if (!password.equals(getPassword(username))) {
            throw new UnauthorizedException();
        }
    } catch (UserNotFoundException unfe) {
        throw new UnauthorizedException();
    }
    return new AuthToken(username);
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:34,代码来源:AuthManager.java

示例5: getUserByUsername

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public User getUserByUsername(String username) throws UserNotFoundException {
	List users = getHibernateTemplate().find("from User where username=?",
			username);
	if (users == null || users.isEmpty()) {
		throw new UserNotFoundException("用户 '" + username + "' 未找到");
	} else {
		return (User) users.get(0);
	}
}
 
开发者ID:lijian17,项目名称:androidpn-server,代码行数:11,代码来源:UserDaoHibernate.java

示例6: sendNotifcationToUser

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
/**
 * 向特定用户发送新创建的通知消息
 * 
 * @param apiKey
 *            密钥
 * @param username
 *            用户名
 * @param title
 *            消息标题
 * @param message
 *            消息详情
 * @param uri
 *            消息URI
 * @param imageUrl
 *            图片地址
 * @param shouldSave
 *            是否要保存该消息
 */
public void sendNotifcationToUser(String apiKey, String username,
		String title, String message, String uri, String imageUrl,
		boolean shouldSave) {
	log.debug("sendNotifcationToUser()...");
	Random random = new Random();
	String id = Integer.toHexString(random.nextInt());
	try {
		User user = userService.getUserByUsername(username);
		// 避免user非法存储到数据库(过滤垃圾数据)
		if (user != null && shouldSave) {
			saveNotification(apiKey, username, title, message, uri,
					imageUrl, id);
		}
	} catch (UserNotFoundException e) {
		log.debug("未找到该用户:" + username);
		e.printStackTrace();
	}
	IQ notificationIQ = createNotificationIQ(id, apiKey, title, message,
			uri, imageUrl);
	ClientSession session = sessionManager.getSession(username);
	if (session != null) {
		if (session.getPresence().isAvailable()) {
			notificationIQ.setTo(session.getAddress());
			session.deliver(notificationIQ);
		}
	}
}
 
开发者ID:lijian17,项目名称:androidpn-server,代码行数:46,代码来源:NotificationManager.java

示例7: authenticate

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
/**
* 根据用户名、密码验证用户名真实性,并返回一个令牌
* 
* @param username
*            用户名
* @param password
*            用户密码
* @return 一个令牌
* @throws UnauthenticatedException
*             如果用户名和密码不匹配
*/
  public static AuthToken authenticate(String username, String password)
          throws UnauthenticatedException {
      if (username == null || password == null) {
          throw new UnauthenticatedException();
      }
// 用户名是否是@domain形式
      username = username.trim().toLowerCase();
      if (username.contains("@")) {
          int index = username.indexOf("@");
          String domain = username.substring(index + 1);
	// 验证domain
          if (domain.equals(XmppServer.getInstance().getServerName())) {
		// 获得真正的username
              username = username.substring(0, index);
          } else {
              throw new UnauthenticatedException();
          }
      }
      try {
          if (!password.equals(getPassword(username))) {
              throw new UnauthenticatedException();
          }
      } catch (UserNotFoundException unfe) {
          throw new UnauthenticatedException();
      }
      return new AuthToken(username);
  }
 
开发者ID:lijian17,项目名称:androidpn-server,代码行数:39,代码来源:AuthManager.java

示例8: getUserByUsername

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public User getUserByUsername(String username) throws UserNotFoundException {
    List users = getHibernateTemplate().find("from User where username=?",
            username);
    if (users == null || users.isEmpty()) {
        throw new UserNotFoundException("User '" + username + "' not found");
    } else {
        return (User) users.get(0);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:11,代码来源:UserDaoHibernate.java

示例9: getUsername

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
/**
 * Returns the username associated with this session.
 * 
 * @return the username
 * @throws UserNotFoundException if a user has not authenticated yet
 */
public String getUsername() throws UserNotFoundException {
    if (authToken == null) {
        throw new UserNotFoundException();
    }
    return getAddress().getNode();
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:13,代码来源:ClientSession.java

示例10: authorize

import org.androidpn.server.service.UserNotFoundException; //导入依赖的package包/类
public static boolean authorize(String username, String principal) {
    if (log.isDebugEnabled()) {
        log.debug("Trying authorize(" + username + " , " + principal + ")");
    }
    try {
        ServiceManager.getUserService().getUserByUsername(username);
    } catch (UserNotFoundException nfe) {
        return false;
    }
    return true;
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:12,代码来源:AuthManager.java


注:本文中的org.androidpn.server.service.UserNotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。