mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-13 20:12:16 -06:00
Initial commit
This commit is contained in:
39
lib/features/login/model/client_certificate.dart
Normal file
39
lib/features/login/model/client_certificate.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_paperless_mobile/core/type/json.dart';
|
||||
|
||||
class ClientCertificate {
|
||||
static const bytesKey = 'bytes';
|
||||
static const passphraseKey = 'passphrase';
|
||||
|
||||
final Uint8List bytes;
|
||||
final String? passphrase;
|
||||
|
||||
ClientCertificate({required this.bytes, this.passphrase});
|
||||
|
||||
static ClientCertificate? nullable(Uint8List? bytes, {String? passphrase}) {
|
||||
if (bytes != null) {
|
||||
return ClientCertificate(bytes: bytes, passphrase: passphrase);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
JSON toJson() {
|
||||
return {
|
||||
bytesKey: base64Encode(bytes),
|
||||
passphraseKey: passphrase,
|
||||
};
|
||||
}
|
||||
|
||||
ClientCertificate.fromJson(JSON json)
|
||||
: bytes = base64Decode(json[bytesKey]),
|
||||
passphrase = json[passphraseKey];
|
||||
|
||||
ClientCertificate copyWith({Uint8List? bytes, String? passphrase}) {
|
||||
return ClientCertificate(
|
||||
bytes: bytes ?? this.bytes,
|
||||
passphrase: passphrase ?? this.passphrase,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user