Skip to content

Commit

Permalink
Merge pull request #192 from pixxelhq/master
Browse files Browse the repository at this point in the history
v5.10.9-Pixxel-8.0.0
  • Loading branch information
swarup-n authored Jan 12, 2025
2 parents b9e2d36 + 2e73c57 commit f525999
Show file tree
Hide file tree
Showing 54 changed files with 1,124 additions and 59 deletions.
2 changes: 1 addition & 1 deletion distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>distribution</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/cascading/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>cascading</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/ccsds-frames/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>ccsds-frames</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/cfdp-udp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>cfdp-udp</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/cfdp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>cfdp</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/perftest1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>perftest1</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/perftest2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>perftest2</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<groupId>org.yamcs.examples</groupId>
Expand Down
2 changes: 1 addition & 1 deletion examples/pus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>pus</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/replication1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>replication1</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/replication2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>replication2</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/replication3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>replication3</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/simulation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>simulation</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>snippets</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs.examples</groupId>
<artifactId>examples</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>templates</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion packet-viewer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>packet-viewer</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>

<packaging>pom</packaging>

Expand Down Expand Up @@ -84,6 +84,11 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion simulator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>simulator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>tests</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion yamcs-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>yamcs-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
syntax="proto2";

package yamcs.protobuf.instances;

option java_package = "org.yamcs.protobuf";
option java_outer_classname = "KeyManagmentServiceProto";
option java_multiple_files = true;

import "google/protobuf/empty.proto";

import "yamcs/api/annotations.proto";

service KeyManagmentApi {

// Update any type of key of the instance
rpc UpdateKey(UpdateKeyRequest) returns (KeyResponse) {
option (yamcs.api.route) = {
post: "/api/keymanagement/{instance}:updateKey"
};
}

// Get the key of a family of the instance
rpc GetActiveKey(ActiveKeyRequest) returns (KeyResponse) {
option (yamcs.api.route) = {
get: "/api/keymanagement/{instance}"
};
}
}

message UpdateKeyRequest{
// Yamcs instance name.
optional string instance = 1;

// Type of the key
required string family = 2;

// Key ID to be updated to
required string keyId = 3;
}

message ActiveKeyRequest {
// Yamcs instance name.
optional string instance = 1;

// Type of the key
optional string family = 2;
}

message KeyResponse {
optional string instance = 1;
optional string keyId = 2;

// Type of the key
optional string family = 3;
}
2 changes: 1 addition & 1 deletion yamcs-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>yamcs-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion yamcs-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.yamcs</groupId>
<artifactId>yamcs</artifactId>
<version>5.10.9-Pixxel-7.2.0</version>
<version>5.10.9-Pixxel-8.0.0</version>
</parent>

