From ee1d3f3a73c728973e8bb374641615f42f1dc2f9 Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Sat, 20 Mar 2021 12:46:30 +0100 Subject: [PATCH] Removed outdated basic auth classes (#2245) Signed-off-by: Kai Kreuzer --- bom/openhab-core/pom.xml | 6 -- .../.classpath | 29 --------- .../.project | 23 -------- .../NOTICE | 14 ----- .../pom.xml | 25 -------- .../basic/internal/BasicChallengeHandler.java | 48 --------------- .../internal/BasicCredentialsExtractor.java | 59 ------------------- bundles/pom.xml | 1 - .../openhab-core/src/main/feature/feature.xml | 10 ---- 9 files changed, 215 deletions(-) delete mode 100644 bundles/org.openhab.core.io.http.auth.basic/.classpath delete mode 100644 bundles/org.openhab.core.io.http.auth.basic/.project delete mode 100644 bundles/org.openhab.core.io.http.auth.basic/NOTICE delete mode 100644 bundles/org.openhab.core.io.http.auth.basic/pom.xml delete mode 100644 bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicChallengeHandler.java delete mode 100644 bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicCredentialsExtractor.java diff --git a/bom/openhab-core/pom.xml b/bom/openhab-core/pom.xml index 5e89a5185f..9e1b068276 100644 --- a/bom/openhab-core/pom.xml +++ b/bom/openhab-core/pom.xml @@ -184,12 +184,6 @@ ${project.version} compile - - org.openhab.core.bundles - org.openhab.core.io.http.auth.basic - ${project.version} - compile - org.openhab.core.bundles org.openhab.core.io.monitor diff --git a/bundles/org.openhab.core.io.http.auth.basic/.classpath b/bundles/org.openhab.core.io.http.auth.basic/.classpath deleted file mode 100644 index 4244343f8a..0000000000 --- a/bundles/org.openhab.core.io.http.auth.basic/.classpath +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.openhab.core.io.http.auth.basic/.project b/bundles/org.openhab.core.io.http.auth.basic/.project deleted file mode 100644 index b36fcd7b19..0000000000 --- a/bundles/org.openhab.core.io.http.auth.basic/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - org.openhab.core.io.http.auth.basic - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/bundles/org.openhab.core.io.http.auth.basic/NOTICE b/bundles/org.openhab.core.io.http.auth.basic/NOTICE deleted file mode 100644 index 6c17d0d8a4..0000000000 --- a/bundles/org.openhab.core.io.http.auth.basic/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -This content is produced and maintained by the openHAB project. - -* Project home: https://www.openhab.org - -== Declared Project Licenses - -This program and the accompanying materials are made available under the terms -of the Eclipse Public License 2.0 which is available at -https://www.eclipse.org/legal/epl-2.0/. - -== Source Code - -https://github.com/openhab/openhab-core - diff --git a/bundles/org.openhab.core.io.http.auth.basic/pom.xml b/bundles/org.openhab.core.io.http.auth.basic/pom.xml deleted file mode 100644 index 4cf228532e..0000000000 --- a/bundles/org.openhab.core.io.http.auth.basic/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - - - org.openhab.core.bundles - org.openhab.core.reactor.bundles - 3.1.0-SNAPSHOT - - - org.openhab.core.io.http.auth.basic - - openHAB Core :: Bundles :: HTTP Interface Basic Authentication - - - - org.openhab.core.bundles - org.openhab.core.io.http.auth - ${project.version} - - - - diff --git a/bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicChallengeHandler.java b/bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicChallengeHandler.java deleted file mode 100644 index 22096e7e90..0000000000 --- a/bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicChallengeHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.core.io.http.auth.basic.internal; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openhab.core.io.http.Handler; -import org.openhab.core.io.http.HandlerContext; -import org.openhab.core.io.http.HandlerPriorities; -import org.osgi.service.component.annotations.Component; - -/** - * A handler which forces basic auth when authentication fails. - * - * @author Łukasz Dywicki - Initial contribution - */ -@Component -public class BasicChallengeHandler implements Handler { - - @Override - public int getPriority() { - return HandlerPriorities.AUTHENTICATION + 1; - } - - @Override - public void handle(HttpServletRequest request, HttpServletResponse response, HandlerContext context) { - context.execute(request, response); - } - - @Override - public void handleError(HttpServletRequest request, HttpServletResponse response, HandlerContext context) { - response.setHeader("WWW-Authenticate", "Basic realm=\"Please enter user name and password to access system\""); - response.setStatus(401); - - context.execute(request, response); - } -} diff --git a/bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicCredentialsExtractor.java b/bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicCredentialsExtractor.java deleted file mode 100644 index 186c144465..0000000000 --- a/bundles/org.openhab.core.io.http.auth.basic/src/main/java/org/openhab/core/io/http/auth/basic/internal/BasicCredentialsExtractor.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.core.io.http.auth.basic.internal; - -import java.util.Base64; -import java.util.Optional; - -import javax.servlet.http.HttpServletRequest; - -import org.openhab.core.auth.Credentials; -import org.openhab.core.auth.UsernamePasswordCredentials; -import org.openhab.core.io.http.auth.CredentialsExtractor; -import org.osgi.service.component.annotations.Component; - -/** - * Extract user name and password from incoming request. - * - * @author Łukasz Dywicki - Initial contribution. - */ -@Component(property = { "context=javax.servlet.http.HttpServletRequest" }) -public class BasicCredentialsExtractor implements CredentialsExtractor { - - @Override - public Optional retrieveCredentials(HttpServletRequest request) { - String authenticationHeader = request.getHeader("Authorization"); - - if (authenticationHeader == null) { - return Optional.empty(); - } - - String[] tokens = authenticationHeader.split(" "); - if (tokens.length == 2) { - String authType = tokens[0]; - if (HttpServletRequest.BASIC_AUTH.equalsIgnoreCase(authType)) { - String usernameAndPassword = new String(Base64.getDecoder().decode(tokens[1])); - - tokens = usernameAndPassword.split(":"); - if (tokens.length == 2) { - String username = tokens[0]; - String password = tokens[1]; - - return Optional.of(new UsernamePasswordCredentials(username, password)); - } - } - } - - return Optional.empty(); - } -} diff --git a/bundles/pom.xml b/bundles/pom.xml index a30102da4b..ea5a27a804 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -53,7 +53,6 @@ org.openhab.core.io.console.karaf org.openhab.core.io.http org.openhab.core.io.http.auth - org.openhab.core.io.http.auth.basic org.openhab.core.io.monitor org.openhab.core.io.net org.openhab.core.io.rest diff --git a/features/karaf/openhab-core/src/main/feature/feature.xml b/features/karaf/openhab-core/src/main/feature/feature.xml index 43f700baa6..896580bb99 100644 --- a/features/karaf/openhab-core/src/main/feature/feature.xml +++ b/features/karaf/openhab-core/src/main/feature/feature.xml @@ -115,16 +115,6 @@ mvn:org.openhab.core.bundles/org.openhab.core.io.http.auth/${project.version} - - openhab-core-base - mvn:org.openhab.core.bundles/org.openhab.core.io.http.auth.basic/${project.version} - - openhab-core-io-http-auth - - enabled = true - - - openhab-core-base openhab-core-auth-jaas