Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update auth in Neo4j Server to remove token
Authentication is now applied directly on all endpoint calls
- Loading branch information
Showing
46 changed files
with
1,745 additions
and
2,294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
217 changes: 0 additions & 217 deletions
217
community/kernel/src/main/java/org/neo4j/kernel/impl/util/BytePrinter.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
community/kernel/src/main/java/org/neo4j/kernel/impl/util/Codecs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2002-2015 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.util; | ||
|
||
public class Codecs | ||
{ | ||
final private static char[] hexArray = "0123456789ABCDEF".toCharArray(); | ||
|
||
/** | ||
* Converts a byte array to a hexadecimal string. | ||
* | ||
* @param bytes Bytes to be encoded | ||
* @return A string of hex characters [0-9A-F] | ||
*/ | ||
public static String encodeHexString( byte[] bytes ) | ||
{ | ||
char[] hexChars = new char[bytes.length * 2]; | ||
for ( int j = 0; j < bytes.length; j++ ) | ||
{ | ||
int v = bytes[j] & 0xFF; | ||
hexChars[j * 2] = hexArray[v >>> 4]; | ||
hexChars[j * 2 + 1] = hexArray[v & 0x0F]; | ||
} | ||
return new String( hexChars ); | ||
} | ||
|
||
/** | ||
* Converts a hexadecimal string to a byte array | ||
* | ||
* @param hexString A string of hexadecimal characters [0-9A-Fa-f] to decode | ||
* @return Decoded bytes, or null if the {@param hexString} is not valid | ||
*/ | ||
public static byte[] decodeHexString( String hexString ) | ||
{ | ||
int len = hexString.length(); | ||
byte[] data = new byte[len / 2]; | ||
for ( int i = 0, j = 0; i < len; i += 2, j++ ) | ||
{ | ||
int highByte = Character.digit( hexString.charAt( i ), 16 ) << 4; | ||
int lowByte = Character.digit( hexString.charAt( i + 1 ), 16 ); | ||
if ( highByte < 0 || lowByte < 0 ) | ||
{ | ||
return null; | ||
} | ||
data[j] = (byte) ( highByte + lowByte ); | ||
} | ||
return data; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
community/kernel/src/test/java/org/neo4j/kernel/impl/util/CodecsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright (c) 2002-2015 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.util; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class CodecsTest | ||
{ | ||
@Test | ||
public void shouldEncodeBytesToString() | ||
{ | ||
String result = Codecs.encodeHexString( new byte[]{(byte) 0xFF, (byte) 0x94, (byte) 0x5C, (byte) 0x00, (byte) 0x3D} ); | ||
assertEquals( "FF945C003D", result ); | ||
} | ||
|
||
@Test | ||
public void shouldEncodeEmptyBytesToEmptyString() | ||
{ | ||
String result = Codecs.encodeHexString( new byte[]{} ); | ||
assertEquals( "", result ); | ||
} | ||
|
||
@Test | ||
public void shouldDecodeStringToBytes() | ||
{ | ||
byte[] result = Codecs.decodeHexString( "00f34CEFFF3e02" ); | ||
byte[] expected = new byte[] {(byte) 0x00, (byte) 0xF3, (byte) 0x4C, (byte) 0xEF, (byte) 0xFF, (byte) 0x3E, (byte) 0x02 }; | ||
assertArrayEquals( expected, result ); | ||
} | ||
|
||
@Test | ||
public void shouldDecodeEmptyStringToEmptyBytes() | ||
{ | ||
byte[] result = Codecs.decodeHexString( "" ); | ||
assertArrayEquals( new byte[]{}, result ); | ||
} | ||
} |
Oops, something went wrong.