<artifactId>yamcs-core</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions yamcs-core/src/main/java/org/yamcs/http/HttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.yamcs.http.api.IamApi;
import org.yamcs.http.api.IndexesApi;
import org.yamcs.http.api.InstancesApi;
import org.yamcs.http.api.KeyManagementApi;
import org.yamcs.http.api.LinksApi;
import org.yamcs.http.api.MdbApi;
import org.yamcs.http.api.MdbOverrideApi;
Expand Down Expand Up @@ -290,6 +291,7 @@ public void init(String yamcsInstance, String serviceName, YConfiguration config
addApi(new IamApi(auditLog, tokenStore));
addApi(new IndexesApi());
addApi(new InstancesApi());
addApi(new KeyManagementApi());
addApi(new LinksApi(auditLog));
addApi(new MdbApi());
addApi(new MdbOverrideApi());
Expand Down
15 changes: 1 addition & 14 deletions yamcs-core/src/main/java/org/yamcs/http/api/InstancesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,7 @@
import org.yamcs.management.ManagementService;
import org.yamcs.mdb.Mdb;
import org.yamcs.plists.ParameterListService;
import org.yamcs.protobuf.AbstractInstancesApi;
import org.yamcs.protobuf.CreateInstanceRequest;
import org.yamcs.protobuf.GetInstanceRequest;
import org.yamcs.protobuf.GetInstanceTemplateRequest;
import org.yamcs.protobuf.InstanceTemplate;
import org.yamcs.protobuf.ListInstanceTemplatesResponse;
import org.yamcs.protobuf.ListInstancesRequest;
import org.yamcs.protobuf.ListInstancesResponse;
import org.yamcs.protobuf.ReconfigureInstanceRequest;
import org.yamcs.protobuf.RestartInstanceRequest;
import org.yamcs.protobuf.StartInstanceRequest;
import org.yamcs.protobuf.StopInstanceRequest;
import org.yamcs.protobuf.TemplateVariable;
import org.yamcs.protobuf.YamcsInstance;
import org.yamcs.protobuf.*;
import org.yamcs.protobuf.YamcsInstance.InstanceState;
import org.yamcs.security.SystemPrivilege;
import org.yamcs.templating.Template;
Expand Down
80 changes: 80 additions & 0 deletions yamcs-core/src/main/java/org/yamcs/http/api/KeyManagementApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.yamcs.http.api;

import java.util.regex.Pattern;

import org.yamcs.YamcsServer;
import org.yamcs.api.Observer;
import org.yamcs.http.Context;
import org.yamcs.http.ForbiddenException;
import org.yamcs.protobuf.*;
import org.yamcs.security.SystemPrivilege;
import org.yamcs.security.encryption.aes.KeyManagementService;
import org.yamcs.time.TimeService;
import org.yamcs.yarch.Stream;
import org.yamcs.yarch.Tuple;


public class KeyManagementApi extends AbstractKeyManagmentApi<Context>{
public static final Pattern ALLOWED_INSTANCE_NAMES = Pattern.compile("\\w[\\w\\.-]*");

@Override
public void updateKey(Context ctx, UpdateKeyRequest request, Observer<KeyResponse> observer) {
ctx.checkSystemPrivilege(SystemPrivilege.ControlServices);

KeyManagementService keyMgmService = YamcsServer.getServer().getInstance(request.getInstance()).getService(KeyManagementService.class, "keyManagementService");
TimeService timeService = YamcsServer.getTimeService(request.getInstance());

if (keyMgmService == null) {
throw new ForbiddenException("KeyManagementService is not configured");
}

if (keyMgmService.getClient() == null) {
throw new ForbiddenException("KeyManagementService is configured, but vault access not provided");
}

Stream publishStream = keyMgmService.getStream();
publishStream.emitTuple(new Tuple(KeyManagementService.ACTIVE_KEY_TUPLE_DEFINITION, new Object[]{
timeService.getMissionTime(),
request.getKeyId(),
request.getFamily(),
})
);

KeyResponse.Builder response = KeyResponse.newBuilder();
response
.setFamily(request.getFamily())
.setKeyId(request.getKeyId());

observer.complete(response.build());
}

@Override
public void getActiveKey(Context ctx, ActiveKeyRequest request, Observer<KeyResponse> observer) {
ctx.checkSystemPrivilege(SystemPrivilege.ControlServices);
KeyManagementService keyMgmService = YamcsServer.getServer().getInstance(request.getInstance()).getService(KeyManagementService.class, "keyManagementService");

if (keyMgmService == null) {
throw new ForbiddenException("KeyManagementService is not configured");
}

if (keyMgmService.getClient() == null) {
throw new ForbiddenException("KeyManagementService is configured, but vault access not provided");
}

String keyId;
switch (request.getFamily()) {
case "tm" -> keyId = keyMgmService.getTmKeyId();
case "tc" -> keyId = keyMgmService.getTcKeyId();
default -> throw new RuntimeException("Key Family not found");
}

KeyResponse.Builder activeKeyResponse = KeyResponse.newBuilder();
activeKeyResponse
.setFamily(request.getFamily())
.setInstance(request.getInstance())
.setKeyId(keyId);

observer.complete(activeKeyResponse.build());
}

}
Loading

0 comments on commit f525999

Please sign in to comment.