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


Java User.getUserId方法代码示例

本文整理汇总了Java中com.google.appengine.api.users.User.getUserId方法的典型用法代码示例。如果您正苦于以下问题:Java User.getUserId方法的具体用法?Java User.getUserId怎么用?Java User.getUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.users.User的用法示例。


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

示例1: CryptonomicaUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
public CryptonomicaUser(User googleUser,
                        PGPPublicKeyData pgpPublicKeyData,
                        NewUserRegistrationForm newUserRegistrationForm) {
    this.userId = googleUser.getUserId();
    this.webSafeStringKey = Key.create(
            CryptonomicaUser.class, googleUser.getUserId()
    ).toWebSafeString();
    this.firstName = pgpPublicKeyData.getFirstName().toLowerCase();
    this.lastName = pgpPublicKeyData.getLastName().toLowerCase();
    this.birthday = newUserRegistrationForm.getBirthday();
    this.googleUser = googleUser;
    if (googleUser.getEmail() != null) {
        this.email = new Email(googleUser.getEmail().toLowerCase()); // or email = pgpPublicKeyData.getUserEmail()
    }
    if (newUserRegistrationForm.getUserInfo() != null) {
        this.userInfo = new Text(newUserRegistrationForm.getUserInfo());
    }
    this.publicKeys = new ArrayList<>();
    Key<CryptonomicaUser> cryptonomicaUserKey = Key.create(CryptonomicaUser.class, googleUser.getUserId());
    this.publicKeys.add(
            Key.create(
                    cryptonomicaUserKey, PGPPublicKeyData.class, pgpPublicKeyData.getFingerprint()
            )
    );
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:26,代码来源:CryptonomicaUser.java

示例2: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser();  // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  // Use Objectify to save the greeting and now() is used to make the call synchronously as we
  // will immediately get a new page using redirect and we want the data to be present.
  ObjectifyService.ofy().save().entity(greeting).now();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:22,代码来源:SignGuestbookServlet.java

示例3: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser();  // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  // Use Objectify to save the greeting and now() is used to make the call synchronously as we
  // will immediately get a new page using redirect and we want the data to be present.
  ObjectifyService.ofy().save().entity(greeting).now();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:SignGuestbookServlet.java

示例4: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser(); // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  greeting.save();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:20,代码来源:SignGuestbookServlet.java

示例5: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser(); // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  // Use Objectify to save the greeting and now() is used to make the call synchronously as we
  // will immediately get a new page using redirect and we want the data to be present.
  ObjectifyService.ofy().save().entity(greeting).now();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:22,代码来源:SignGuestbookServlet.java

示例6: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  User user = userService.getCurrentUser();
  // String rpId = (request.isSecure() ? "https://" : "http://") + request.getHeader("Host");
  String rpId = request.getHeader("Host").split(":")[0];
  String rpName = getServletContext().getInitParameter("name");
  rpName = (rpName == null ? "" : rpName);

  MakePublicKeyCredentialOptions options =
      new MakePublicKeyCredentialOptions(user.getNickname(), user.getUserId(), rpId, rpName);

  String hasAdvanced = request.getParameter("advanced");
  if (hasAdvanced.equals("true")) {
    parseAdvancedOptions(request.getParameter("advancedOptions"), options);
  }

  SessionData session = new SessionData(options.challenge, rpId);

  session.save(userService.getCurrentUser().getUserId());
  JsonObject sessionJson = session.getJsonObject();
  JsonObject optionsJson = options.getJsonObject();
  optionsJson.add("session", sessionJson);

  response.setContentType("application/json");
  response.getWriter().println(optionsJson.toString());
}
 
开发者ID:google,项目名称:webauthndemo,代码行数:28,代码来源:BeginMakeCredential.java

