@RequiresSession
  public UserEntity findUserByPrincipal(PrincipalEntity principal) {
    if (principal == null) {
      return null;
    }
    final TypedQuery<UserEntity> query = entityManagerProvider.get().createQuery("SELECT user_entity FROM UserEntity user_entity WHERE user_entity.principal.id=:principalId", UserEntity.class);
    query.setParameter("principalId", principal.getId());
    return daoUtils.selectSingle(query);
  }
Find the user entity for the given admin principal entity.

@param principal the principal entity
@return the matching user entity
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UserDAO.java