Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
UsernamePasswordCredentialsSource |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2005-2007 The Kuali Foundation | |
3 | * | |
4 | * | |
5 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.opensource.org/licenses/ecl2.php | |
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 | package org.kuali.rice.ksb.security.credentials; | |
18 | ||
19 | import org.kuali.rice.core.api.security.credentials.Credentials; | |
20 | import org.kuali.rice.core.api.security.credentials.CredentialsSource; | |
21 | import org.kuali.rice.core.api.security.credentials.CredentialsType; | |
22 | import org.springframework.util.Assert; | |
23 | ||
24 | /** | |
25 | * Implementation of a CredentialsSource that contains a username and password. | |
26 | * <p> | |
27 | * Note that this implementation is for service-to-service authentication. It | |
28 | * cannot handle user-to-service authentication. | |
29 | * | |
30 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
31 | * @since 0.9 | |
32 | */ | |
33 | public final class UsernamePasswordCredentialsSource implements CredentialsSource { | |
34 | ||
35 | /** The username. */ | |
36 | private final String username; | |
37 | ||
38 | /** The password. */ | |
39 | private final String password; | |
40 | ||
41 | public Credentials getCredentials(final String serviceEndpoint) { | |
42 | 0 | return new UsernamePasswordCredentials(username, password); |
43 | } | |
44 | ||
45 | /** | |
46 | * Constructor that accepts the username and password for which to construct | |
47 | * UsernamePasswordAuthenticationToken's from. | |
48 | * | |
49 | * @param username the username. | |
50 | * @param password the password. | |
51 | */ | |
52 | public UsernamePasswordCredentialsSource(final String username, | |
53 | 0 | final String password) { |
54 | 0 | Assert.notNull(username, "username cannot be null."); |
55 | 0 | Assert.notNull(password, "password cannote be null."); |
56 | ||
57 | 0 | this.username = username; |
58 | 0 | this.password = password; |
59 | 0 | } |
60 | ||
61 | public CredentialsType getSupportedCredentialsType() { | |
62 | 0 | return CredentialsType.USERNAME_PASSWORD; |
63 | } | |
64 | } |