Removed outdated basic auth classes (#2245)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
pull/2250/head
Kai Kreuzer 2021-03-20 12:46:30 +01:00 committed by GitHub
parent 4bf156ffc0
commit ee1d3f3a73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 0 additions and 215 deletions

View File

@ -184,12 +184,6 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.io.http.auth.basic</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.io.monitor</artifactId>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="annotationpath" value="target/dependency"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="annotationpath" value="target/dependency"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.core.io.http.auth.basic</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -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

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.reactor.bundles</artifactId>
<version>3.1.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.core.io.http.auth.basic</artifactId>
<name>openHAB Core :: Bundles :: HTTP Interface Basic Authentication</name>
<dependencies>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.io.http.auth</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -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);
}
}

View File

@ -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<HttpServletRequest> {
@Override
public Optional<Credentials> 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();
}
}

View File

@ -53,7 +53,6 @@
<module>org.openhab.core.io.console.karaf</module>
<module>org.openhab.core.io.http</module>
<module>org.openhab.core.io.http.auth</module>
<module>org.openhab.core.io.http.auth.basic</module>
<module>org.openhab.core.io.monitor</module>
<module>org.openhab.core.io.net</module>
<module>org.openhab.core.io.rest</module>

View File

@ -115,16 +115,6 @@
<bundle>mvn:org.openhab.core.bundles/org.openhab.core.io.http.auth/${project.version}</bundle>
</feature>
<feature name="openhab-core-io-http-auth-basic" version="${project.version}">
<feature>openhab-core-base</feature>
<bundle>mvn:org.openhab.core.bundles/org.openhab.core.io.http.auth.basic/${project.version}</bundle>
<feature>openhab-core-io-http-auth</feature>
<config name="org.openhab.auth">
enabled = true
</config>
</feature>
<feature name="openhab-core-io-rest-auth" version="${project.version}">
<feature>openhab-core-base</feature>
<feature>openhab-core-auth-jaas</feature>