java类org.hibernate.validator.constraints.Email的实例源码

MailServiceImpl.java 文件源码 项目:REST-Web-Services 阅读 40 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithUsername(
        @NotBlank @Email final String email,
        @NotBlank final String username
) {
    log.info("Called with e-mail {}, username {}", email, username);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Recover username");
        helper.setText("Your username: " + "<b>" + username + "</b>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
MailServiceImpl.java 文件源码 项目:REST-Web-Services 阅读 35 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithNewPassword(
        @NotBlank @Email final String email,
        @NotBlank final String newPassword
) {
    log.info("Called with e-mail {}, newPassword {}", email, newPassword);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Recover password");
        helper.setText("Your new password: " + "<b>" + newPassword + "</b>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
OrganisationApi.java 文件源码 项目:GamificationEngine-Kinben 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Creates a new organisation. The email address and password of one Account are used 
 * to connect it with this organisation. So the email address and password are mandatory for
 * authentication otherwise a warning with the hint for wrong credentials is returned.
 * All further Accounts which should be associated to this organisation are added with the 
 * method addManager. 
 * In the response the account's password isn't returned because of security reasons.
 *
 * @param name 
 *          The name of the developer or the manager of the account.
 * @param email
 *           The required valid email address.
 * @param password
 *           Required header parameter associated with the email address.
 * @return A Response of Organisation in JSON.
 */
@POST
@Path("/")
@TypeHint(Organisation.class)
public Response create(@QueryParam("name") String name, @QueryParam("email") @NotNull @Email String email,
        @HeaderParam("password") @NotNull String password) {

    LOGGER.debug("create organisation requested");

    String encryptedPassword = SecurityTools.encryptWithSHA512(password);
    if (!accountDao.checkCredentials(email, encryptedPassword)) {
        throw new CredentialException(email);
    }

    Organisation organisation = new Organisation(name);
    organisation.addManager(accountDao.getAccount(email, encryptedPassword));
    organisation.setApiKey(SecurityTools.generateApiKey());

    LOGGER.debug("Organisation created");

    organisationDao.insertOrganisation(organisation);
    return ResponseSurrogate.created(organisation);
}
OrganisationApi.java 文件源码 项目:GamificationEngine-Kinben 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Returns a specific organisation which id is equal to the transfered path parameter. 
 * Additionally the email address and the associated password are mandatory and have to be
 * correct otherwise an exception is returned that the given credentials are wrong.
 * In the response the account's password isn't returned because of security reasons.
 * 
 * @param id
 *            The path parameter of the organisation, that should be returned.
 * @param email
 *            The valid email address.
 * @param password
 *             Required header parameter to connect it with the given 
 *             email address.
 * @return A response of Organisation in JSON.
 */
@GET
@Path("/{id}")
@TypeHint(Organisation.class)
public Response get(@PathParam("id") @NotNull String id, @QueryParam("email") @NotNull @Email String email, 
        @HeaderParam("password") @NotNull String password) {

    LOGGER.debug("get organisation requested");

    if (!accountDao.checkCredentials(email, SecurityTools.encryptWithSHA512(password))) {
        throw new CredentialException(email);
    }

    int intId = Integer.parseInt(id);
    Organisation organisation = organisationDao.getOrganisation(intId);
    return ResponseSurrogate.of(organisation);
}
OrganisationApi.java 文件源码 项目:GamificationEngine-Kinben 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Generates an API key for the given organisation which matches the id, email address and the
 * associated password. Otherwise an exception is returned that the given credentials are wrong.
 * If the API key field is already set the method resets it and replaced it with the new generated
 * API key.  
 * In the response the account's password isn't returned because of security reasons.
 * 
 * @param id
 *            The path parameter of the organisation, for which the API key should be generated.
 * @param email
 *           The valid email address. 
 * @param password
 *            Required header parameter to connect it with the given email address.
 * @return A Response of Organisation in JSON.
 */
@PUT
@Path("/{id}/generateapikey")
@TypeHint(Organisation.class)
public Response generateApiKey(@PathParam("id") @NotNull String id, @QueryParam("email") @Email String email,
        @HeaderParam("password") @NotNull String password) {

    Notification notification = new Notification();

    LOGGER.debug("generate api key requested");
    if (!accountDao.checkCredentials(email, SecurityTools.encryptWithSHA512(password))) {
        throw new CredentialException(email);
    }

    int intId = Integer.parseInt(id);
    Organisation organisation = organisationDao.getOrganisation(intId);
    organisation.setApiKey(SecurityTools.generateApiKey());

    return ResponseSurrogate.updated(organisation, notification);
}
AccountApi.java 文件源码 项目:GamificationEngine-Kinben 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Creates a new account. For this an unique email address and a 
 * password are mandatory. By the creation of an organisation this 
 * email address is connected with it. Optionally the first and last
 * name can also be set.
 * In the response the password isn't returned because of security 
 * reasons.
 *
 * @param email
 *            A required valid email address. 
 * @param password
 *            Required query parameter to connect it with the given 
 *            email address.
 * @param firstName
 *            Optionally the first name of the Account's owner can be set.
 * @param lastName
 *            Optionally the last name of the Account's owner can be set.
 * @return A Response of Account in JSON.
 */
@POST
@Path("/")
@TypeHint(Account.class)
public Response create(@QueryParam("email") @NotNull @Email String email, @QueryParam("password") @NotNull String password,
        @QueryParam("firstName") String firstName, @QueryParam("lastName") String lastName) {

    LOGGER.debug("create account requested");

    if(accountDao.getAccount(email)!=null){
        throw new ApiError(Response.Status.FORBIDDEN, "This mail address is already used.");
    }

    Account account = new Account(email);
    account.setPassword(SecurityTools.encryptWithSHA512(password));
    account.setFirstName(firstName);
    account.setLastName(lastName);
    accountDao.persist(account);

    LOGGER.debug("Persisted account: %s", account);
    return ResponseSurrogate.created(account);
}
AccountApi.java 文件源码 项目:GamificationEngine-Kinben 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Returns an account corresponding to the given email address but only
 * if the combination with password is correct. By the creation of an 
 * organisation this email address is connected with it. 
 * So the method requires valid credentials otherwise a warning with the 
 * hint for wrong credentials is returned.
 * In the response the password isn't returned because of security 
 * reasons.
 *
 * @param email
 *            A required valid unique email address.
 * @param password
 *            Required header parameter associated with the email address. 
 * @return A Response of Account in JSON.
 */
@GET
@Path("/")
@TypeHint(Account.class)
public Response get(@QueryParam("email") @NotNull @Email String email, @HeaderParam("password") @NotNull String password) {

    LOGGER.debug("get account requested");

    String encryptedPassword = SecurityTools.encryptWithSHA512(password);

    if (!accountDao.checkCredentials(email, encryptedPassword)) {
        LOGGER.warn("Account with wrong credentials (email:\"%s\", pass:\"%s\") requested", email, password);
        throw new CredentialException(email);
    }

    Account account = accountDao.getAccount(email, encryptedPassword);
    LOGGER.debug("Account requested: %s", account);
    return ResponseSurrogate.of(account);
}
AccountApi.java 文件源码 项目:GamificationEngine-Kinben 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Updates the first and last name of an existing account. For this the 
 * specific email address and associated password are mandatory.
 * Otherwise a warning with the hint for wrong credentials is returned.
 * In the response the password isn't returned because of security 
 * reasons.
 *
 * @param email
 *            A required valid email address. 
 * @param password
 *            Required header parameter to connect it with the given 
 *            email address.
 * @param firstName
 *            Optionally the first name of the Account's owner can be set.
 * @param lastName
 *            Optionally the last name of the Account's owner can be set.
 * 
 * @return A Response of Account in JSON.
 */
@PUT
@Path("/")
@TypeHint(Account.class)
public Response update(@QueryParam("email") @NotNull @Email String email, @HeaderParam("password") @NotNull String password,
        @QueryParam("firstName") String firstName, @QueryParam("lastName") String lastName) {

    LOGGER.debug("update account requested");

    String encryptedPassword = SecurityTools.encryptWithSHA512(password);
    if (!accountDao.checkCredentials(email, encryptedPassword)) {
        LOGGER.warn("Account with wrong credentials (email:\"%s\", pass:\"%s\") requested", email, password);
        throw new CredentialException(email);
    }

    Account account = accountDao.getAccount(email, encryptedPassword);
    Optional.ofNullable(encryptedPassword).ifPresent(account::setPassword);
    Optional.ofNullable(firstName).ifPresent(account::setFirstName);
    Optional.ofNullable(lastName).ifPresent(account::setLastName);
    accountDao.persist(account);

    LOGGER.debug("Updated account: %s", account);
    return ResponseSurrogate.updated(account);
}
TestObject.java 文件源码 项目:nest-old 阅读 46 收藏 0 点赞 0 评论 0
@Test
public void testEmail() {
    Set<ConstraintViolation<ObjectWithValidation>> violations = validator.validate(obj, Email.class);
    assertNotNull(violations);
    assertEquals(violations.size(), 1);

    if (runPeformance) {
        long time = System.currentTimeMillis();
        for (int index = 0; index < 10000; index++) {
            validator.validate(obj, Email.class);
        }
        long used = System.currentTimeMillis() - time;
        System.out.println("Hibernate Validator [Email] check used " + used + "ms, avg. " + ((double) used) / 10000
                + "ms.");
    }
}
Html5InputTag.java 文件源码 项目:spring-mvc-toolkit 阅读 41 收藏 0 点赞 0 评论 0
@Override
protected String getType()  {
    String type = javaToHtmlTypes.get(valueType);
    if (type != null) {
        return type;
    }
    type = "text";
    if (annotations != null) {
        if (annotations.containsKey(Email.class)) {
            type = "email";
        } else if (annotations.containsKey(URL.class)) {
            type = "url";
        } else if (annotations.containsKey(Max.class) || annotations.containsKey(Min.class)) {
            type = "number";
        }
    }
    return type;
}
UserSearchServiceImpl.java 文件源码 项目:REST-Web-Services 阅读 36 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Override
public User getUserByEmail(
        @NotBlank @Email final String email
) throws ResourceNotFoundException {
    log.info("Called with email {}", email);

    return this.userRepository.findByEmailIgnoreCaseAndEnabledTrue(email)
            .map(ServiceUtils::toUserDto)
            .orElseThrow(() -> new ResourceNotFoundException("No user found with e-mail " + email));
}
UserSearchServiceImpl.java 文件源码 项目:REST-Web-Services 阅读 42 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Override
public boolean existsUserByEmail(
        @NotBlank @Email final String email
) {
    log.info("Called with email {}", email);

    return this.userRepository.existsByEmailIgnoreCase(email);
}
MailServiceImpl.java 文件源码 项目:REST-Web-Services 阅读 41 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithActivationToken(
        @NotBlank @Email final String email,
        @NotBlank final String token
) {
    log.info("Called with e-mail {}, token {}", email, token);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Complete registration");
        helper.setText("To activation your account, click the link below:<br />"
                + "<a href='" + "https://localhost:8443" + "/register/thanks?token=" + token + "'>" +
                "Click here to complete your registration" +
                "</a>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
MailServiceImpl.java 文件源码 项目:REST-Web-Services 阅读 41 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithEmailChangeToken(
        @NotBlank @Email final String email,
        @NotBlank final String token
) {
    log.info("Called with e-mail {}, token {}", email, token);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Change e-mail");
        helper.setText("Change e-mail address, click the link below:<br />"
                + "<a href='" + "https://localhost:8443" + "/settings/changeEmail/thanks?token=" + token + "'>" +
                "Click here to complete the change of your e-mail" +
                "</a>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
UserTest.java 文件源码 项目:SECP 阅读 50 收藏 0 点赞 0 评论 0
@Test
public void testEmail() {
    AssertAnnotations.assertField( User.class, "email", Column.class, Email.class);

    Column c = ReflectTool.getFieldAnnotation(User.class, "email", Column.class);

    assertEquals("column email:  name is not equal", "email", c.name());
    assertEquals("column email: unique is false", true, c.unique());
    assertEquals("column email: nullable is true", false, c.nullable());
}
UserResource.java 文件源码 项目:gitplex-mit 阅读 42 收藏 0 点赞 0 评论 0
@ValidQueryParams
@GET
public Collection<User> query(@QueryParam("name") String name, @Email @QueryParam("email") String email) {
    if (!SecurityUtils.canAccessPublic())
        throw new UnauthorizedException("Unauthorized access to user profiles");
    EntityCriteria<User> criteria = EntityCriteria.of(User.class);
    if (name != null)
        criteria.add(Restrictions.eq("name", name));
    if (email != null)
        criteria.add(Restrictions.eq("email", email));
    return userManager.findAll(criteria);
}
EmailValidator.java 文件源码 项目:GPigValidator 阅读 36 收藏 0 点赞 0 评论 0
private boolean areWrongPreconditions(Object objectValue, Annotation annotation) {
    if (objectValue == null)
        return true;
    if (!(annotation instanceof Email))
        throw new WrongAnnotationTypeException();

    return false;
}
ValidatorTest.java 文件源码 项目:GPigValidator 阅读 108 收藏 0 点赞 0 评论 0
private void mockEmailValidator() throws Exception {
    emailValidator = mock(EmailValidator.class);

    whenNew(EmailValidator.class)
            .withAnyArguments()
            .thenReturn(emailValidator);

    when(emailValidator.getAnnotationType())
            .thenReturn(Email.class);
}
MessageService.java 文件源码 项目:holdmail 阅读 39 收藏 0 点赞 0 评论 0
public MessageList findMessages(@Null @Email String recipientEmail, Pageable pageRequest) {

        List<MessageEntity> entities;

        if (StringUtils.isBlank(recipientEmail)) {
            entities = messageRepository.findAllByOrderByReceivedDateDesc(pageRequest);
        }
        else {
            entities = messageRepository.findAllForRecipientOrderByReceivedDateDesc(recipientEmail, pageRequest);
        }

        return messageListMapper.toMessageList(entities);
    }
MessageController.java 文件源码 项目:holdmail 阅读 41 收藏 0 点赞 0 评论 0
@RequestMapping()
public MessageList getMessages(
        @RequestParam(name = "recipient", required = false) @Email String recipientEmail,
        Pageable pageRequest) {

    return messageService.findMessages(recipientEmail, pageRequest);
}
Usuario.java 文件源码 项目:webpedidos 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Retorna o endereço de e-mail.
 * 
 * @return o endereço de e-mail armazenado no campo email.
 */
@NotBlank
@Email
@Column(nullable = false, length = 254)
// @Column(nullable = false, length = 254, unique = true)
public String getEmail() {
    return this.email;
}
Member.java 文件源码 项目:my-paper 阅读 44 收藏 0 点赞 0 评论 0
/**
 * 获取E-mail
 * 
 * @return E-mail
 */
@NotEmpty
@Email
@Length(max = 200)
@Column(nullable = false)
public String getEmail() {
    return email;
}
Admin.java 文件源码 项目:my-paper 阅读 47 收藏 0 点赞 0 评论 0
/**
 * 获取E-mail
 * 
 * @return E-mail
 */
@NotEmpty
@Email
@Length(max = 200)
@Column(nullable = false)
public String getEmail() {
    return email;
}
ProductNotify.java 文件源码 项目:my-paper 阅读 35 收藏 0 点赞 0 评论 0
/**
 * 获取E-mail
 * 
 * @return E-mail
 */
@NotEmpty
@Email
@Length(max = 200)
@Column(nullable = false, updatable = false)
public String getEmail() {
    return email;
}
Setting.java 文件源码 项目:my-paper 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 获取发件人邮箱
 * 
 * @return 发件人邮箱
 */
@NotEmpty
@Email
@Length(max = 200)
public String getSmtpFromMail() {
    return smtpFromMail;
}
PessoaVO.java 文件源码 项目:omr 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 
 * @return
 */
@NotBlank(message="Email não pode ser branco",groups=VGroupUsuario.class)
@Email(message="E-mail inválido",groups=VGroupUsuario.class)
@JazzProp(name="E-mail", stereotype=PropertyStereotype.EMAIL)
public String getEmail() { 
    return email;
}
Pessoa2VO.java 文件源码 项目:omr 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 
 * @return
 */
//@NotBlank(message="Email não pode ser branco",groups=VGroupUsuario.class)
//@Email(message="E-mail inválido",groups=VGroupUsuario.class)
@JazzProp(name="E-mail", stereotype=PropertyStereotype.EMAIL)
@Email(message="Email inválido!")
@NotBlank(message="Email não pode ficar em branco")
public String getEmail() { 
    return email;
}
PessoaVO.java 文件源码 项目:omr 阅读 40 收藏 0 点赞 0 评论 0
/**
 * 
 * @return
 */
//@NotBlank(message="Email não pode ser branco",groups=VGroupUsuario.class)
//@Email(message="E-mail inválido",groups=VGroupUsuario.class)
@JazzProp(name="E-mail", stereotype=PropertyStereotype.EMAIL)
@Email(message="Email inválido!")
@NotBlank(message="Email não pode ficar em branco")
public String getEmail() { 
    return email;
}
PessoaVO.java 文件源码 项目:omr 阅读 43 收藏 0 点赞 0 评论 0
/**
 * 
 * @return
 */
@NotBlank(message="Email não pode ser branco",groups=VGroupUsuario.class)
@Email(message="E-mail inválido",groups=VGroupUsuario.class)
@JazzProp(name="E-mail", stereotype=PropertyStereotype.EMAIL)
public String getEmail() { 
    return email;
}
PessoaVO.java 文件源码 项目:omr 阅读 38 收藏 0 点赞 0 评论 0
/**
 * 
 * @return
 */
@NotBlank(message="Email não pode ser branco",groups=VGroupUsuario.class)
@Email(message="E-mail inválido",groups=VGroupUsuario.class)
@JazzProp(name="E-mail", stereotype=PropertyStereotype.EMAIL)
public String getEmail() { 
    return email;
}


问题


面经


文章

微信
公众号

扫码关注公众号