View Javadoc

1   /*
2    * Copyright [2006] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.opensaml.xml.security.credential;
18  
19  import java.security.PrivateKey;
20  import java.security.PublicKey;
21  import java.util.Collection;
22  
23  import javax.crypto.SecretKey;
24  
25  /**
26   * Base class for {@link org.opensaml.xml.security.credential.Credential} implementations.
27   */
28  public abstract class AbstractCredential implements Credential {
29  
30      /** ID of the entity owning this credential. */
31      protected String entityID;
32      
33      /** Usage type of this credential. */
34      protected UsageType usageType;
35      
36      /** Key names for this credential. */
37      protected Collection<String> keyNames;
38      
39      /** Public key of this credential. */
40      protected PublicKey publicKey;
41      
42      /** Secret key for this credential. */
43      protected SecretKey secretKey;
44      
45      /** Private key of this credential. */
46      protected PrivateKey privateKey;
47      
48      /** Credential context of this credential. */
49      protected final CredentialContextSet credentialContextSet;
50      
51      /**
52       * Constructor.
53       */
54      public AbstractCredential() {
55          credentialContextSet = new CredentialContextSet(); 
56      }
57      
58      /** {@inheritDoc}  */
59      public String getEntityId() {
60          return entityID;
61      }
62  
63      /** {@inheritDoc}  */
64      public UsageType getUsageType() {
65          return usageType;
66      }
67  
68      /** {@inheritDoc} */
69      public Collection<String> getKeyNames() {
70          return keyNames;
71      }
72      
73      /** {@inheritDoc}  */
74      public PublicKey getPublicKey() {
75          return publicKey;
76      }
77      
78      /** {@inheritDoc} */
79      public SecretKey getSecretKey() {
80          return secretKey;
81      }
82  
83      /** {@inheritDoc}  */
84      public PrivateKey getPrivateKey() {
85          return privateKey;
86      }
87  
88      /** {@inheritDoc} */
89      public CredentialContextSet getCredentalContextSet() {
90          return credentialContextSet;
91      }
92      
93  }