Exemplo n.º 1
0
  protected OpenIdUser discover(Identifier identifier, HttpServletRequest request)
      throws Exception {
    OpenIdUser user = _userCache.get(identifier.getUrl(), true);
    if (user == null) {
      try {
        user = _context.getDiscovery().discover(identifier, _context);
      } catch (IOException e) {
        if (!_identifierAsServer) throw e;
      }
      if (user == null) {
        if (!_identifierAsServer) return null;

        // user = new OpenIdUser(identifier.getId(), YadisDiscovery.IDENTIFIER_SELECT,
        // identifier.getUrl(), null);
        user =
            OpenIdUser.populate(
                identifier.getId(), YadisDiscovery.IDENTIFIER_SELECT, identifier.getUrl(), null);
      }

      _userCache.put(identifier.getUrl(), user);
    }

    _listener.onDiscovery(user, request);
    request.setAttribute(OpenIdUser.ATTR_NAME, user);
    return user;
  }
Exemplo n.º 2
0
 /**
  * Returns true if the user is successfully associated with his openid provider; The {@link
  * OpenIdUser} is persisted if successful.
  */
 public boolean associate(
     OpenIdUser user, HttpServletRequest request, HttpServletResponse response) throws Exception {
   if (_context.getAssociation().associate(user, _context)) {
     _manager.saveUser(user, request, response);
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
 /**
  * Returns true if the user has succeeded authentication on his openid provider; The {@link
  * OpenIdUser} is persisted if successful.
  */
 public boolean verifyAuth(
     OpenIdUser user, HttpServletRequest request, HttpServletResponse response) throws Exception {
   if (_context.getAssociation().verifyAuth(user, getAuthParameters(request), _context)) {
     _listener.onAuthenticate(user, request);
     _manager.saveUser(user, request, response);
     return true;
   }
   return false;
 }
Exemplo n.º 4
0
 /**
  * Returns true if the user is successfully associated and redirected to his openid provider for
  * authentication; The {@link OpenIdUser} is persisted if successful.
  */
 public boolean associateAndAuthenticate(
     OpenIdUser user,
     HttpServletRequest request,
     HttpServletResponse response,
     String trustRoot,
     String realm,
     String returnTo)
     throws Exception {
   return _context.getAssociation().associate(user, _context)
       && authenticate(user, request, response, trustRoot, realm, returnTo);
 }