Struct apple_codesign::app_store_connect::UnifiedApiKey
source · pub struct UnifiedApiKey { /* private fields */ }
Expand description
Represents all metadata for an App Store Connect API Key.
This is a convenience type to aid in the generic representation of all the components of an App Store Connect API Key. The type supports serialization so we save as a single file or payload to enhance usability (so people don’t need to provide all 3 pieces of the API Key for all operations).
Implementations§
source§impl UnifiedApiKey
impl UnifiedApiKey
sourcepub fn from_ecdsa_pem_path(
issuer_id: impl ToString,
key_id: impl ToString,
path: impl AsRef<Path>
) -> Result<Self, AppleCodesignError>
pub fn from_ecdsa_pem_path(
issuer_id: impl ToString,
key_id: impl ToString,
path: impl AsRef<Path>
) -> Result<Self, AppleCodesignError>
Construct an instance from constitute parts and a PEM encoded ECDSA private key.
This is what you want to use if importing a private key from the file downloaded from the App Store Connect web interface.
Examples found in repository?
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
fn command_encode_app_store_connect_api_key(args: &ArgMatches) -> Result<(), AppleCodesignError> {
let issuer_id = args
.get_one::<String>("issuer_id")
.expect("arg should have been required");
let key_id = args
.get_one::<String>("key_id")
.expect("arg should have been required");
let private_key_path = args
.get_one::<PathBuf>("private_key_path")
.expect("arg should have been required");
let unified = UnifiedApiKey::from_ecdsa_pem_path(issuer_id, key_id, private_key_path)?;
if let Some(output_path) = args.get_one::<PathBuf>("output_path") {
eprintln!("writing unified key JSON to {}", output_path.display());
unified.write_json_file(output_path)?;
eprintln!(
"consider auditing the file's access permissions to ensure its content remains secure"
);
} else {
println!("{}", unified.to_json_string()?);
}
Ok(())
}
sourcepub fn from_json(data: impl AsRef<[u8]>) -> Result<Self, AppleCodesignError>
pub fn from_json(data: impl AsRef<[u8]>) -> Result<Self, AppleCodesignError>
Construct an instance from serialized JSON.
sourcepub fn from_json_path(
path: impl AsRef<Path>
) -> Result<Self, AppleCodesignError>
pub fn from_json_path(
path: impl AsRef<Path>
) -> Result<Self, AppleCodesignError>
Construct an instance from a JSON file.
Examples found in repository?
1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918
fn notarizer_from_args(
args: &ArgMatches,
) -> Result<crate::notarization::Notarizer, AppleCodesignError> {
let api_key_path = args.get_one::<PathBuf>("api_key_path");
let api_issuer = args.get_one::<String>("api_issuer");
let api_key = args.get_one::<String>("api_key");
let mut notarizer = crate::notarization::Notarizer::new()?;
if let Some(api_key_path) = api_key_path {
let unified = UnifiedApiKey::from_json_path(api_key_path)?;
notarizer.set_token_encoder(unified.try_into()?);
} else if let (Some(issuer), Some(key)) = (api_issuer, api_key) {
notarizer.set_api_key(issuer, key)?;
}
Ok(notarizer)
}
sourcepub fn to_json_string(&self) -> Result<String, AppleCodesignError>
pub fn to_json_string(&self) -> Result<String, AppleCodesignError>
Serialize this instance to a JSON object.
Examples found in repository?
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
pub fn write_json_file(&self, path: impl AsRef<Path>) -> Result<(), AppleCodesignError> {
let path = path.as_ref();
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)?;
}
let data = self.to_json_string()?;
let mut fh = std::fs::File::create(path)?;
let mut permissions = fh.metadata()?.permissions();
set_permissions_private(&mut permissions);
fh.set_permissions(permissions)?;
fh.write_all(data.as_bytes())?;
Ok(())
}
More examples
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
fn command_encode_app_store_connect_api_key(args: &ArgMatches) -> Result<(), AppleCodesignError> {
let issuer_id = args
.get_one::<String>("issuer_id")
.expect("arg should have been required");
let key_id = args
.get_one::<String>("key_id")
.expect("arg should have been required");
let private_key_path = args
.get_one::<PathBuf>("private_key_path")
.expect("arg should have been required");
let unified = UnifiedApiKey::from_ecdsa_pem_path(issuer_id, key_id, private_key_path)?;
if let Some(output_path) = args.get_one::<PathBuf>("output_path") {
eprintln!("writing unified key JSON to {}", output_path.display());
unified.write_json_file(output_path)?;
eprintln!(
"consider auditing the file's access permissions to ensure its content remains secure"
);
} else {
println!("{}", unified.to_json_string()?);
}
Ok(())
}
sourcepub fn write_json_file(
&self,
path: impl AsRef<Path>
) -> Result<(), AppleCodesignError>
pub fn write_json_file(
&self,
path: impl AsRef<Path>
) -> Result<(), AppleCodesignError>
Write this instance to a JSON file.
Since the file contains sensitive data, it will have limited read permissions on platforms where this is implemented. Parent directories will be created if missing using default permissions for created directories.
Permissions on the resulting file may not be as restrictive as desired. It is up to callers to additionally harden as desired.
Examples found in repository?
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
fn command_encode_app_store_connect_api_key(args: &ArgMatches) -> Result<(), AppleCodesignError> {
let issuer_id = args
.get_one::<String>("issuer_id")
.expect("arg should have been required");
let key_id = args
.get_one::<String>("key_id")
.expect("arg should have been required");
let private_key_path = args
.get_one::<PathBuf>("private_key_path")
.expect("arg should have been required");
let unified = UnifiedApiKey::from_ecdsa_pem_path(issuer_id, key_id, private_key_path)?;
if let Some(output_path) = args.get_one::<PathBuf>("output_path") {
eprintln!("writing unified key JSON to {}", output_path.display());
unified.write_json_file(output_path)?;
eprintln!(
"consider auditing the file's access permissions to ensure its content remains secure"
);
} else {
println!("{}", unified.to_json_string()?);
}
Ok(())
}
Trait Implementations§
source§impl Clone for UnifiedApiKey
impl Clone for UnifiedApiKey
source§fn clone(&self) -> UnifiedApiKey
fn clone(&self) -> UnifiedApiKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for UnifiedApiKey
impl Debug for UnifiedApiKey
source§impl<'de> Deserialize<'de> for UnifiedApiKey
impl<'de> Deserialize<'de> for UnifiedApiKey
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Serialize for UnifiedApiKey
impl Serialize for UnifiedApiKey
source§impl TryFrom<UnifiedApiKey> for ConnectTokenEncoder
impl TryFrom<UnifiedApiKey> for ConnectTokenEncoder
§type Error = AppleCodesignError
type Error = AppleCodesignError
Auto Trait Implementations§
impl RefUnwindSafe for UnifiedApiKey
impl Send for UnifiedApiKey
impl Sync for UnifiedApiKey
impl Unpin for UnifiedApiKey
impl UnwindSafe for UnifiedApiKey
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.