protected UserAuthenticationEntity getAuthenticationEntity(UserEntity userEntity, UserAuthenticationType type) {
    Collection<UserAuthenticationEntity> authenticationEntities = (userEntity == null) ? null : userEntity.getAuthenticationEntities();
    if (authenticationEntities != null) {
      for (UserAuthenticationEntity authenticationEntity : authenticationEntities) {
        if (authenticationEntity.getAuthenticationType() == type) {
          return authenticationEntity;
        }
      }
    }

    return null;
  }
Finds the specific {@link UserAuthenticationEntity} 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 {@link UserAuthenticationEntity} if found; otherwise null
ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariAuthenticationProvider.java