org.neo4j.string.UTF8.encode()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中org.neo4j.string.UTF8.encode()方法的一些代码示例,展示了UTF8.encode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UTF8.encode()方法的具体详情如下:
包路径:org.neo4j.string.UTF8
类名称:UTF8
方法名:encode

UTF8.encode介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

@Override
public void writeString( String value )
{
  builder.append( base64Encoder.encodeToString( UTF8.encode( value ) ) );
  builder.append( '|' );
}

代码示例来源:origin: neo4j/neo4j

static Map<String,Object> newCustomAuthToken( String principle, String credentials, String realm, String scheme,
    Map<String,Object> parameters )
{
  return newCustomAuthToken( principle, UTF8.encode( credentials ), realm, scheme, parameters );
}

代码示例来源:origin: neo4j/neo4j

@Override
public void writeString( char value )
{
  writeStringBytes( UTF8.encode( String.valueOf( value ) ), true );
}

代码示例来源:origin: neo4j/neo4j

private LoginContext authenticate( String username, String password ) throws InvalidAuthTokenException
{
  AuthManager authManager = authManagerSupplier.get();
  Map<String,Object> authToken = newBasicAuthToken( username, password != null ? UTF8.encode( password ) : null );
  return authManager.login( authToken );
}

代码示例来源:origin: neo4j/neo4j

@Override
  public void write( Object value, FlushableChannel into ) throws IOException
  {
    byte[] bytes = UTF8.encode( (String)value );
    into.putInt( bytes.length ).put( bytes, bytes.length );
  }
} );

代码示例来源:origin: neo4j/neo4j

