5050import java .util .Base64 ;
5151import java .util .EnumMap ;
5252import java .util .List ;
53+ import java .util .logging .Level ;
5354import java .util .logging .Logger ;
5455import java .util .Map ;
5556import java .util .concurrent .LinkedBlockingQueue ;
@@ -369,7 +370,7 @@ public final void handle(final HttpExchange exchange) throws IOException {
369370 }
370371 handlePost (exchange );
371372 } catch (final Exception e ) {
372- e . printStackTrace ( );
373+ logger . log ( Level . SEVERE , "unhandled error handling request" , e );
373374 exchange .sendResponseHeaders (500 , -1 );
374375 } finally {
375376 exchange .close ();
@@ -569,7 +570,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
569570 username = object .getString ("username" );
570571 password = object .getString ("password" );
571572 } catch (final ClassCastException | JsonException | NullPointerException e ) {
572- e . printStackTrace ( );
573+ logger . log ( Level . INFO , "invalid request" , e );
573574 exchange .sendResponseHeaders (400 , -1 );
574575 return ;
575576 }
@@ -580,7 +581,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
580581 exchange .sendResponseHeaders (409 , -1 );
581582 return ;
582583 } catch (final GeneralSecurityException e ) {
583- e . printStackTrace ( );
584+ logger . log ( Level . INFO , "invalid request" , e );
584585 exchange .sendResponseHeaders (400 , -1 );
585586 return ;
586587 }
@@ -600,7 +601,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
600601 currentPassword = object .getString ("currentPassword" );
601602 newPassword = object .getString ("newPassword" );
602603 } catch (final ClassCastException | JsonException | NullPointerException e ) {
603- e . printStackTrace ( );
604+ logger . log ( Level . INFO , "invalid request" , e );
604605 exchange .sendResponseHeaders (400 , -1 );
605606 return ;
606607 }
@@ -613,7 +614,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
613614 try {
614615 changePassword (account .userId , currentPassword , newPassword );
615616 } catch (final GeneralSecurityException e ) {
616- e . printStackTrace ( );
617+ logger . log ( Level . INFO , "invalid request" , e );
617618 exchange .sendResponseHeaders (400 , -1 );
618619 return ;
619620 }
@@ -631,7 +632,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
631632 username = object .getString ("username" );
632633 password = object .getString ("password" );
633634 } catch (final ClassCastException | JsonException | NullPointerException e ) {
634- e . printStackTrace ( );
635+ logger . log ( Level . INFO , "invalid request" , e );
635636 exchange .sendResponseHeaders (400 , -1 );
636637 return ;
637638 }
@@ -643,7 +644,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
643644 exchange .sendResponseHeaders (400 , -1 );
644645 return ;
645646 } catch (final GeneralSecurityException e ) {
646- e . printStackTrace ( );
647+ logger . log ( Level . INFO , "invalid login information" , e );
647648 exchange .sendResponseHeaders (403 , -1 );
648649 return ;
649650 }
@@ -917,7 +918,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
917918 alertDelay = object .getInt ("alertDelay" );
918919 email = object .getString ("email" ).trim ();
919920 } catch (final ClassCastException | JsonException | NullPointerException e ) {
920- e . printStackTrace ( );
921+ logger . log ( Level . INFO , "invalid request" , e );
921922 exchange .sendResponseHeaders (400 , -1 );
922923 return ;
923924 }
@@ -999,7 +1000,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
9991000 requestToken = object .getString ("requestToken" );
10001001 fingerprint = object .getString ("fingerprint" );
10011002 } catch (final ClassCastException | JsonException | NullPointerException e ) {
1002- e . printStackTrace ( );
1003+ logger . log ( Level . INFO , "invalid request" , e );
10031004 exchange .sendResponseHeaders (400 , -1 );
10041005 return ;
10051006 }
@@ -1168,7 +1169,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
11681169 writeAttestationHistoryJson (exchange , fingerprint , account , offsetId );
11691170 } catch (final ClassCastException | JsonException | NullPointerException | NumberFormatException |
11701171 DataFormatException | GeneralSecurityException e ) {
1171- e . printStackTrace ( );
1172+ logger . log ( Level . INFO , "invalid request" , e );
11721173 exchange .sendResponseHeaders (400 , -1 );
11731174 return ;
11741175 }
@@ -1300,7 +1301,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
13001301 try {
13011302 AttestationProtocol .verifySerialized (attestationResult , pendingChallenges , userId , subscribeKey == null );
13021303 } catch (final BufferUnderflowException | NegativeArraySizeException | DataFormatException | GeneralSecurityException | IOException e ) {
1303- e . printStackTrace ( );
1304+ logger . log ( Level . INFO , "invalid request" , e );
13041305 final byte [] response = "Error\n " .getBytes ();
13051306 exchange .sendResponseHeaders (400 , response .length );
13061307 try (final OutputStream output = exchange .getResponseBody ()) {
0 commit comments