001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.geronimo.management.geronimo;
018
019 import java.math.BigInteger;
020 import java.security.PublicKey;
021 import java.security.cert.Certificate;
022 import java.util.Date;
023
024 import javax.security.auth.x500.X500Principal;
025
026 import org.apache.geronimo.management.geronimo.CertificationAuthorityException;
027
028 /**
029 * Management interface for dealing with a specific CertificationAuthority.
030 *
031 * @version $Rev: 487175 $ $Date: 2006-12-14 03:10:31 -0800 (Thu, 14 Dec 2006) $
032 */
033 public interface CertificationAuthority {
034
035 /**
036 * This method checks if the CA is locked.
037 * @return true if CA is locked, false otherwise.
038 */
039 public abstract boolean isLocked();
040
041 /**
042 * This method locks the CA.
043 */
044 public abstract void lock();
045
046 /**
047 * This method unlocks the CA.
048 * @param password Password to unlock the CA.
049 */
050 public abstract void unlock(char[] password) throws CertificationAuthorityException;
051
052 /**
053 * This method returns CA's name.
054 * @throws Exception if CA is locked.
055 */
056 public abstract X500Principal getName() throws CertificationAuthorityException;
057
058 /**
059 * This method returns CA's own certificate.
060 * @throws Exception if CA is locked.
061 */
062 public abstract Certificate getCertificate() throws CertificationAuthorityException;
063
064 /**
065 * This method makes the CA issue a self-signed certificate with given details. This method is usually
066 * called while initializing the CA.
067 *
068 * @param sNo Serial number for self-signed certificate
069 * @param validFromDate Certificate validity period start date
070 * @param validToDate Certificate validity period end date
071 * @param algorithm Signature algorithm for self-signed certificate
072 */
073 public abstract void issueOwnCertificate(BigInteger sNo, Date validFromDate, Date validToDate, String algorithm) throws CertificationAuthorityException;
074
075 /**
076 * This method issues a certificate.
077 *
078 * @param subject Subject name
079 * @param publicKey Subject's public key
080 * @param sNo Serial number for the certificate to be issued
081 * @param validFromDate Certificate validity period start date
082 * @param validToDate Certificate validity period end date
083 * @param algorithm Signature algorithm for the certificate
084 * @return newly issued certificate
085 */
086 public abstract Certificate issueCertificate(X500Principal subject, PublicKey publicKey, BigInteger sNo, Date validFromDate, Date validToDate, String algorithm) throws CertificationAuthorityException;
087
088 /**
089 * This method returns the highest serial number used by the CA.
090 */
091 public abstract BigInteger getHighestSerialNumber() throws CertificationAuthorityException;
092
093 /**
094 * This method checks if a Certificate with a given serial number is already issued.
095 * @param sNo The serial number of the the certificate to be looked for
096 * @return true if a certificate with the specified serial number has already been issued
097 */
098 public abstract boolean isCertificateIssued(BigInteger sNo) throws CertificationAuthorityException;
099
100 /**
101 * This method returns the next serial number that can be used to issue a certificate and increments the
102 * highest serial number.
103 */
104 public abstract BigInteger getNextSerialNumber() throws CertificationAuthorityException;
105
106 /**
107 * This method retrieves a certificate with the specified serial number.
108 * @param sNo The serial number of the certificate to be retrieved
109 * @return java.security.cert.Certificate instance of the certificate
110 */
111 public abstract Certificate getCertificate(BigInteger sNo) throws CertificationAuthorityException;
112
113 /**
114 * This method retrieves a certificate with the specified serial number.
115 * @param sNo The serial number of the certificate to be retrieved
116 * @return base64 encoded certificate text
117 */
118 public abstract String getCertificateBase64Text(BigInteger sNo) throws CertificationAuthorityException;
119 }