@Override
public boolean matchesPassword( String password )
{
  return byteEquals( passwordHash, hash( salt, UTF8.encode( password ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldMakeCustomAuthTokenAndBasicScheme()
{
  Map<String, Object> token = AuthToken.newCustomAuthToken( "me", "my secret", "my realm", "basic" );
  assertThat("Should have correct username", token.get(AuthToken.PRINCIPAL), equalTo("me"));
  assertThat( "Should have correct password", token.get( AuthToken.CREDENTIALS ), equalTo( UTF8.encode( "my secret" ) ) );
  assertThat("Should have correct scheme", token.get(AuthToken.SCHEME_KEY), equalTo(AuthToken.BASIC_SCHEME));
  assertThat("Should have correctno realm", token.get(AuthToken.REALM_KEY), equalTo( "my realm" ));
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldMakeCustomAuthTokenAndCustomcScheme()
{
  Map<String, Object> token = AuthToken.newCustomAuthToken( "me", "my secret", "my realm", "my scheme" );
  assertThat("Should have correct username", token.get(AuthToken.PRINCIPAL), equalTo("me"));
  assertThat( "Should have correct password", token.get( AuthToken.CREDENTIALS ), equalTo( UTF8.encode( "my secret" ) ) );
  assertThat("Should have correct scheme", token.get(AuthToken.SCHEME_KEY), equalTo("my scheme"));
  assertThat("Should have correct realm", token.get(AuthToken.REALM_KEY), equalTo( "my realm" ));
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldBeAbleToUpdateCredentials() throws Exception
{
  // When
  authentication.authenticate(
      map( "scheme", "basic", "principal", "mike", "credentials", UTF8.encode( "secret2" ),
          "new_credentials", UTF8.encode( "secret" ) ) );
  // Then
  authentication.authenticate( map( "scheme", "basic", "principal", "mike", "credentials", UTF8.encode( "secret" ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldBeAbleToUpdateExpiredCredentials() throws Exception
{
  // When
  AuthenticationResult result = authentication.authenticate(
      map( "scheme", "basic", "principal", "bob", "credentials", UTF8.encode( "secret" ), "new_credentials", UTF8.encode( "secret2" ) ) );
  // Then
  assertThat(result.credentialsExpired(), equalTo( false ));
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldIgnoreUnknownFields()
{
  // Given
  String json =  "{ \"statements\" : [ { \"a\" : \"\", \"b\" : { \"k\":1 }, \"statement\" : \"blah\" } ] }";
  // When
  StatementDeserializer de = new StatementDeserializer( new ByteArrayInputStream( UTF8.encode( json ) ) );
  // Then
  assertThat( de.hasNext(), equalTo( true ) );
  assertThat( de.next().statement(), equalTo( "blah" ) );
  assertThat( de.hasNext(), equalTo( false ) );
}

代码示例来源:origin: neo4j/neo4j

private File fileContaining( FileSystemAbstraction fs, String content ) throws IOException
  {
    File shortFile = directory.file( "file" );
    fs.deleteFile( shortFile );
    try ( OutputStream outputStream = fs.openAsOutputStream( shortFile, false ) )
    {
      outputStream.write( UTF8.encode( content ) );
      return shortFile;
    }
  }
}

代码示例来源:origin: neo4j/neo4j

static void changeVersionNumber( FileSystemAbstraction fileSystem, File storeFile, String versionString )
    throws IOException
{
  byte[] versionBytes = UTF8.encode( versionString );
  try ( StoreChannel fileChannel = fileSystem.open( storeFile, OpenMode.READ_WRITE ) )
  {
    fileChannel.position( fileSystem.getFileSize( storeFile ) - versionBytes.length );
    fileChannel.write( ByteBuffer.wrap( versionBytes ) );
  }
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldNotDoAnythingOnSuccess() throws Exception
{
  // When
  AuthenticationResult result =
      authentication.authenticate( map( "scheme", "basic", "principal", "mike", "credentials", UTF8.encode( "secret2" ) ) );
  // Then
  assertThat( result.getLoginContext().subject().username(), equalTo( "mike" ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldNotBeAbleToUpdateCredentialsIfOldCredentialsAreInvalid() throws Exception
{
  // Expect
  exception.expect( AuthenticationException.class );
  exception.expect( hasStatus( Status.Security.Unauthorized ) );
  exception.expectMessage( "The client is unauthorized due to authentication failure." );
  // When
  authentication.authenticate( map( "scheme", "basic", "principal", "bob", "credentials", UTF8.encode( "gelato" ),
      "new_credentials", UTF8.encode( "secret2" ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void newUserShouldBeAbleToChangePassword() throws Throwable
{
  // Given
  authManager.newUser( "andres", UTF8.encode( "banana" ), true );
  // Then
  assertEmpty( login("andres", "banana"), "CALL dbms.changePassword('abc')" );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void newUserShouldNotBeAbleToCallOtherProcedures() throws Throwable
{
  // Given
  authManager.newUser( "andres", UTF8.encode( "banana" ), true );
  LoginContext user = login("andres", "banana");
  // Then
  assertFail( user, "CALL dbms.procedures",
      "The credentials you provided were valid, but must be changed before you can use this instance." );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldFailOnMalformedToken() throws Exception
{
  // Expect
  exception.expect( AuthenticationException.class );
  exception.expect( hasStatus( Status.Security.Unauthorized ) );
  exception.expectMessage( "Unsupported authentication token, the value associated with the key `principal` " +
      "must be a String but was: SingletonList" );
  // When
  authentication
      .authenticate( map( "scheme", "basic", "principal", singletonList( "bob" ), "credentials", UTF8.encode( "secret" ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldThrowWithNoScheme() throws Exception
{
  // Expect
  exception.expect( AuthenticationException.class );
  exception.expect( hasStatus( Status.Security.Unauthorized ) );
  // When
  authentication.authenticate( map( "principal", "bob", "credentials", UTF8.encode( "secret" ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldReturnUsersWithFlags() throws Exception
{
  authManager.newUser( "andres", UTF8.encode( "123" ), false );
  Map<String,Object> expected = map(
      "neo4j", listOf( PWD_CHANGE ),
      "andres", listOf()
  );
  assertSuccess( admin, "CALL dbms.security.listUsers()",
      r -> assertKeyIsMap( r, "username", "flags", expected ) );
}

相关文章

微信公众号

最新文章

更多