forked from yamcs/yamcs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from pixxelhq/master
v5.10.9-Pixxel-8.0.0
- Loading branch information
Showing
54 changed files
with
1,124 additions
and
59 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
55 changes: 55 additions & 0 deletions
55
yamcs-api/src/main/proto/yamcs/protobuf/keymanagement/keymanagement.proto
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,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; | ||
} |
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
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
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
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
80 changes: 80 additions & 0 deletions
80
yamcs-core/src/main/java/org/yamcs/http/api/KeyManagementApi.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,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()); | ||
} | ||
|
||
} |
Oops, something went wrong.