@ Nullable private static Identifiers handleIdentifiers ( String domainIdOrName , String projectIdOrName , String endpoint , String userId , String password ) { //we try all four cases and return the one that works Set < Identifiers > possibleIdentifiers = new HashSet < Identifiers > ( ) { { add ( new Identifiers ( Identifier . byName ( domainIdOrName ) , Identifier . byName ( projectIdOrName ) ) ) ; add ( new Identifiers ( Identifier . byId ( domainIdOrName ) , Identifier . byId ( projectIdOrName ) ) ) ; add ( new Identifiers ( Identifier . byId ( domainIdOrName ) , Identifier . byName ( projectIdOrName ) ) ) ; add ( new Identifiers ( Identifier . byName ( domainIdOrName ) , Identifier . byId ( projectIdOrName ) ) ) ; } } ; for ( Identifiers candidate : possibleIdentifiers ) { try { authenticate ( endpoint , userId , password , candidate . getDomain ( ) , candidate . getProject ( ) ) ; } catch ( AuthenticationException | ClientResponseException e ) { continue ; } return candidate ; } return null ; }
This method tries to determine if the authentication should happen by using the user provided information as domain ID or domain name resp . project ID or project name .