blob: 4bd2ee8db232f5156ef236a387b54cb7b8f07260 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package sun.security.provider;
27
28import java.util.*;
29import java.security.*;
30
31/**
32 * SunSecurity signer. Like SystemIdentity, it has a trust bit, which
33 * can be set by SunSecurity classes, and a set of accessors for other
34 * classes in sun.security.*.
35 *
36 * @author Benjamin Renaud
37 */
38
39public class SystemSigner extends Signer {
40
41 /** use serialVersionUID from JDK 1.1. for interoperability */
42 private static final long serialVersionUID = -2127743304301557711L;
43
44 /* Is this signer trusted */
45 private boolean trusted = false;
46
47 /**
48 * Construct a signer with a given name.
49 */
50 public SystemSigner(String name) {
51 super(name);
52 }
53
54 /**
55 * Construct a signer with a name and a scope.
56 *
57 * @param name the signer's name.
58 *
59 * @param scope the scope for this signer.
60 */
61 public SystemSigner(String name, IdentityScope scope)
62 throws KeyManagementException {
63
64 super(name, scope);
65 }
66
67 /* Set the trust status of this signer */
68 void setTrusted(boolean trusted) {
69 this.trusted = trusted;
70 }
71
72 /**
73 * Returns true if this signer is trusted.
74 */
75 public boolean isTrusted() {
76 return trusted;
77 }
78
79 /* friendly callback for set keys */
80 void setSignerKeyPair(KeyPair pair)
81 throws InvalidParameterException, KeyException {
82 setKeyPair(pair);
83 }
84
85 /* friendly callback for getting private keys */
86 PrivateKey getSignerPrivateKey() {
87 return getPrivateKey();
88 }
89
90 void setSignerInfo(String s) {
91 setInfo(s);
92 }
93
94 /**
95 * Call back method into a protected method for package friends.
96 */
97 void addSignerCertificate(Certificate cert) throws KeyManagementException {
98 addCertificate(cert);
99 }
100
101 void clearCertificates() throws KeyManagementException {
102 Certificate[] certs = certificates();
103 for (int i = 0; i < certs.length; i++) {
104 removeCertificate(certs[i]);
105 }
106 }
107
108 public String toString() {
109 String trustedString = "not trusted";
110 if (trusted) {
111 trustedString = "trusted";
112 }
113 return super.toString() + "[" + trustedString + "]";
114 }
115}