示例7: getTokenInfo

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
public static OAuthTokenInfoResponse getTokenInfo(User user, String authorizedHeader) throws IOException {
    String token = authorizedHeader.substring(7);
    String tokenType;


    if(user.getUserId() == null) {
        //token is an id token
        tokenType = "id_token";
    } else {
        //token is an access token
        tokenType = "access_token";
    }

    URL url = new URL(GOOGLE_APIS_HOST + "/oauth2/v1/tokeninfo?" + tokenType + "=" + URLEncoder.encode(token, "UTF-8"));
    log.info("auth url:" + url);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    connection.setDoOutput(true);
    BufferedReader in = new BufferedReader(
            new InputStreamReader(connection.getInputStream()));
    String inputLine;
    StringBuffer response = new StringBuffer();
    while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
    }
    in.close();
    log.info("response:" + response);
    if(connection.getResponseCode() != 200) {
        throw new IOException("token info response from google returned" + connection.getResponseCode() + " with body: " + response);
    }

    OAuthTokenInfoResponse tokenInfo = gson.fromJson(response.toString(), OAuthTokenInfoResponse.class);
    return tokenInfo;
}
 
开发者ID:saucenet,项目名称:sync,代码行数:35,代码来源:Networker.java

示例8: ensureNewCryptonomicaUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
public static void ensureNewCryptonomicaUser(final User googleUser) throws Exception {
    ensureGoogleAuth(googleUser);
    String userId = googleUser.getUserId();
    Key<CryptonomicaUser> userKey = Key.create(CryptonomicaUser.class, userId);
    CryptonomicaUser cryptonomicaUser = null;
    cryptonomicaUser = ofy().load().key(userKey).now();
    if (cryptonomicaUser != null) {
        throw new Exception("user is already registered");
    }
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:11,代码来源:UserTools.java

示例9: validateUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Validation for User.
 *
 * @author <a href="mailto:[email protected]"> João Felipe de Medeiros Moreira </a>
 * @since 28/09/2015
 *
 * @param user to be validated
 * @param techUser to be validated
 *
 * @throws BadRequestException in case the params are not correct
 * @throws InternalServerErrorException in case of internal error
 */
private void validateUser(User user, TechGalleryUser techUser)
    throws BadRequestException, InternalServerErrorException {
  log.info("Validating user to recommend");

  if (user == null || user.getUserId() == null || user.getUserId().isEmpty()) {
    throw new BadRequestException(ValidationMessageEnums.USER_GOOGLE_ENDPOINT_NULL.message());
  }

  if (techUser == null) {
    throw new BadRequestException(ValidationMessageEnums.USER_NOT_EXIST.message());
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:25,代码来源:TechnologyRecommendationServiceImpl.java

示例10: validateUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Validate the user logged in.
 *
 * @param user info about user from google
 *
 * @throws BadRequestException in case a request with problem were made.
 * @throws InternalServerErrorException in case something goes wrong
 * @throws NotFoundException in case the information are not founded
 */
private void validateUser(User user)
    throws BadRequestException, NotFoundException, InternalServerErrorException {

  log.info("Validating user to comment");

  if (user == null || user.getUserId() == null || user.getUserId().isEmpty()) {
    throw new BadRequestException(ValidationMessageEnums.USER_GOOGLE_ENDPOINT_NULL.message());
  }

  final TechGalleryUser techUser = userService.getUserByGoogleId(user.getUserId());
  if (techUser == null) {
    throw new NotFoundException(ValidationMessageEnums.USER_NOT_EXIST.message());
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:24,代码来源:TechnologyCommentServiceImpl.java

示例11: validateUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Validate the user logged in.
 *
 * @param user info about user from google
 * @throws InternalServerErrorException in case something goes wrong
 * @throws NotFoundException in case the information are not founded
 * @throws BadRequestException in case a request with problem were made.
 */
private void validateUser(User user)
    throws BadRequestException, NotFoundException, InternalServerErrorException {

  if (user == null || user.getUserId() == null || user.getUserId().isEmpty()) {
    throw new BadRequestException(ValidationMessageEnums.USER_GOOGLE_ENDPOINT_NULL.message());
  }

  final TechGalleryUser techUser = userService.getUserByGoogleId(user.getUserId());
  if (techUser == null) {
    throw new NotFoundException(ValidationMessageEnums.USER_NOT_EXIST.message());
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:21,代码来源:RecommendationServiceImpl.java

示例12: validateUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Validate the user logged in.
 *
 * @param user info about user from google
 *
 * @throws BadRequestException in case a request with problem were made.
 * @throws InternalServerErrorException in case something goes wrong
 * @throws NotFoundException in case the information are not founded
 */
private void validateUser(User user)
    throws BadRequestException, NotFoundException, InternalServerErrorException {

  log.info("Validating user to link");

  if (user == null || user.getUserId() == null || user.getUserId().isEmpty()) {
    throw new BadRequestException(ValidationMessageEnums.USER_GOOGLE_ENDPOINT_NULL.message());
  }

  final TechGalleryUser techUser = userService.getUserByGoogleId(user.getUserId());
  if (techUser == null) {
    throw new NotFoundException(ValidationMessageEnums.USER_NOT_EXIST.message());
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:24,代码来源:TechnologyLinkServiceImpl.java

示例13: validateInputs

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Validate inputs of SkillResponse.
 *
 * @param skill inputs to be validate
 * @param user info about user from google
 *
 * @throws BadRequestException for the validations.
 * @throws InternalServerErrorException in case something goes wrong
 * @throws NotFoundException in case the information are not founded
 */
private void validateInputs(Skill skill, User user)
    throws BadRequestException, NotFoundException, InternalServerErrorException {

  log.info("Validating inputs of skill");

  if (user == null || user.getUserId() == null || user.getUserId().isEmpty()) {
    throw new BadRequestException(ValidationMessageEnums.USER_GOOGLE_ENDPOINT_NULL.message());
  }

  final TechGalleryUser techUser = userService.getUserByGoogleId(user.getUserId());
  if (techUser == null) {
    throw new BadRequestException(ValidationMessageEnums.USER_NOT_EXIST.message());
  }

  if (skill == null) {
    throw new BadRequestException(ValidationMessageEnums.SKILL_CANNOT_BLANK.message());
  }

  if (skill.getValue() == null || skill.getValue() < 0 || skill.getValue() > 5) {
    throw new BadRequestException(ValidationMessageEnums.SKILL_RANGE.message());
  }

  if (skill.getTechnology() == null) {
    throw new BadRequestException(ValidationMessageEnums.TECHNOLOGY_ID_CANNOT_BLANK.message());
  }

}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:38,代码来源:SkillServiceImpl.java

示例14: getUserSkill

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public Skill getUserSkill(String techId, User user) throws BadRequestException,
    OAuthRequestException, NotFoundException, InternalServerErrorException {
  // user google id
  String googleId;
  // user from techgallery datastore
  TechGalleryUser tgUser;
  // User from endpoint can't be null
  if (user == null) {
    throw new OAuthRequestException(i18n.t("OAuth error, null user reference!"));
  } else {
    googleId = user.getUserId();
  }

  // TechGalleryUser can't be null and must exists on datastore
  if (googleId == null || googleId.equals("")) {
    throw new BadRequestException(i18n.t("Current user was not found!"));
  } else {
    // get the TechGalleryUser from datastore or PEOPLE API
    tgUser = userService.getUserByGoogleId(googleId);
    if (tgUser == null) {
      throw new BadRequestException(i18n.t("Endorser user do not exists on datastore!"));
    }
  }

  // Technology can't be null
  final Technology technology = techService.getTechnologyById(techId, user);
  if (technology == null) {
    throw new BadRequestException(i18n.t("Technology do not exists!"));
  }
  final Skill userSkill = skillDao.findByUserAndTechnology(tgUser, technology);
  if (userSkill == null) {
    throw new NotFoundException(i18n.t("User skill do not exist!"));
  } else {
    return userSkill;
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:38,代码来源:SkillServiceImpl.java

示例15: validateUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public TechGalleryUser validateUser(User user)
    throws BadRequestException, NotFoundException, InternalServerErrorException {

  if (user == null || user.getUserId() == null || user.getUserId().isEmpty()) {
    throw new BadRequestException(ValidationMessageEnums.USER_GOOGLE_ENDPOINT_NULL.message());
  }

  final TechGalleryUser techUser = getUserByGoogleId(user.getUserId());
  if (techUser == null) {
    throw new NotFoundException(ValidationMessageEnums.USER_NOT_EXIST.message());
  }
  return techUser;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:15,代码来源:UserServiceTGImpl.java


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