protected Collection<UserAuthenticationEntity> getAuthenticationEntities(UserEntity userEntity, UserAuthenticationType type) {
    Collection<UserAuthenticationEntity> foundAuthenticationEntities = null;

    Collection<UserAuthenticationEntity> authenticationEntities = (userEntity == null) ? null : userEntity.getAuthenticationEntities();
    if (authenticationEntities != null) {
      foundAuthenticationEntities = new ArrayList<>();
      for (UserAuthenticationEntity authenticationEntity : authenticationEntities) {
        if (authenticationEntity.getAuthenticationType() == type) {
          foundAuthenticationEntities.add(authenticationEntity);
        }
      }
    }

    return foundAuthenticationEntities;
  }
Finds the specific set of {@link UserAuthenticationEntity} instances from the collection of
authentication methods available to the specified {@link UserEntity}.

@param userEntity a {@link UserEntity}
@param type       the {@link UserAuthenticationType} to retrieve
@return a collection {@link UserAuthenticationEntity} if found; otherwise null
ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationProvider.java