@@ -165,7 +165,7 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(
165165 .build ();
166166
167167 String username = null ;
168- byte [] password = null ;
168+ String password = null ;
169169 if (clientHandshake .hasFieldValue ("Authorization" )) {
170170 String authorization = clientHandshake .getFieldValue ("Authorization" );
171171 if (authorization != null && authorization .toLowerCase ().startsWith ("basic" )) {
@@ -178,21 +178,21 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(
178178 username =
179179 new String (Arrays .copyOfRange (credDecoded , 0 , i ), StandardCharsets .UTF_8 );
180180 if (i + 1 < credDecoded .length ) {
181- password = Arrays .copyOfRange (credDecoded , i + 1 , credDecoded .length );
181+ password = new String ( Arrays .copyOfRange (credDecoded , i + 1 , credDecoded .length ) );
182182 }
183183 break ;
184184 }
185185 }
186186 }
187187 if (protocolVersion == null || protocolVersion == ProtocolVersion .OCPP1_6 ) {
188188 if (password == null
189- || password .length < configuration .getParameter (JSONConfiguration .OCPPJ_CP_MIN_PASSWORD_LENGTH , OCPPJ_CP_MIN_PASSWORD_LENGTH )
190- || password .length > configuration .getParameter (JSONConfiguration .OCPPJ_CP_MAX_PASSWORD_LENGTH , OCPPJ_CP_MAX_PASSWORD_LENGTH ))
189+ || password .length () < configuration .getParameter (JSONConfiguration .OCPPJ_CP_MIN_PASSWORD_LENGTH , OCPPJ_CP_MIN_PASSWORD_LENGTH )
190+ || password .length () > configuration .getParameter (JSONConfiguration .OCPPJ_CP_MAX_PASSWORD_LENGTH , OCPPJ_CP_MAX_PASSWORD_LENGTH ))
191191 throw new InvalidDataException (401 , "Invalid password length" );
192192 } else {
193193 if (password == null
194- || password .length < configuration .getParameter (JSONConfiguration .OCPP2J_CP_MIN_PASSWORD_LENGTH , OCPP2J_CP_MIN_PASSWORD_LENGTH )
195- || password .length > configuration .getParameter (JSONConfiguration .OCPP2J_CP_MAX_PASSWORD_LENGTH , OCPP2J_CP_MAX_PASSWORD_LENGTH ))
194+ || password .length () < configuration .getParameter (JSONConfiguration .OCPP2J_CP_MIN_PASSWORD_LENGTH , OCPP2J_CP_MIN_PASSWORD_LENGTH )
195+ || password .length () > configuration .getParameter (JSONConfiguration .OCPP2J_CP_MAX_PASSWORD_LENGTH , OCPP2J_CP_MAX_PASSWORD_LENGTH ))
196196 throw new InvalidDataException (401 , "Invalid password length" );
197197 }
198198 }
0 commit comments