01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.security.auth.x500;
19:
20: import java.security.cert.X509Certificate;
21: import java.security.PrivateKey;
22: import javax.security.auth.Destroyable;
23:
24: import org.apache.harmony.auth.internal.nls.Messages;
25:
26: public final class X500PrivateCredential implements Destroyable {
27:
28: //X509 certificate
29: private X509Certificate cert;
30:
31: //Private key
32: private PrivateKey key;
33:
34: //Alias
35: private String alias;
36:
37: public X500PrivateCredential(X509Certificate cert, PrivateKey key) {
38: super ();
39: if (cert == null) {
40: throw new IllegalArgumentException(Messages
41: .getString("auth.28")); //$NON-NLS-1$
42: }
43: if (key == null) {
44: throw new IllegalArgumentException(Messages
45: .getString("auth.29")); //$NON-NLS-1$
46: }
47: this .cert = cert;
48: this .key = key;
49: }
50:
51: public X500PrivateCredential(X509Certificate cert, PrivateKey key,
52: String alias) {
53: this (cert, key);
54: if (alias == null) {
55: throw new IllegalArgumentException(Messages
56: .getString("auth.2A")); //$NON-NLS-1$
57: }
58: this .alias = alias;
59: }
60:
61: public X509Certificate getCertificate() {
62: return cert;
63: }
64:
65: public PrivateKey getPrivateKey() {
66: return key;
67: }
68:
69: public String getAlias() {
70: return alias;
71: }
72:
73: public void destroy() {
74: cert = null;
75: key = null;
76: alias = null;
77: }
78:
79: public boolean isDestroyed() {
80: return (cert == null && key == null && alias == null);
81: }
82: }
|