Skip to content

Commit

Permalink
Deprecated refactored ClientUtils functions
Browse files Browse the repository at this point in the history
  • Loading branch information
masomel committed Aug 14, 2016
1 parent 3bfba86 commit f82da34
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ public class ServerUtils{

/** The maximum number of bytes logged per log file.
*
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static final int MAX_BYTES_LOGGED_PER_FILE = (1 << 15);

/** The maximum number of log files per log.
*
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static final int MAX_NUM_LOG_FILES = 5;
Expand All @@ -106,7 +106,7 @@ public class ServerUtils{
*@param isErr indicates whether this is an error message
*@param msg the status message to print
*
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static void printStatusMsg (boolean isErr, String msg) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public static byte[] hashChildren(byte[] left, byte[] right){
* of its hexadecimal representation.
*
*@return The hex representation of {@code bytes} as a String.
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static String bytesToHex(byte[] bytes) {
Expand All @@ -194,7 +194,7 @@ public static String bytesToHex(byte[] bytes) {

/** Converts a UTF-8 String {@code str} to an array of bytes.
*
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static byte[] strToBytes (String str) {
Expand All @@ -216,7 +216,7 @@ public static byte[] unameToIndex (String uname){
/** Converts a long {@code val} into an array of bytes.
*
*@return The {@code byte[]} representation of the long value.
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static byte[] longToBytes(long val) {
Expand All @@ -234,7 +234,7 @@ public static byte[] longToBytes(long val) {
* at offset {@code offset}, and determines whether it is 1 or 0.
*
*@return true if the nth bit is 1, false otherwise.
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static boolean getNthBit(byte[] arr, int offset){
Expand All @@ -248,7 +248,7 @@ public static boolean getNthBit(byte[] arr, int offset){
*
*@return the first 16 bits of {@code arr} or all zeros if the length
* of the array is less than 2 bytes.
*@deprecated Moved to {@link org.coniks.util.Util}.
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static byte[] getPrefixBytes(byte[] arr){
Expand Down
7 changes: 7 additions & 0 deletions coniks_test_client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.coniks.util</groupId>
<artifactId>coniks-util</artifactId>
<version>1.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
import java.util.logging.Level;
import java.io.IOException;

// coniks-java imports
import org.coniks.util.Convert;

/** Implements the logger used for a CONIKS client.
*
*@author Marcela S. Melara (melara@cs.princeton.edu)
Expand All @@ -61,8 +64,8 @@ public static void setup (String clientLog) {

try {
FileHandler handler = new FileHandler(clientLog,
ClientUtils.MAX_BYTES_LOGGED_PER_FILE,
ClientUtils.MAX_NUM_LOG_FILES, true);
Convert.MAX_BYTES_LOGGED_PER_FILE,
Convert.MAX_NUM_LOG_FILES, true);

// create a TXT formatter
SimpleFormatter fmt = new SimpleFormatter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,25 @@ public class ClientUtils{
public static final int SIG_SIZE_BYTES = 256;

/** The maximum number of bytes logged per log file.
*
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static final int MAX_BYTES_LOGGED_PER_FILE = (1 << 15);

/** The maximum number of log files per log.
*
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static final int MAX_NUM_LOG_FILES = 5;

/** Indicates a generic internal client error.
*/
// TODO: is this where it makes most sense to put this?
public static final int INTERNAL_CLIENT_ERR = 1;

@Deprecated
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();

/** Generates the cryptographic hash of {@code input}.
Expand Down Expand Up @@ -158,12 +165,15 @@ public static byte[] hashChildren(byte[] left, byte[] right){

}

// from Stackoverflow 9655181
/** Converts a {@code byte[]} into a String
* of its hexadecimal representation.
*
*@return The hex representation of {@code bytes} as a String.
*
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
// from Stackoverflow 9655181
@Deprecated
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ ) {
Expand All @@ -175,7 +185,10 @@ public static String bytesToHex(byte[] bytes) {
}

/** Converts a UTF-8 String {@code str} to an array of bytes.
*
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static byte[] strToBytes (String str) {
return str.getBytes(Charset.forName("UTF-8"));
}
Expand All @@ -195,7 +208,10 @@ public static byte[] unameToIndex (String username){
/** Converts a long {@code val} into an array of bytes.
*
*@return The {@code byte[]} representation of the long value.
*
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static byte[] longToBytes(long val) {
byte[] byteArr = new byte[8];

Expand All @@ -211,7 +227,10 @@ public static byte[] longToBytes(long val) {
* at offset {@code offset}, and determines whether it is 1 or 0.
*
*@return true if the nth bit is 1, false otherwise.
*
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static boolean getNthBit(byte[] arr, int offset){
int arrayOffset = offset / 8;
int bitOfByte = offset % 8;
Expand All @@ -223,7 +242,10 @@ public static boolean getNthBit(byte[] arr, int offset){
*
*@return the first 16 bits of {@code arr} or all zeros if the length
* of the array is less than 2 bytes.
*
*@deprecated Moved to {@link org.coniks.util.Convert}.
*/
@Deprecated
public static byte[] getPrefixBytes(byte[] arr){
byte[] out = new byte[2];

Expand All @@ -242,7 +264,9 @@ public static byte[] getPrefixBytes(byte[] arr){
/** Compares two byte buffers for byte-by-byte equality.
*
*@return true if the buffers are identical, false otherwise.
*@deprecated Use {@link java.util.Arrays#equals(byte[], byte[])}
*/
@Deprecated
public static boolean compareByteBuffers(byte[] buf1, byte[] buf2){
if (buf1.length != buf2.length) {
return false;
Expand Down

0 comments on commit f82da34

Please sign in to comment.