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


Java User类代码示例

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


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

示例1: sendTestSms

import com.google.appengine.api.users.User; //导入依赖的package包/类
@ApiMethod(
        name = "sendTestSms",
        path = "sendTestSms",
        httpMethod = ApiMethod.HttpMethod.POST
)
@SuppressWarnings("unused")
public StringWrapperObject sendTestSms(
        // final HttpServletRequest httpServletRequest,
        final User googleUser,
        final @Named("phoneNumber") String phoneNumber,
        final @Named("smsMessage") String smsMessage
        // see: https://cloud.google.com/appengine/docs/java/endpoints/exceptions
) throws UnauthorizedException, BadRequestException, NotFoundException, NumberParseException,
        IllegalArgumentException, TwilioRestException {

    /* --- Check authorization: */
    CryptonomicaUser cryptonomicaUser = UserTools.ensureCryptonomicaOfficer(googleUser);

    /* --- Send SMS */
    Message message = TwilioUtils.sendSms(phoneNumber, smsMessage);

    return new StringWrapperObject(message.toJSON());

}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:25,代码来源:OnlineVerificationAPI.java

示例2: 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

示例3: ensureCryptonomicaRegisteredUser

import com.google.appengine.api.users.User; //导入依赖的package包/类
public static CryptonomicaUser ensureCryptonomicaRegisteredUser(final User googleUser)
        throws UnauthorizedException {

    ensureGoogleAuth(googleUser);

    CryptonomicaUser cryptonomicaUser = null;
    try {
        cryptonomicaUser = ofy()
                .load()
                .key(Key.create(CryptonomicaUser.class, googleUser.getUserId()))
                .now();
    } catch (Exception e) {
        LOG.warning(e.getMessage());
    }

    if (cryptonomicaUser == null) {
        throw new UnauthorizedException("You are not registered on Cryptonomica server");
    }
    return cryptonomicaUser;
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:21,代码来源:UserTools.java

示例4: ensureNotaryOrCryptonomicaOfficer

import com.google.appengine.api.users.User; //导入依赖的package包/类
public static CryptonomicaUser ensureNotaryOrCryptonomicaOfficer(final User googleUser)
        throws UnauthorizedException {
    //
    CryptonomicaUser cryptonomicaUser = ensureCryptonomicaRegisteredUser(googleUser);
    //
    LOG.warning("cryptonomicaUser: ");
    LOG.warning(new Gson().toJson(cryptonomicaUser));

    // if (cryptonomicaOfficer == null && notary == null) {
    LOG.warning("cryptonomicaUser.getCryptonomicaOfficer(): " + cryptonomicaUser.getCryptonomicaOfficer());
    LOG.warning("cryptonomicaUser.getNotary(): " + cryptonomicaUser.getNotary());
    // if isCryptonomicaOfficer and isNotary are both false or null:
    if ((cryptonomicaUser.getCryptonomicaOfficer() == null || !cryptonomicaUser.getCryptonomicaOfficer())
            && (cryptonomicaUser.getNotary() == null || !cryptonomicaUser.getNotary())) {
        throw new UnauthorizedException("You are not a Notary or Cryptonomica officer");
    }
    return cryptonomicaUser;
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:19,代码来源:UserTools.java

示例5: newSharedProduct

import com.google.appengine.api.users.User; //导入依赖的package包/类
@POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void newSharedProduct(@FormParam("productID") String productID,
		@FormParam("productName") String productName,
		@Context HttpServletResponse servletResponse) throws Exception {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return;
	}

	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	Entity entity = new Entity("SharedList", productID);
	entity.setProperty("email", user.getEmail());
	entity.setProperty("productName", productName);
	entity.setProperty("sharedDate", new Date());
	datastore.put(entity);
	servletResponse.getWriter().println(productName + " has been added.");
	servletResponse.flushBuffer();
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:24,代码来源:Sharedlist.java

示例6: convertEmailAddressToGaeUserId

import com.google.appengine.api.users.User; //导入依赖的package包/类
/**
 * Converts an email address to a GAE user id.
 *
 * @return Numeric GAE user id (in String form), or null if email address has no GAE id
 */
public static String convertEmailAddressToGaeUserId(String emailAddress) {
  final GaeUserIdConverter gaeUserIdConverter = new GaeUserIdConverter();
  gaeUserIdConverter.id = allocateId();
  gaeUserIdConverter.user =
      new User(emailAddress, Splitter.on('@').splitToList(emailAddress).get(1));

  try {
    // Perform these operations in a transactionless context to avoid enlisting in some outer
    // transaction (if any).
    ofy().doTransactionless(() -> ofy().saveWithoutBackup().entity(gaeUserIdConverter).now());

    // The read must be done in its own transaction to avoid reading from the session cache.
    return ofy()
        .transactNew(() -> ofy().load().entity(gaeUserIdConverter).safe().user.getUserId());
  } finally {
    ofy().doTransactionless(() -> ofy().deleteWithoutBackup().entity(gaeUserIdConverter).now());
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:24,代码来源:GaeUserIdConverter.java

示例7: doGet

import com.google.appengine.api.users.User; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException, ServletException {

  UserService userService = UserServiceFactory.getUserService();
  if (userService.isUserLoggedIn()) {
    // Save the relevant profile info and store it in the session.
    User user = userService.getCurrentUser();
    req.getSession().setAttribute("userEmail", user.getEmail());
    req.getSession().setAttribute("userId", user.getUserId());

    String destination = (String) req.getSession().getAttribute("loginDestination");
    if (destination == null) {
      destination = "/books";
    }

    resp.sendRedirect(destination);
  } else {
    resp.sendRedirect(userService.createLoginURL("/login"));
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:22,代码来源:LoginServlet.java

示例8: createDocument

import com.google.appengine.api.users.User; //导入依赖的package包/类
/**
 * Code snippet for creating a Document.
 * @return Document Created document.
 */
public Document createDocument() {
  // [START create_document]
  User currentUser = UserServiceFactory.getUserService().getCurrentUser();
  String userEmail = currentUser == null ? "" : currentUser.getEmail();
  String userDomain = currentUser == null ? "" : currentUser.getAuthDomain();
  String myDocId = "PA6-5000";
  Document doc = Document.newBuilder()
      // Setting the document identifer is optional.
      // If omitted, the search service will create an identifier.
      .setId(myDocId)
      .addField(Field.newBuilder().setName("content").setText("the rain in spain"))
      .addField(Field.newBuilder().setName("email").setText(userEmail))
      .addField(Field.newBuilder().setName("domain").setAtom(userDomain))
      .addField(Field.newBuilder().setName("published").setDate(new Date()))
      .build();
  // [END create_document]
  return doc;
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:DocumentServlet.java

示例9: 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

示例10: unregister

import com.google.appengine.api.users.User; //导入依赖的package包/类
/**
 * Unregister a device
 * This will not remove a user
 *
 * @param deviceId The Google Cloud Messaging registration Id to remove
 * @param user     The Google Authenticated User
 */
@ApiMethod(
        name = "users.unregister",
        path = "users/unregister",
        httpMethod = HttpMethod.POST
)
public void unregister(@Named("deviceId") String deviceId, User user) throws OAuthRequestException, BadRequestException {
    UserRecord currentUser = userDAO.getUserRecord(user);
    if (currentUser == null) {
        throw new OAuthRequestException(Messages.ERROR_AUTH);
    }

    if (deviceId == null) {
        throw new BadRequestException(Messages.ERROR_INVALID_PARAMETERS);
    }

    for (String id : currentUser.getDevices()) {
        if (id.equals(deviceId)) {
            // found device - unregister it
            currentUser.removeDevice(id);
            userDAO.save(currentUser);
            return;
        }
    }
}
 
开发者ID:AndrewJack,项目名称:moment-for-android-wear,代码行数:32,代码来源:UserEndpoint.java

示例11: updateUserInformation

import com.google.appengine.api.users.User; //导入依赖的package包/类
/**
 * Updates current Tech Gallery user information with user data found on
 * Google.
 *
 * @param user
 *          Google user
 * @param person
 *          Google Plus person information
 * @param tgUser
 *          Tech Gallery user
 */
private void updateUserInformation(final User user, Person person, TechGalleryUser tgUser) {
  String plusEmail = user.getEmail();
  String plusPhoto = person.getImage().getUrl();
  String plusName = person.getDisplayName();

  String currentEmail = tgUser.getEmail();
  String currentPhoto = tgUser.getPhoto();
  String currentName = tgUser.getName();

  if (currentEmail == null || !currentEmail.equals(plusEmail)) {
    tgUser.setEmail(plusEmail);
  }
  if (currentPhoto == null || !currentPhoto.equals(plusPhoto)) {
    tgUser.setPhoto(plusPhoto);
  }
  if (currentName == null || !currentName.equals(plusName)) {
    tgUser.setName(plusName);
  }
  if (tgUser.getGoogleId() == null) {
    tgUser.setGoogleId(user.getUserId());
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:34,代码来源:UserServiceTGImpl.java

示例12: doGet

import com.google.appengine.api.users.User; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  if (req.getParameter("testing") == null) {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, this is a testing servlet. \n\n");
    Properties p = System.getProperties();
    p.list(resp.getWriter());

  } else {
    UserService userService = UserServiceFactory.getUserService();
    User currentUser = userService.getCurrentUser();

    if (currentUser != null) {
      resp.setContentType("text/plain");
      resp.getWriter().println("Hello, " + currentUser.getNickname());
    } else {
      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }
}
 
开发者ID:raghu-sannlingappa,项目名称:push-to-delploy,代码行数:22,代码来源:GuestbookServlet.java

示例13: PackageDetailPage

import com.google.appengine.api.users.User; //导入依赖的package包/类
/**
 * @param mode editing mode
 */
public PackageDetailPage(FormMode mode) {
    this.mode = mode;

    id = "";
    title = "";
    url = "";
    changelog = "";
    icon = "";
    description = "";
    comment = "";
    discoveryURL = "";
    discoveryRE = "";
    discoveryURLPattern = "";
    license = "";
    this.tags = new ArrayList<String>();
    screenshots = "";
    permissions = "";

    User u = UserServiceFactory.getUserService().getCurrentUser();
    this.params.put("modified", new Date().toString());
    this.params.put("modifiedBy", u == null ? "" : u.getEmail());
}
 
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:26,代码来源:PackageDetailPage.java

示例14: doGet

import com.google.appengine.api.users.User; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws IOException {
  if (req.getParameter("testing") == null) {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, this is a testing servlet. \n\n");
    Properties p = System.getProperties();
    p.list(resp.getWriter());

  } else {
    UserService userService = UserServiceFactory.getUserService();
    User currentUser = userService.getCurrentUser();

    if (currentUser != null) {
      resp.setContentType("text/plain");
      resp.getWriter().println("Hello, " + currentUser.getNickname());
    } else {
      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }
}
 
开发者ID:luisibanez,项目名称:running-with-zebras-101,代码行数:22,代码来源:GuestbookServlet.java

示例15: getEndorsementsByTech

import com.google.appengine.api.users.User; //导入依赖的package包/类
/**
 * GET for getting one endorsement.
 *
 * @throws InternalServerErrorException in case something goes wrong
 * @throws OAuthRequestException in case of authentication problem
 * @throws NotFoundException in case the information are not founded
 * @throws BadRequestException in case a request with problem were made.
 */
@Override
public Response getEndorsementsByTech(String techId, User user)
    throws InternalServerErrorException, BadRequestException, NotFoundException,
    OAuthRequestException {
  final List<Endorsement> endorsementsByTech = endorsementDao.findAllActivesByTechnology(techId);
  final List<EndorsementsGroupedByEndorsedTransient> grouped =
      groupEndorsementByEndorsed(endorsementsByTech, techId);
  final Technology technology = techService.getTechnologyById(techId, user);

  techService.updateEdorsedsCounter(technology, grouped.size());

  groupUsersWithSkill(grouped, technology);

  Collections.sort(grouped, new EndorsementsGroupedByEndorsedTransient());
  final ShowEndorsementsResponse response = new ShowEndorsementsResponse();
  response.setEndorsements(grouped);
  return response;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:27,代码来源:EndorsementServiceImpl.java


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