| 1 | /* Identity.java --- Identity Class
|
|---|
| 2 | Copyright (C) 1999 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU Classpath.
|
|---|
| 5 |
|
|---|
| 6 | GNU Classpath is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | GNU Classpath is distributed in the hope that it will be useful, but
|
|---|
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 14 | General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
|---|
| 18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 19 | 02111-1307 USA.
|
|---|
| 20 |
|
|---|
| 21 | Linking this library statically or dynamically with other modules is
|
|---|
| 22 | making a combined work based on this library. Thus, the terms and
|
|---|
| 23 | conditions of the GNU General Public License cover the whole
|
|---|
| 24 | combination.
|
|---|
| 25 |
|
|---|
| 26 | As a special exception, the copyright holders of this library give you
|
|---|
| 27 | permission to link this library with independent modules to produce an
|
|---|
| 28 | executable, regardless of the license terms of these independent
|
|---|
| 29 | modules, and to copy and distribute the resulting executable under
|
|---|
| 30 | terms of your choice, provided that you also meet, for each linked
|
|---|
| 31 | independent module, the terms and conditions of the license of that
|
|---|
| 32 | module. An independent module is a module which is not derived from
|
|---|
| 33 | or based on this library. If you modify this library, you may extend
|
|---|
| 34 | this exception to your version of the library, but you are not
|
|---|
| 35 | obligated to do so. If you do not wish to do so, delete this
|
|---|
| 36 | exception statement from your version. */
|
|---|
| 37 |
|
|---|
| 38 | package java.security;
|
|---|
| 39 | import java.io.Serializable;
|
|---|
| 40 | import java.util.Vector;
|
|---|
| 41 |
|
|---|
| 42 | /**
|
|---|
| 43 | The Identity class is used to repsent people and companies that
|
|---|
| 44 | can be authenticated using public key encryption. The identities
|
|---|
| 45 | can also be abstract objects such as smart cards.
|
|---|
| 46 |
|
|---|
| 47 | Identity object store a name and public key for each identity.
|
|---|
| 48 | The names cannot be changed and the identities can be scoped.
|
|---|
| 49 | Each identity (name and public key) within a scope is unique
|
|---|
| 50 | to that scope.
|
|---|
| 51 |
|
|---|
| 52 | Each identity has a set of ceritificates which all specify the
|
|---|
| 53 | same public key but not necessarily the same name.
|
|---|
| 54 |
|
|---|
| 55 | The Identity class can be subclassed to allow additional
|
|---|
| 56 | information to be attached to it.
|
|---|
| 57 |
|
|---|
| 58 | @since JDK 1.1
|
|---|
| 59 |
|
|---|
| 60 | @deprecated Use java.security.KeyStore, the java.security.cert
|
|---|
| 61 | package, and java.security.Principal.
|
|---|
| 62 |
|
|---|
| 63 | @author Mark Benvenuto
|
|---|
| 64 | */
|
|---|
| 65 | public abstract class Identity implements Principal, Serializable
|
|---|
| 66 | {
|
|---|
| 67 | static final long serialVersionUID = 3609922007826600659L;
|
|---|
| 68 |
|
|---|
| 69 | private String name;
|
|---|
| 70 | private IdentityScope scope;
|
|---|
| 71 | private PublicKey publicKey;
|
|---|
| 72 | private String info;
|
|---|
| 73 | private Vector certificates;
|
|---|
| 74 |
|
|---|
| 75 | /**
|
|---|
| 76 | Creates a new instance of Identity from Serialized Data
|
|---|
| 77 | */
|
|---|
| 78 | protected Identity()
|
|---|
| 79 | {
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | /**
|
|---|
| 83 | Creates a new instance of Identity with the specified name
|
|---|
| 84 | and IdentityScope.
|
|---|
| 85 |
|
|---|
| 86 | @param name the name to use
|
|---|
| 87 | @param scope the scope to use
|
|---|
| 88 |
|
|---|
| 89 | @throws KeyManagementException if the identity is already
|
|---|
| 90 | present
|
|---|
| 91 | */
|
|---|
| 92 | public Identity(String name, IdentityScope scope)
|
|---|
| 93 | throws KeyManagementException
|
|---|
| 94 | {
|
|---|
| 95 | this.name = name;
|
|---|
| 96 | this.scope = scope;
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | /**
|
|---|
| 100 | Creates a new instance of Identity with the specified name
|
|---|
| 101 | and no scope.
|
|---|
| 102 |
|
|---|
| 103 | @param name the name to use
|
|---|
| 104 | */
|
|---|
| 105 | public Identity(String name)
|
|---|
| 106 | {
|
|---|
| 107 | this.name = name;
|
|---|
| 108 | this.scope = null;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | /**
|
|---|
| 112 | Gets the name for this Identity.
|
|---|
| 113 |
|
|---|
| 114 | @return the name
|
|---|
| 115 | */
|
|---|
| 116 | public final String getName()
|
|---|
| 117 | {
|
|---|
| 118 | return name;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | /**
|
|---|
| 122 | Gets the scope for this Identity.
|
|---|
| 123 |
|
|---|
| 124 | @return the scope
|
|---|
| 125 | */
|
|---|
| 126 | public final IdentityScope getScope()
|
|---|
| 127 | {
|
|---|
| 128 | return scope;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | /**
|
|---|
| 132 | Gets the public key for this identity.
|
|---|
| 133 |
|
|---|
| 134 | @return the public key
|
|---|
| 135 | */
|
|---|
| 136 | public PublicKey getPublicKey()
|
|---|
| 137 | {
|
|---|
| 138 | return publicKey;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | /**
|
|---|
| 142 | Sets the public key for this identity.
|
|---|
| 143 | The old key and all certificates are removed.
|
|---|
| 144 |
|
|---|
| 145 | This class checks the security manager with the call
|
|---|
| 146 | checkSecurityAccess with "setIdentityPublicKey".
|
|---|
| 147 |
|
|---|
| 148 | @param key the public key to use
|
|---|
| 149 |
|
|---|
| 150 | @throws KeyManagementException if this public key is used by
|
|---|
| 151 | another identity in the current scope.
|
|---|
|
|---|