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 java.security.PrivateKey; 047 048 import iaik.pkcs.pkcs11.objects.PrivateKey; 049 050 051 052 /** 053 * This is an adapter class that allows to use token keys as JCA private keys. 054 * An application can use this class whereever an interface requires the 055 * application to pass an JCA private key; e.g. for signing. 056 * 057 * @author <a href="mailto:Karl.Scheibelhofer@iaik.at"> Karl Scheibelhofer </a> 058 * @version 0.1 059 * @invariants 060 */ 061 public class TokenPrivateKey implements java.security.PrivateKey { 062 063 /** 064 * The PKCS#11 private key of this object. 065 */ 066 protected PrivateKey tokenPrivateKey_; 067 068 /** 069 * Create a new JCA private key that uses the given PKCS#11 private key 070 * internally. 071 * 072 * @param tokenPrivateKey The PKCS#11 private key that this object refers to. 073 * @preconditions 074 * @postconditions 075 */ 076 public TokenPrivateKey(PrivateKey tokenPrivateKey) { 077 tokenPrivateKey_ = tokenPrivateKey; 078 } 079 080 /** 081 * Just returns null. 082 * 083 * @return null. 084 * @preconditions 085 * @postconditions (result == null) 086 */ 087 public String getAlgorithm() { 088 return null ; 089 } 090 091 /** 092 * Just returns null. 093 * 094 * @return null. 095 * @preconditions 096 * @postconditions (result == null) 097 */ 098 public String getFormat() { 099 return null ; 100 } 101 102 /** 103 * Just returns null. 104 * 105 * @return null. 106 * @preconditions 107 * @postconditions (result == null) 108 */ 109 public byte[] getEncoded() { 110 return null ; 111 } 112 113 /** 114 * Returns the PKCS#11 private key object that this object refers to. 115 * 116 * @return The KCS#11 private key object that this object refers to. 117 * @preconditions 118 * @postconditions 119 */ 120 public PrivateKey getTokenPrivateKey() { 121 return tokenPrivateKey_ ; 122 } 123 124 }