private String generateTicket() {
    final StringBuilder builder = new StringBuilder();

    builder.append(getExternalId());
    builder.append(hashCode());

    final InstitutionAffiliationEvent event = getInstitutionAffiliationEvent();
    final Person person = event.getPerson();
    final User user = person.getUser();
    builder.append(user.getUserUId());
    builder.append(user.getExternalId());

    final DateTime instant = getGenerated();
    builder.append(instant.toString("yyyy-MM-dd HH:mm:ss"));

    return DigestUtils.shaHex(builder.toString());
  }
 private String getNickname(final User user) {
   return user == null ? "" : getNickname(user.getPerson());
 }
 private String getNickname(final String username) {
   return username == null || username.isEmpty()
       ? ""
       : getNickname(User.readUserByUserUId(username));
 }