🔍 Code Extractor

class Pkcs12CertificateInformation

Maturity: 49

A data class that represents the public information of a PKCS#12 certificate, including thumbprint, active status, and validity period.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/certificates/pkcs12_information.py
Lines:
4 - 22
Complexity:
simple

Purpose

This class serves as a data container for PKCS#12 certificate metadata within the Office365 API framework. It inherits from ClientValue, making it suitable for serialization and transmission in API requests/responses. The class stores essential certificate information including the certificate's thumbprint (unique identifier), activation status, and validity time range (notBefore and notAfter timestamps). This is typically used when working with SharePoint or other Office365 services that require certificate-based authentication or certificate management operations.

Source Code

class Pkcs12CertificateInformation(ClientValue):
    """Represents the public information of a Pkcs12 certificate."""

    def __init__(
        self, thumbprint=None, is_active=None, not_after=None, not_before=None
    ):
        """
        :param str thumbprint: The certificate thumbprint
        :param long not_after: The certificate's expiry. This value is a NumericDate as defined in RFC 7519
           (A JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified
           UTC date/time, ignoring leap seconds.)
        :param long not_before: The certificate's issue time (not before).
            This value is a NumericDate as defined in RFC 7519 (A JSON numeric value representing the number
            of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds.)
        """
        self.thumbprint = thumbprint
        self.isActive = is_active
        self.notAfter = not_after
        self.notBefore = not_before

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

thumbprint: A string representing the certificate's thumbprint (hash), which serves as a unique identifier for the certificate. This is typically a hexadecimal string generated from the certificate's contents. Can be None if not yet set.

is_active: A boolean indicating whether the certificate is currently active and valid for use. Can be None if the status is unknown or not yet determined.

not_after: A long integer representing the certificate's expiration date/time as a NumericDate (RFC 7519 format). This is the number of seconds from 1970-01-01T00:00:00Z UTC (Unix epoch) until the certificate expires, ignoring leap seconds. Can be None if not specified.

not_before: A long integer representing the certificate's issue time (start of validity period) as a NumericDate (RFC 7519 format). This is the number of seconds from 1970-01-01T00:00:00Z UTC (Unix epoch) until the certificate becomes valid, ignoring leap seconds. Can be None if not specified.

Return Value

Instantiation returns a Pkcs12CertificateInformation object with the specified certificate metadata. The object contains four instance attributes (thumbprint, isActive, notAfter, notBefore) that can be accessed and modified. As a ClientValue subclass, the object can be serialized for API communication.

Class Interface

Methods

__init__(self, thumbprint=None, is_active=None, not_after=None, not_before=None)

Purpose: Initializes a new instance of Pkcs12CertificateInformation with certificate metadata

Parameters:

  • thumbprint: String representing the certificate's unique thumbprint/hash identifier
  • is_active: Boolean indicating if the certificate is currently active
  • not_after: Long integer (Unix timestamp) representing when the certificate expires
  • not_before: Long integer (Unix timestamp) representing when the certificate becomes valid

Returns: None (constructor)

Attributes

Name Type Description Scope
thumbprint str The certificate's thumbprint (hash-based unique identifier), typically a hexadecimal string instance
isActive bool Boolean flag indicating whether the certificate is currently active and valid for use instance
notAfter long Unix timestamp (NumericDate per RFC 7519) representing the certificate's expiration date/time instance
notBefore long Unix timestamp (NumericDate per RFC 7519) representing when the certificate becomes valid (issue time) instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue
from datetime import datetime

# Create a certificate information object with all parameters
cert_info = Pkcs12CertificateInformation(
    thumbprint="A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q7R8S9T0",
    is_active=True,
    not_after=1735689600,  # Unix timestamp for expiry date
    not_before=1704067200  # Unix timestamp for issue date
)

# Access certificate properties
print(f"Thumbprint: {cert_info.thumbprint}")
print(f"Is Active: {cert_info.isActive}")
print(f"Expires: {cert_info.notAfter}")
print(f"Valid From: {cert_info.notBefore}")

# Create with minimal information
cert_info_minimal = Pkcs12CertificateInformation(
    thumbprint="A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q7R8S9T0"
)

# Modify attributes after instantiation
cert_info_minimal.isActive = True
cert_info_minimal.notAfter = 1735689600

Best Practices

  • This is a simple data container class with no methods beyond __init__, so instantiation is straightforward with no complex lifecycle management.
  • All constructor parameters are optional and default to None, allowing flexible instantiation based on available certificate information.
  • Note the naming convention change: the parameter 'is_active' becomes the attribute 'isActive' (camelCase), following the Office365 API naming conventions.
  • The notAfter and notBefore values should be Unix timestamps (seconds since epoch) as per RFC 7519 NumericDate format.
  • As a ClientValue subclass, this object is designed for serialization in API communications, so it should be treated as a data transfer object (DTO).
  • The thumbprint is typically a SHA-1 or SHA-256 hash of the certificate, represented as a hexadecimal string.
  • When working with timestamps, consider using Python's datetime module to convert between human-readable dates and Unix timestamps.
  • This class does not perform validation on the input values, so ensure that thumbprints are valid and timestamps are in the correct format before instantiation.

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SelfSignedCertificate 74.5% similar

    A data class representing the public part of a self-signed certificate, inheriting from ClientValue for use in Office 365 API operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/certificates/self_signed.py
  • class CertificateAuthority 72.6% similar

    A data class representing a certificate authority with its associated properties such as certificate, revocation list URL, and issuer information.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/certificates/authority.py
  • class Certification 68.6% similar

    A data class representing certification details of an application, inheriting from ClientValue to provide serialization capabilities for Office 365 API interactions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/certificates/certification.py
  • class ClientCertificateAuthentication 67.7% similar

    A class representing Pkcs12-based client certificate authentication configuration, derived from ApiAuthenticationConfigurationBase, used to manage and retrieve public properties of uploaded certificates.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/authentication/client_certificate.py
  • class TenantAppInformation 58.4% similar

    A data class that represents information about a tenant-scoped application in Office 365, including its principal ID, web URL, and creation timestamp.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/apps/information.py
← Back to Browse