forked from eclipse-leshan/leshan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring add bsserver module - no file content changes [dont build]
Move Bootstrap Server code in dedicated maven modules. This is part of : eclipse-leshan#1295 Refactoring was done in 2 commits to try to keep git history : https://stackoverflow.com/questions/2314652/is-it-possible-to-move-rename-files-in-git-and-maintain-their-history This commit doesn't build.
- Loading branch information
1 parent
6d2ff69
commit 2869625
Showing
87 changed files
with
1,220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2013-2015 Sierra Wireless and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v2.0 | ||
and Eclipse Distribution License v1.0 which accompany this distribution. | ||
The Eclipse Public License is available at | ||
http://www.eclipse.org/legal/epl-v20.html | ||
and the Eclipse Distribution License is available at | ||
http://www.eclipse.org/org/documents/edl-v10.html. | ||
Contributors: | ||
Sierra Wireless - initial API and implementation | ||
--> | ||
<configuration> | ||
<!-- | ||
This file will only be used by maven by default. | ||
If you want to use it in your IDE, just : | ||
- use -Dlogback.configurationFile=logback-test-.xml argument | ||
or | ||
- put a logback-test.xml file in your classpath (it will be ignore by git) | ||
--> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d %p %C{1} [%t] %m%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="ERROR"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2013-2015 Sierra Wireless and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v2.0 | ||
and Eclipse Distribution License v1.0 which accompany this distribution. | ||
The Eclipse Public License is available at | ||
http://www.eclipse.org/legal/epl-v20.html | ||
and the Eclipse Distribution License is available at | ||
http://www.eclipse.org/org/documents/edl-v10.html. | ||
Contributors: | ||
Sierra Wireless - initial API and implementation | ||
Bosch Software Innovations GmbH - OSGi support | ||
--> | ||
<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.eclipse.leshan</groupId> | ||
<artifactId>lib-build-config</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<relativePath>../build-config/lib-build-config/pom.xml</relativePath> | ||
</parent> | ||
<artifactId>leshan-lwm2m-bsserver</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>leshan - bsserver</name> | ||
<description>A LWM2M bootstrap server implementation which abstracts transport layer. A transport implementation like "leshan-tl-cf-bsserver-coap" is needed.</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.leshan</groupId> | ||
<artifactId>leshan-lwm2m-core</artifactId> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2013-2015 Sierra Wireless and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v2.0 | ||
and Eclipse Distribution License v1.0 which accompany this distribution. | ||
The Eclipse Public License is available at | ||
http://www.eclipse.org/legal/epl-v20.html | ||
and the Eclipse Distribution License is available at | ||
http://www.eclipse.org/org/documents/edl-v10.html. | ||
Contributors: | ||
Sierra Wireless - initial API and implementation | ||
--> | ||
<configuration> | ||
<!-- | ||
This file will only be used by maven by default. | ||
If you want to use it in your IDE, just : | ||
- use -Dlogback.configurationFile=logback-test-.xml argument | ||
or | ||
- put a logback-test.xml file in your classpath (it will be ignore by git) | ||
--> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d %p %C{1} [%t] %m%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="ERROR"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2013-2015 Sierra Wireless and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v2.0 | ||
and Eclipse Distribution License v1.0 which accompany this distribution. | ||
The Eclipse Public License is available at | ||
http://www.eclipse.org/legal/epl-v20.html | ||
and the Eclipse Distribution License is available at | ||
http://www.eclipse.org/org/documents/edl-v10.html. | ||
Contributors: | ||
Sierra Wireless - initial API and implementation | ||
Bosch Software Innovations GmbH - OSGi support | ||
--> | ||
<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.eclipse.leshan</groupId> | ||
<artifactId>lib-build-config</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<relativePath>../build-config/lib-build-config/pom.xml</relativePath> | ||
</parent> | ||
<artifactId>leshan-lwm2m-servers-shared</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>leshan - servers - shared</name> | ||
<description>Shared classes between server and bsserver.</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.leshan</groupId> | ||
<artifactId>leshan-lwm2m-core</artifactId> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2013-2015 Sierra Wireless and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v2.0 | ||
and Eclipse Distribution License v1.0 which accompany this distribution. | ||
The Eclipse Public License is available at | ||
http://www.eclipse.org/legal/epl-v20.html | ||
and the Eclipse Distribution License is available at | ||
http://www.eclipse.org/org/documents/edl-v10.html. | ||
Contributors: | ||
Sierra Wireless - initial API and implementation | ||
--> | ||
<configuration> | ||
<!-- | ||
This file will only be used by maven by default. | ||
If you want to use it in your IDE, just : | ||
- use -Dlogback.configurationFile=logback-test-.xml argument | ||
or | ||
- put a logback-test.xml file in your classpath (it will be ignore by git) | ||
--> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d %p %C{1} [%t] %m%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="ERROR"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2013-2015 Sierra Wireless and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v2.0 | ||
and Eclipse Distribution License v1.0 which accompany this distribution. | ||
The Eclipse Public License is available at | ||
http://www.eclipse.org/legal/epl-v20.html | ||
and the Eclipse Distribution License is available at | ||
http://www.eclipse.org/org/documents/edl-v10.html. | ||
Contributors: | ||
Sierra Wireless - initial API and implementation | ||
Bosch Software Innovations GmbH - OSGi support | ||
--> | ||
<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.eclipse.leshan</groupId> | ||
<artifactId>lib-build-config</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<relativePath>../build-config/lib-build-config/pom.xml</relativePath> | ||
</parent> | ||
<artifactId>leshan-tl-cf-bsserver-coap</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>leshan - transport - californium - bsserver - coap</name> | ||
<description>A transport implementation for leshan bootstrap server based on Californium for CoAP protocol</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.leshan</groupId> | ||
<artifactId>leshan-tl-cf-shared</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.leshan</groupId> | ||
<artifactId>leshan-lwm2m-server</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.californium</groupId> | ||
<artifactId>californium-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.californium</groupId> | ||
<artifactId>scandium</artifactId> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<!-- We need to launch each tests in its own JVM to be able to check number | ||
of active threads in LeshanBootstrapServerTest and LeshanServerTest --> | ||
<reuseForks>false</reuseForks> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
File renamed without changes.
File renamed without changes.
79 changes: 79 additions & 0 deletions
79
...ap/src/main/java/org/eclipse/leshan/transport/californium/bsserver/ConnectionCleaner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
* | ||
* Contributors: | ||
* Sierra Wireless - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.leshan.transport.californium.server; | ||
|
||
import java.security.Principal; | ||
import java.security.PublicKey; | ||
|
||
import javax.security.auth.x500.X500Principal; | ||
|
||
import org.eclipse.californium.elements.auth.PreSharedKeyIdentity; | ||
import org.eclipse.californium.elements.auth.RawPublicKeyIdentity; | ||
import org.eclipse.californium.elements.auth.X509CertPath; | ||
import org.eclipse.californium.elements.util.Filter; | ||
import org.eclipse.californium.scandium.DTLSConnector; | ||
import org.eclipse.leshan.core.security.certificate.util.X509CertUtil; | ||
import org.eclipse.leshan.server.security.SecurityInfo; | ||
|
||
/** | ||
* This class is responsible to remove DTLS connection for a given SecurityInfo. | ||
*/ | ||
public class ConnectionCleaner { | ||
|
||
private final DTLSConnector connector; | ||
|
||
public ConnectionCleaner(DTLSConnector connector) { | ||
this.connector = connector; | ||
} | ||
|
||
public void cleanConnectionFor(final SecurityInfo... infos) { | ||
connector.startTerminateConnectionsForPrincipal(new Filter<Principal>() { | ||
@Override | ||
public boolean accept(Principal principal) { | ||
if (principal != null) { | ||
for (SecurityInfo info : infos) { | ||
if (info != null) { | ||
// PSK | ||
if (info.usePSK() && principal instanceof PreSharedKeyIdentity) { | ||
String identity = ((PreSharedKeyIdentity) principal).getIdentity(); | ||
if (info.getPskIdentity().equals(identity)) { | ||
return true; | ||
} | ||
} | ||
// RPK | ||
else if (info.useRPK() && principal instanceof RawPublicKeyIdentity) { | ||
PublicKey publicKey = ((RawPublicKeyIdentity) principal).getKey(); | ||
if (info.getRawPublicKey().equals(publicKey)) { | ||
return true; | ||
} | ||
} | ||
// x509 | ||
else if (info.useX509Cert() && principal instanceof X500Principal | ||
|| principal instanceof X509CertPath) { | ||
// Extract common name | ||
String x509CommonName = X509CertUtil.extractCN(principal.getName()); | ||
if (x509CommonName.equals(info.getEndpoint())) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
}); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.