Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
TDF-PL-038 committed Nov 19, 2023
1 parent e1c8360 commit 37a4d58
Show file tree
Hide file tree
Showing 18 changed files with 335 additions and 274 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.wot.tak.connection.configuration;

import org.wot.tak.connection.connectors.CredentialsConnector;
import org.wot.tak.connection.connectors.PlainConnector;
import org.wot.tak.connection.connectors.TCPConnector;
import org.wot.tak.connection.connectors.SSLConnector;
import org.wot.tak.connection.connectors.SSLCredentialsConnector;
import org.wot.tak.connection.connectors.UDPConnector;
Expand Down Expand Up @@ -62,11 +62,10 @@ public TAKServerConnector getCredentialsConnector() throws Exception {
* @throws Exception If an error occurs.
*/
public TAKServerConnector getPlainConnector() throws Exception {
return new PlainConnector(
return new TCPConnector(
config.getTakServerUrl(),
config.getTakServerPort(),
new SocketFactory(config.getSocketFactoryConfig())
);
new SocketFactory(config.getSocketFactoryConfig()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package org.wot.tak.connection.configuration;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter(AccessLevel.PUBLIC)
@RequiredArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public final class SocketFactoryConfig {

public static SocketFactoryConfig empty() {
return new SocketFactoryConfig(
"", "", "", "", false);
}

private final String trustStorePath;
private final String trustStorePassword;
private final String keyStorePath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package org.wot.tak.connection.configuration;

import org.wot.tak.connection.protocol.ProtocolVersion;
import org.wot.tak.connection.protocol.protobuf.Takmessage;
import org.wot.tak.connection.protocol.xml.Event;

import java.io.IOException;

public interface TAKServerConnector extends AutoCloseable {

/**
* Retrieves the protocol version of the communication.
* @return The {@code ProtocolVersion} representing the protocol version.
*/
ProtocolVersion getProtocolVersion();

/**
* Connects to the server.
* @param handler Handler for received XML.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import org.wot.tak.connection.configuration.MessageReceiver;
import org.wot.tak.connection.infra.SocketFactory;
import org.wot.tak.connection.infra.TCPConnector;
import org.wot.tak.connection.infra.TCPConnectorBase;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;

public final class CredentialsConnector extends TCPConnector {
public final class CredentialsConnector extends TCPConnectorBase {

private final String username;
private final String password;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.wot.tak.connection.connectors;

import org.wot.tak.connection.configuration.MessageReceiver;
import org.wot.tak.connection.infra.SocketFactory;
import org.wot.tak.connection.infra.StreamingTcpConnector;

public final class TCPConnector extends StreamingTcpConnector {

public TCPConnector(String url, String port, SocketFactory sFactory) {
super(url, port, sFactory, true);
}

public TCPConnector(String url, String port, SocketFactory sFactory, boolean negotiateProtocolVersion) {
super(url, port, sFactory, negotiateProtocolVersion);
}

@Override
public void connect(MessageReceiver handler) throws Exception {
this.setSocket(getSocketFactory().createSocket(getUrl(), getPort()));
super.connect(handler);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.xml.bind.JAXBException;
import org.wot.tak.connection.configuration.MessageReceiver;
import org.wot.tak.connection.configuration.TAKServerConnector;
import org.wot.tak.connection.protocol.ProtocolVersion;
import org.wot.tak.connection.protocol.protobuf.Takmessage;
import org.wot.tak.connection.protocol.xml.Event;
import org.wot.tak.connection.protocol.xml.EventMarshalling;
Expand All @@ -23,6 +24,11 @@ public UDPConnector(String url, String port) {
this.port = Integer.parseInt(port);
}

@Override
public ProtocolVersion getProtocolVersion() {
return ProtocolVersion.XML;
}

@Override
public void connect(MessageReceiver handler) throws Exception {
socket = new DatagramSocket(this.port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import javax.xml.datatype.DatatypeConfigurationException;

public class StreamingTcpConnector extends TCPConnector {
public abstract class StreamingTcpConnector extends TCPConnectorBase {

private final boolean negotiateProtobufProtocol;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.net.Socket;

@Getter(AccessLevel.PUBLIC)
public abstract class TCPConnector implements TAKServerConnector {
public abstract class TCPConnectorBase implements TAKServerConnector {
private final String url;
private final int port;
private final SocketFactory socketFactory;
Expand All @@ -35,7 +35,7 @@ public abstract class TCPConnector implements TAKServerConnector {
@Setter(AccessLevel.PUBLIC)
private ProtocolVersion protocolVersion = ProtocolVersion.XML;

protected TCPConnector(String url, String port, SocketFactory sFactory) {
protected TCPConnectorBase(String url, String port, SocketFactory sFactory) {
this.url = url;
this.port = Integer.parseInt(port);
this.socketFactory = sFactory;
Expand Down
28 changes: 14 additions & 14 deletions connection/src/main/resources/protocol/xml/wot/Event.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,43 @@
<xs:element name="point" type="point"/>
<xs:element name="detail" type="detail"/>
</xs:all>
<xs:attribute name="how" type="xs:string">
<xs:attribute name="how" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>Gives a hint about how the coordinates were generated</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="m_detail" type="xs:string"/>
<xs:attribute name="m_point" type="xs:string"/>
<xs:attribute name="stale" type="xs:dateTime">
<xs:attribute name="stale" type="xs:dateTime" use="required">
<xs:annotation>
<xs:documentation>ending time when an event should no longer be considered valid</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="start" type="xs:dateTime">
<xs:attribute name="start" type="xs:dateTime" use="required">
<xs:annotation>
<xs:documentation>starting time when an event should be considered valid</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="time" type="xs:dateTime">
<xs:attribute name="time" type="xs:dateTime" use="required">
<xs:annotation>
<xs:documentation>time stamp: when the event was generated</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" type="xs:string">
<xs:attribute name="type" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>&lt;font color="#008000"&gt;# Hierarchically organized hint about event type
(defaultis is 'a-f-G-I' for infrastructure)&lt;/font&gt;
<xs:documentation>&lt;font color="#008000"&gt; # Hierarchically organized hint about event type
(default is 'a-f-G-I' for infrastructure)&lt;/font&gt;
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="uid" type="xs:string">
<xs:attribute name="uid" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>Globally unique name for this information on this event.</xs:documentation>
<xs:documentation>can have additional information attached.</xs:documentation>
<xs:documentation>e.g. -ping means that this request is a ping</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="version" type="xs:decimal">
<xs:attribute name="version" type="xs:decimal" use="required">
<xs:annotation>
<xs:documentation>Schema version of this event instance (e.g. 2.0)</xs:documentation>
</xs:annotation>
Expand All @@ -62,28 +62,28 @@
<xs:annotation>
<xs:documentation>class COTPOINT</xs:documentation>
</xs:annotation>
<xs:attribute name="ce" type="xs:decimal">
<xs:attribute name="ce" type="xs:decimal" use="required">
<xs:annotation>
<xs:documentation>Circular 1-sigma or decimal a circular area about the point in meters
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="lat" type="xs:decimal">
<xs:attribute name="lat" type="xs:decimal" use="required">
<xs:annotation>
<xs:documentation>Latitude referred to the WGS 84 ellipsoid in degrees</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="le" type="xs:decimal">
<xs:attribute name="le" type="xs:decimal" use="required">
<xs:annotation>
<xs:documentation>Linear 1-sigma error or an altitude range about the point in meters</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="lon" type="xs:decimal">
<xs:attribute name="lon" type="xs:decimal" use="required">
<xs:annotation>
<xs:documentation>Longitude referred to the WGS 84 in degrees</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="hae" type="xs:decimal">
<xs:attribute name="hae" type="xs:decimal" use="required">
<xs:annotation>
<xs:documentation>
HAE acronym for Height above Ellipsoid based on WGS-84 ellipsoid (measured in meters).
Expand Down
Loading

0 comments on commit 37a4d58

Please sign in to comment.