@@ -31,6 +31,7 @@ of this software and associated documentation files (the "Software"), to deal
3131import java .net .ConnectException ;
3232import java .net .Proxy ;
3333import java .net .URI ;
34+ import java .nio .charset .StandardCharsets ;
3435import java .util .Base64 ;
3536import java .util .HashMap ;
3637import java .util .Map ;
@@ -68,10 +69,18 @@ public void connect(String uri, RadioEvents events) {
6869
6970 Map <String , String > httpHeaders = new HashMap <>();
7071 String username = configuration .getParameter (JSONConfiguration .USERNAME_PARAMETER );
71- String password = configuration .getParameter (JSONConfiguration .PASSWORD_PARAMETER );
72+ Object password = configuration .getParameter (JSONConfiguration .PASSWORD_PARAMETER );
73+ byte [] credentials = null ;
7274 if (username != null && password != null ) {
73- String credentials = username + ":" + password ;
74- byte [] base64Credentials = Base64 .getEncoder ().encode (credentials .getBytes ());
75+ if (password instanceof String ) {
76+ credentials = (username + ":" + password ).getBytes (StandardCharsets .UTF_8 );
77+ } else if (password instanceof byte []) {
78+ credentials =
79+ joinByteArrays ((username + ":" ).getBytes (StandardCharsets .UTF_8 ), (byte []) password );
80+ }
81+ }
82+ if (credentials != null ) {
83+ byte [] base64Credentials = Base64 .getEncoder ().encode (credentials );
7584 httpHeaders .put ("Authorization" , "Basic " + new String (base64Credentials ));
7685 }
7786
@@ -132,6 +141,13 @@ public void onError(Exception ex) {
132141 }
133142 }
134143
144+ byte [] joinByteArrays (byte [] a , byte [] b ) {
145+ byte [] result = new byte [a .length + b .length ];
146+ System .arraycopy (a , 0 , result , 0 , a .length );
147+ System .arraycopy (b , 0 , result , a .length , b .length );
148+ return result ;
149+ }
150+
135151 void configure () {
136152 client .setReuseAddr (configuration .getParameter (JSONConfiguration .REUSE_ADDR_PARAMETER , false ));
137153 client .setTcpNoDelay (
0 commit comments