AuthTokens { public static AuthToken kerberos( String base64EncodedTicket ) { Objects.requireNonNull( base64EncodedTicket, "Ticket can't be null" ); Map<String,Value> map = newHashMapWithSize( 3 ); map.put( SCHEME_KEY, value( "kerberos" ) ); map.put( PRINCIPAL_KEY, value( "" ) ); map.put( CREDENTIALS_KEY, value( base64EncodedTicket ) ); return new InternalAuthToken( map ); }  static AuthToken basic( String username, String password ); static AuthToken basic( String username, String password, String realm ); static AuthToken kerberos( String base64EncodedTicket ); static AuthToken custom( String principal, String credentials, String realm, String scheme); static AuthToken custom( String principal, String credentials, String realm, String scheme, Map<String, Object> parameters); static AuthToken none();  }
@Test void basicKerberosAuthWithRealm() { InternalAuthToken token = (InternalAuthToken) AuthTokens.kerberos( "base64" ); Map<String,Value> map = token.toMap(); assertThat( map.size(), equalTo( 3 ) ); assertThat( map.get( "scheme" ), equalTo( (Value) new StringValue( "kerberos" ) ) ); assertThat( map.get( "principal" ), equalTo( (Value) new StringValue( "" ) ) ); assertThat( map.get( "credentials" ), equalTo( (Value) new StringValue( "base64" ) ) ); }
@Test void shouldNotAllowKerberosAuthTokenWithNullTicket() { NullPointerException e = assertThrows( NullPointerException.class, () -> AuthTokens.kerberos( null ) ); assertEquals( "Ticket can't be null", e.getMessage() ); }