001    /**
002     *
003     *  Licensed to the Apache Software Foundation (ASF) under one or more
004     *  contributor license agreements.  See the NOTICE file distributed with
005     *  this work for additional information regarding copyright ownership.
006     *  The ASF licenses this file to You under the Apache License, Version 2.0
007     *  (the "License"); you may not use this file except in compliance with
008     *  the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing, software
013     *  distributed under the License is distributed on an "AS IS" BASIS,
014     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     *  See the License for the specific language governing permissions and
016     *  limitations under the License.
017     */
018    package org.apache.geronimo.management.geronimo;
019    
020    import java.math.BigInteger;
021    import java.security.cert.Certificate;
022    
023    /**
024     * Management interface for dealing with a specific Certificate Store
025     *
026     * @version $Rev: 476291 $ $Date: 2006-11-17 15:05:24 -0500 (Fri, 17 Nov 2006) $
027     */
028    public interface CertificateStore {
029        /**
030         * This method stores a given certificate.
031         * 
032         * @param cert Certificate to be stored
033         */
034        public void storeCertificate(Certificate cert) throws CertificateStoreException;
035    
036        /**
037         * This method returns a Certificate with a given serial number (if it exists in the store)
038         * 
039         * @param sNo Serial Number of the certificate to be retrieved.
040         */
041        public Certificate getCertificate(BigInteger sNo) throws CertificateStoreException;
042    
043        /**
044         * This method returns base64 encoded certificate with a given serial number (if it exists in the store)
045         * 
046         * @param sNo Serial Number of the certificate to be retrieved.
047         */
048        public String getCertificateBase64Text(BigInteger sNo) throws CertificateStoreException;
049    
050        /**
051         * This method returns the highest certificate serial number in the store.
052         */
053        public BigInteger getHighestSerialNumber() throws CertificateStoreException;
054    
055        /**
056         * This method returns the 'highest certificate serial number plus ONE' and increments the highest
057         * serial number in the store.
058         */
059        public BigInteger getNextSerialNumber() throws CertificateStoreException;
060    
061        /**
062         * This method checks if a certificate with a given serial number exists in the store.
063         * 
064         * @param sNo Serial number of the certificate to be checked
065         */
066        public boolean containsCertificate(BigInteger sNo);
067    
068        /**
069         * This method stores the CA's certificate in the store.
070         * @param cert CA's certificate
071         */
072        public boolean storeCACertificate(Certificate cert) throws CertificateStoreException;
073    
074        /**
075         * This method returns the CA's certificate stored in the store.
076         */
077        public Certificate getCACertificate() throws CertificateStoreException;
078    
079        /**
080         * This method stores the challenge phrase against the specified certificate serial number
081         * @param sNo  Serial number of the certificate
082         * @param challenge Challenge phrase
083         */
084        public boolean setCertificateChallenge(BigInteger sNo, String challenge) throws CertificateStoreException;
085    }