+ protected registerProtocolVersionUIService (version: ProtocolVersion): void {
+ if (!this.uiServices.has(version)) {
+ this.uiServices.set(version, UIServiceFactory.getUIServiceImplementation(version, this))
+ }
+ }
+
+ protected authenticate (req: IncomingMessage, next: (err?: Error) => void): void {
+ const authorizationError = new BaseError('Unauthorized')
+ if (this.isBasicAuthEnabled()) {
+ if (!this.isValidBasicAuth(req, next)) {
+ next(authorizationError)
+ }
+ next()
+ } else if (this.isProtocolBasicAuthEnabled()) {
+ if (!this.isValidProtocolBasicAuth(req, next)) {
+ next(authorizationError)
+ }
+ next()
+ } else if (this.uiServerConfiguration.authentication?.enabled === true) {
+ next(authorizationError)
+ }
+ next()
+ }
+
+ private stopHttpServer (): void {
+ if (this.httpServer.listening) {
+ this.httpServer.close()
+ this.httpServer.removeAllListeners()
+ }
+ }
+
+ private isBasicAuthEnabled (): boolean {
+ return (
+ this.uiServerConfiguration.authentication?.enabled === true &&
+ this.uiServerConfiguration.authentication.type === AuthenticationType.BASIC_AUTH
+ )
+ }
+
+ private isProtocolBasicAuthEnabled (): boolean {