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 * A credential for an entity. A particular credential may contain either asymmetric key information (a public key 27 * and optionally the corresponding private key), or a symmetric (secret) key, but never both. 28 * With asymmetric key-based credentials, local entity credentials will usually contain both a public 29 * and private key while peer credentails will normally contain only a public key. 30 */ 31 public interface Credential { 32 33 /** 34 * The unique ID of the entity this credential is for. 35 * 36 * @return unique ID of the entity this credential is for 37 */ 38 public String getEntityId(); 39 40 /** 41 * Gets usage type of this credential. 42 * 43 * @return usage type of this credential 44 */ 45 public UsageType getUsageType(); 46 47 /** 48 * Gets key names for this credential. These names may be used to reference a key(s) exchanged 49 * through an out-of-band aggreement. Implementations may or may not implement means to resolve 50 * these names into keys retrievable through the {@link #getPublicKey()}, {@link #getPrivateKey()} 51 * or {@link #getSecretKey()} methods. 52 * 53 * @return key names for this credential 54 */ 55 public Collection<String> getKeyNames(); 56 57 /** 58 * Gets the public key for the entity. 59 * 60 * @return public key for the entity 61 */ 62 public PublicKey getPublicKey(); 63 64 /** 65 * Gets the private key for the entity if there is one. 66 * 67 * @return the private key for the entity 68 */ 69 public PrivateKey getPrivateKey(); 70 71 /** 72 * Gets the secret key for this entity. 73 * 74 * @return secret key for this entity 75 */ 76 public SecretKey getSecretKey(); 77 78 /** 79 * Get the set of credential context information, which provides additional information 80 * specific to the contexts in which the credential was resolved. 81 * 82 * @return set of resolution contexts of the credential 83 */ 84 public CredentialContextSet getCredentalContextSet(); 85 86 /** 87 * Get the primary type of the credential instance. This will usually be the primary sub-interface 88 * of {@link Credential} implemented by an implementation. 89 * 90 * @return the credential type 91 */ 92 public Class<? extends Credential> getCredentialType(); 93 }