mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-23 18:04:54 +02:00
Show suspended/active state for child CAs. (#656)
This commit is contained in:
+35
-2
@@ -141,23 +141,55 @@ impl From<&IdCert> for IdCertPem {
|
||||
}
|
||||
}
|
||||
|
||||
//------------ ChildState ----------------------------------------------------
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ChildState {
|
||||
Active,
|
||||
Suspended,
|
||||
}
|
||||
|
||||
impl Default for ChildState {
|
||||
fn default() -> Self {
|
||||
ChildState::Active
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ChildState {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match &self {
|
||||
ChildState::Active => "active",
|
||||
ChildState::Suspended => "suspended",
|
||||
}
|
||||
.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
//------------ ChildCaInfo ---------------------------------------------------
|
||||
|
||||
/// This type represents information about a child CA that is shared through the API.
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct ChildCaInfo {
|
||||
state: ChildState,
|
||||
id_cert: IdCertPem,
|
||||
entitled_resources: ResourceSet,
|
||||
}
|
||||
|
||||
impl ChildCaInfo {
|
||||
pub fn new(id_cert: IdCertPem, entitled_resources: ResourceSet) -> Self {
|
||||
pub fn new(state: ChildState, id_cert: IdCertPem, entitled_resources: ResourceSet) -> Self {
|
||||
ChildCaInfo {
|
||||
state,
|
||||
id_cert,
|
||||
entitled_resources,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn state(&self) -> ChildState {
|
||||
self.state
|
||||
}
|
||||
|
||||
pub fn id_cert(&self) -> &IdCertPem {
|
||||
&self.id_cert
|
||||
}
|
||||
@@ -171,7 +203,8 @@ impl fmt::Display for ChildCaInfo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "{}", self.id_cert.pem())?;
|
||||
writeln!(f, "SHA256 hash of PEM encoded certificate: {}", self.id_cert.hash())?;
|
||||
writeln!(f, "resources: {}", self.entitled_resources)
|
||||
writeln!(f, "resources: {}", self.entitled_resources)?;
|
||||
writeln!(f, "state: {}", self.state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-16
@@ -6,7 +6,7 @@ use rpki::repository::crypto::KeyIdentifier;
|
||||
use rpki::repository::x509::Time;
|
||||
|
||||
use crate::commons::api::{
|
||||
ChildCaInfo, ChildHandle, IssuedCert, ResourceClassName, ResourceSet, SuspendedCert, UnsuspendedCert,
|
||||
ChildCaInfo, ChildHandle, ChildState, IssuedCert, ResourceClassName, ResourceSet, SuspendedCert, UnsuspendedCert,
|
||||
};
|
||||
use crate::commons::crypto::IdCert;
|
||||
use crate::commons::error::Error;
|
||||
@@ -25,20 +25,6 @@ pub enum UsedKeyState {
|
||||
Revoked,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ChildState {
|
||||
Active,
|
||||
Suspended,
|
||||
}
|
||||
|
||||
impl Default for ChildState {
|
||||
fn default() -> Self {
|
||||
ChildState::Active
|
||||
}
|
||||
}
|
||||
|
||||
//------------ ChildInfo ---------------------------------------------------
|
||||
|
||||
/// Contains information about a child CA needed by a parent [CertAuth](ca.CertAuth).
|
||||
@@ -135,7 +121,7 @@ impl ChildDetails {
|
||||
|
||||
impl From<ChildDetails> for ChildCaInfo {
|
||||
fn from(details: ChildDetails) -> Self {
|
||||
ChildCaInfo::new((&details.id_cert).into(), details.resources)
|
||||
ChildCaInfo::new(details.state, (&details.id_cert).into(), details.resources)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user