コード例 #1
0
 private AuthResult byPreferredEmail(final HttpServletResponse rsp, final String email) {
   try {
     final ReviewDb db = schema.open();
     try {
       List<Account> matches = db.accounts().byPreferredEmail(email).toList();
       return matches.size() == 1 ? auth(matches.get(0)) : null;
     } finally {
       db.close();
     }
   } catch (OrmException e) {
     getServletContext().log("cannot query database", e);
     return null;
   }
 }
コード例 #2
0
 private AuthResult byUserName(final HttpServletResponse rsp, final String userName) {
   try {
     final ReviewDb db = schema.open();
     try {
       AccountExternalId.Key key = new AccountExternalId.Key(SCHEME_USERNAME, userName);
       return auth(db.accountExternalIds().get(key));
     } finally {
       db.close();
     }
   } catch (OrmException e) {
     getServletContext().log("cannot query database", e);
     return null;
   }
 }
コード例 #3
0
 private AuthResult byAccountId(final HttpServletResponse rsp, final String idStr) {
   final Account.Id id;
   try {
     id = Account.Id.parse(idStr);
   } catch (NumberFormatException nfe) {
     return null;
   }
   try {
     final ReviewDb db = schema.open();
     try {
       return auth(db.accounts().get(id));
     } finally {
       db.close();
     }
   } catch (OrmException e) {
     getServletContext().log("cannot query database", e);
     return null;
   }
 }