All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.idsec.x509cert.extensions.PrivateKeyUsagePeriod Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2020. IDsec Solutions AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package se.idsec.x509cert.extensions;

import lombok.Getter;
import org.bouncycastle.asn1.*;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.Extensions;

import java.util.Date;

/**
 * Private key usage period X.509 extension implementation for extending Bouncycastle
 *
 * The AuthorityInformationAccess object.
 * 
 * id-pe-subjectInfoAccess OBJECT IDENTIFIER ::= { id-pe 11 }
 *
 * SubjectInfoAccessSyntax  ::=
 *      SEQUENCE SIZE (1..MAX) OF AccessDescription
 * AccessDescription  ::=  SEQUENCE {
 *       accessMethod          OBJECT IDENTIFIER,
 *       accessLocation        GeneralName  }
 *
 * 
* @author Martin Lindström ([email protected]) * @author Stefan Santesson ([email protected]) */ public class PrivateKeyUsagePeriod extends ASN1Object { /** Start time for usage of private key */ @Getter private Date notBefore; /** End time for usage of private key */ @Getter private Date notAfter; /** * Creates an instance of the PrivateKeyUsagePeriod extension * @param obj object holding extension data * @return {@link PrivateKeyUsagePeriod} extension */ public static PrivateKeyUsagePeriod getInstance( Object obj) { if (obj instanceof PrivateKeyUsagePeriod) { return (PrivateKeyUsagePeriod) obj; } if (obj != null) { return new PrivateKeyUsagePeriod(ASN1Sequence.getInstance(obj)); } return null; } /** * Creates an instance of the PrivateKeyUsagePeriod extension * @param extensions extensions data * @return {@link PrivateKeyUsagePeriod} extension */ public static PrivateKeyUsagePeriod fromExtensions(Extensions extensions) { return PrivateKeyUsagePeriod.getInstance(extensions.getExtensionParsedValue(Extension.authorityInfoAccess)); } /** * Private constructor based on asn.1 sequence. This is used by the public getInstance function * @param seq ASN.1 sequence */ private PrivateKeyUsagePeriod(ASN1Sequence seq) { for (int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy