[3612811] | 1 | package net.deterlab.abac; |
---|
| 2 | |
---|
| 3 | import java.io.*; |
---|
| 4 | import java.math.*; |
---|
| 5 | |
---|
| 6 | import java.util.*; |
---|
| 7 | import java.security.*; |
---|
| 8 | import java.security.cert.*; |
---|
| 9 | |
---|
| 10 | import javax.security.auth.x500.*; |
---|
| 11 | |
---|
| 12 | import org.bouncycastle.asn1.*; |
---|
| 13 | import org.bouncycastle.asn1.x509.*; |
---|
| 14 | import org.bouncycastle.x509.*; |
---|
| 15 | import org.bouncycastle.x509.util.*; |
---|
| 16 | import org.bouncycastle.openssl.*; |
---|
| 17 | |
---|
| 18 | /** |
---|
| 19 | * An Internal Credential, used to represent extra arcs in the proof graph. It |
---|
| 20 | * should never be converted to a cert or output. |
---|
| 21 | * @author <a href="http://abac.deterlab.net">ISI ABAC team</a> |
---|
[4560b65] | 22 | * @version 1.4 |
---|
[3612811] | 23 | */ |
---|
| 24 | public class InternalCredential extends Credential { |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * Create an empty InternalCredential. |
---|
| 28 | */ |
---|
| 29 | public InternalCredential() { super(); } |
---|
| 30 | /** |
---|
| 31 | * Create a credential from a head and tail role. This credential has no |
---|
| 32 | * underlying certificate, and cannot be exported or used in real proofs. |
---|
| 33 | * @param head the Role at the head of the credential |
---|
| 34 | * @param tail the Role at the tail of the credential |
---|
| 35 | */ |
---|
| 36 | public InternalCredential(Role head, Role tail) {super(head, tail); } |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * Create a credential from an attribute cert in a file. This will always |
---|
| 40 | * fail for in InternalCredential. |
---|
| 41 | * @param filename a String containing the filename to read |
---|
| 42 | * @param ids a Collection of Identities to use in validating the cert |
---|
| 43 | * @throws CertInvalidException if the stream is unparsable |
---|
| 44 | * @throws MissingIssuerException if none of the Identities can validate the |
---|
| 45 | * certificate |
---|
| 46 | * @throws BadSignatureException if the signature check fails |
---|
| 47 | */ |
---|
| 48 | public InternalCredential(String filename, Collection<Identity> ids) |
---|
| 49 | throws ABACException { this(); } |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | * Create a credential from an attribute cert in a file. This will always |
---|
| 53 | * * fail for in InternalCredential. |
---|
| 54 | * @param file the File to read |
---|
| 55 | * @param ids a Collection of Identities to use in validating the cert |
---|
| 56 | * @throws CertInvalidException if the stream is unparsable |
---|
| 57 | * @throws MissingIssuerException if none of the Identities can validate the |
---|
| 58 | * certificate |
---|
| 59 | * @throws BadSignatureException if the signature check fails |
---|
| 60 | */ |
---|
| 61 | public InternalCredential(File file, Collection<Identity> ids) |
---|
| 62 | throws ABACException { |
---|
| 63 | this(); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * Create a credential from an InputStream. This will always |
---|
| 68 | * fail for in InternalCredential. |
---|
| 69 | * @param ids a Collection of Identities to use in validating the cert |
---|
| 70 | * @throws CertInvalidException if the stream is unparsable |
---|
| 71 | * @throws MissingIssuerException if none of the Identities can validate the |
---|
| 72 | * certificate |
---|
| 73 | * @throws BadSignatureException if the signature check fails |
---|
| 74 | */ |
---|
| 75 | public InternalCredential(InputStream s, Collection<Identity> ids) |
---|
| 76 | throws ABACException { |
---|
| 77 | this(); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | /** |
---|
| 82 | * Create a certificate from this credential issued by the given identity. |
---|
| 83 | * This will always fail for an InternalCredential. |
---|
| 84 | * @param i the Identity that will issue the certificate |
---|
| 85 | * @throws ABACException for Credential-specific errors |
---|
| 86 | * @throws MissingIssuerException the identity is invalid |
---|
| 87 | * @throws BadSignatureException if the signature creation fails |
---|
| 88 | */ |
---|
| 89 | public void make_cert(Identity i) throws ABACException { |
---|
| 90 | throw new ABACException("Cannot create certificate for " + |
---|
| 91 | "an InternalCredential"); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | /** |
---|
| 95 | * Output the DER formatted attribute certificate associated with this |
---|
| 96 | * Credential to the OutputStream. This will always fail for an |
---|
| 97 | * InternalCredential. |
---|
| 98 | * @param s the OutputStream on which to write |
---|
| 99 | * @throws IOException if there is an error writing. |
---|
| 100 | */ |
---|
| 101 | public void write(OutputStream s) throws IOException { |
---|
| 102 | throw new IOException("Cannot write certificate for " + |
---|
| 103 | "an InternalCredential"); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | /** |
---|
| 107 | * Output the DER formatted attribute certificate associated with this |
---|
| 108 | * Credential to the filename given. This will always fail for an |
---|
| 109 | * InternalCredential. |
---|
| 110 | * @param fn a String containing the output filename |
---|
| 111 | * @throws IOException if there is an error writing. |
---|
| 112 | */ |
---|
| 113 | public void write(String fn) |
---|
| 114 | throws IOException, FileNotFoundException { |
---|
| 115 | write((OutputStream) null); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | /** |
---|
| 119 | * Return true if this Credential has a certificate associated. A jabac |
---|
| 120 | * extension. Always false for an InternalCredential. |
---|
| 121 | * @return true if this Credential has a certificate associated. |
---|
| 122 | */ |
---|
| 123 | public boolean hasCertificate() { return false; } |
---|
| 124 | |
---|
| 125 | } |
---|