001 /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
002 *
003 * Redistribution and use in source and binary forms, with or without
004 * modification, are permitted provided that the following conditions are met:
005 *
006 * 1. Redistributions of source code must retain the above copyright notice,
007 * this list of conditions and the following disclaimer.
008 *
009 * 2. Redistributions in binary form must reproduce the above copyright notice,
010 * this list of conditions and the following disclaimer in the documentation
011 * and/or other materials provided with the distribution.
012 *
013 * 3. The end-user documentation included with the redistribution, if any, must
014 * include the following acknowledgment:
015 *
016 * "This product includes software developed by IAIK of Graz University of
017 * Technology."
018 *
019 * Alternately, this acknowledgment may appear in the software itself, if
020 * and wherever such third-party acknowledgments normally appear.
021 *
022 * 4. The names "Graz University of Technology" and "IAIK of Graz University of
023 * Technology" must not be used to endorse or promote products derived from
024 * this software without prior written permission.
025 *
026 * 5. Products derived from this software may not be called
027 * "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
028 * written permission of Graz University of Technology.
029 *
030 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
031 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
032 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
033 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
034 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
035 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
036 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
037 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
038 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
039 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
040 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
041 * POSSIBILITY OF SUCH DAMAGE.
042 */
043
044 package demo.pkcs.pkcs11;
045
046 import iaik.pkcs.pkcs11.objects.Key;
047 import iaik.pkcs.pkcs11.objects.X509PublicKeyCertificate;
048
049
050
051 /**
052 * This class encapsulates a key and an optional certificate.
053 *
054 * @author <a href="mailto:Karl.Scheibelhofer@iaik.at"> Karl Scheibelhofer </a>
055 * @version 0.1
056 * @invariants
057 */
058 public class KeyAndCertificate {
059
060 /**
061 * The key.
062 */
063 protected Key key_;
064
065 /**
066 * This optional certificate.
067 */
068 protected X509PublicKeyCertificate certificate_;
069
070 /**
071 * Creates a new object that holds the given key and certificate.
072 *
073 * @param key The key.
074 * @param certificate The certificate.
075 * @preconditions
076 * @postconditions
077 */
078 public KeyAndCertificate(Key key, X509PublicKeyCertificate certificate) {
079 key_ = key;
080 certificate_ = certificate;
081 }
082
083 /**
084 * Returns the certificate.
085 *
086 * @return The certificate.
087 * @preconditions
088 * @postconditions
089 */
090 public X509PublicKeyCertificate getCertificate() {
091 return certificate_ ;
092 }
093
094 /**
095 * Returns the key.
096 *
097 * @return The key.
098 * @preconditions
099 * @postconditions
100 */
101 public Key getKey() {
102 return key_ ;
103 }
104
105 /**
106 * Sets the certificate.
107 *
108 * @param certificate The certificate.
109 * @preconditions
110 * @postconditions
111 */
112 public void setCertificate(X509PublicKeyCertificate certificate) {
113 certificate_ = certificate;
114 }
115
116 /**
117 * Sets the key.
118 *
119 * @param key The key.
120 * @preconditions
121 * @postconditions
122 */
123 public void setKey(Key key) {
124 key_ = key;
125 }
126
127 }