View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.rice.ksb.security.credentials;
17  
18  import java.security.cert.X509Certificate;
19  
20  import org.kuali.rice.core.api.security.credentials.Credentials;
21  import org.kuali.rice.core.api.security.credentials.CredentialsSource;
22  import org.kuali.rice.core.api.security.credentials.CredentialsType;
23  import org.springframework.util.Assert;
24  
25  /**
26   * Implementation of a CredentialsSource that returns an X509 Certificate.
27   * <p>
28   * Note that this class is for service-to-service authentication, not
29   * user-to-service authentication.
30   * 
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   * @since 0.9
33   * @see X509Certificate
34   */
35  public final class X509CredentialsSource implements CredentialsSource {
36  
37      private final X509Certificate certificate;
38  
39      public X509CredentialsSource(final X509Certificate certificate) {
40          Assert.notNull(certificate, "certificate cannot be null.");
41          this.certificate = certificate;
42      }
43  
44      
45      
46      public Credentials getCredentials(final String serviceEndpoint) {
47      	return new X509Credentials(certificate);
48  	}
49  
50      public CredentialsType getSupportedCredentialsType() {
51          return CredentialsType.X509;
52      }
53  }