88import java .io .FileNotFoundException ;
99import java .io .IOException ;
1010import java .util .Scanner ;
11- import java .util .logging .Level ;
12- import java .util .logging .Logger ;
1311
1412final class AuthenticationExample {
15- private static final Logger LOGGER = Logger .getLogger (AuthenticationExample .class .getName ());
1613
1714 private static final String SERVICE_ACCOUNT_KEY_PATH = "/path/to/sa_key.json" ;
1815 private static final String PRIVATE_KEY_PATH = "/path/to/private_key.pem" ;
1916 private static final String SERVICE_ACCOUNT_MAIL = "name-1234@sa.stackit.cloud" ;
2017
21- @ SuppressWarnings ({"PMD.CyclomaticComplexity" , "PMD.NPathComplexity" })
18+ @ SuppressWarnings ({"PMD.CyclomaticComplexity" , "PMD.NPathComplexity" , "PMD.SystemPrintln" })
2219 public static void main (String [] args ) {
2320 /* OPTION 1: setting the paths to service account key (and private key) as configuration */
2421 try {
@@ -33,9 +30,7 @@ public static void main(String[] args) {
3330 ListOrganizationsResponse response =
3431 api .listOrganizations (null , SERVICE_ACCOUNT_MAIL , null , null , null );
3532
36- if (LOGGER .isLoggable (Level .INFO )) {
37- LOGGER .info (response .toString ());
38- }
33+ System .out .println (response .toString ());
3934 } catch (ApiException | IOException e ) {
4035 throw new IllegalStateException (e );
4136 }
@@ -57,9 +52,7 @@ public static void main(String[] args) {
5752 serviceAccountKeyContent .append (myReader .nextLine ());
5853 }
5954 } catch (FileNotFoundException e ) {
60- if (LOGGER .isLoggable (Level .SEVERE )) {
61- LOGGER .severe ("File not found: " + serviceAccountKeyPath );
62- }
55+ System .err .println ("File not found: " + serviceAccountKeyPath );
6356 return ;
6457 }
6558
@@ -72,9 +65,7 @@ public static void main(String[] args) {
7265 privateKeyContent .append (myReader .nextLine ());
7366 }
7467 } catch (FileNotFoundException e ) {
75- if (LOGGER .isLoggable (Level .SEVERE )) {
76- LOGGER .severe ("File not found: " + privateKeyPath );
77- }
68+ System .err .println ("File not found: " + privateKeyPath );
7869 return ;
7970 }
8071
@@ -93,9 +84,7 @@ public static void main(String[] args) {
9384 ListOrganizationsResponse response =
9485 api .listOrganizations (null , SERVICE_ACCOUNT_MAIL , null , null , null );
9586
96- if (LOGGER .isLoggable (Level .INFO )) {
97- LOGGER .info (response .toString ());
98- }
87+ System .out .println (response .toString ());
9988 } catch (ApiException | IOException e ) {
10089 throw new IllegalStateException (e );
10190 }
@@ -132,9 +121,7 @@ public static void main(String[] args) {
132121 ListOrganizationsResponse response =
133122 api .listOrganizations (null , SERVICE_ACCOUNT_MAIL , null , null , null );
134123
135- if (LOGGER .isLoggable (Level .INFO )) {
136- LOGGER .info (response .toString ());
137- }
124+ System .out .println (response .toString ());
138125 } catch (ApiException | IOException e ) {
139126 throw new IllegalStateException (e );
140127 }
0 commit comments