01: /*
02: * Copyright 2005 - 2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.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.bus.security.credentials;
18:
19: import org.kuali.rice.security.credentials.Credentials;
20: import org.kuali.rice.security.credentials.CredentialsSource;
21: import org.springframework.util.Assert;
22:
23: /**
24: * Implementation of a CredentialsSource that contains a username and password.
25: * <p>
26: * Note that this implementation is for service-to-service authentication. It
27: * cannot handle user-to-service authentication.
28: *
29: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
30: * @version $Revision: 1.2.24.1 $ $Date: 2007/10/17 20:32:05 $
31: * @since 0.9
32: */
33: public final class UsernamePasswordCredentialsSource implements
34: CredentialsSource {
35:
36: /** The username. */
37: private final String username;
38:
39: /** The password. */
40: private final String password;
41:
42: public Credentials getCredentials(final String serviceEndpoint) {
43: return new UsernamePasswordCredentials(username, password);
44: }
45:
46: /**
47: * Constructor that accepts the username and password for which to construct
48: * UsernamePasswordAuthenticationToken's from.
49: *
50: * @param username the username.
51: * @param password the password.
52: */
53: public UsernamePasswordCredentialsSource(final String username,
54: final String password) {
55: Assert.notNull(username, "username cannot be null.");
56: Assert.notNull(password, "password cannote be null.");
57:
58: this .username = username;
59: this .password = password;
60: }
61:
62: public CredentialsType getSupportedCredentialsType() {
63: return CredentialsType.USERNAME_PASSWORD;
64: }
65: }
|