01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.bus.security.credentials;
17:
18: import junit.framework.TestCase;
19:
20: import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
21: import org.acegisecurity.providers.x509.X509AuthenticationToken;
22: import org.kuali.bus.security.credentials.X509CredentialsSourceTest.KualiX509Certificate;
23:
24: /**
25: *
26: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
27: * @version $Revision: 1.2.16.1.6.1 $ $Date: 2007/10/17 20:32:06 $
28: * @since 0.9
29: *
30: */
31: public class SecurityUtilsTest extends TestCase {
32:
33: public void testUsernamePasswordCredentials() {
34: final UsernamePasswordCredentials c = new UsernamePasswordCredentials(
35: "test", "test");
36: final UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) SecurityUtils
37: .convertCredentialsToSecurityContext(c);
38:
39: assertEquals(token.getPrincipal(), c.getUsername());
40: assertEquals(token.getCredentials(), c.getPassword());
41: }
42:
43: public void testX509CertificateCredentials() {
44: final X509Credentials c = new X509Credentials(
45: new KualiX509Certificate());
46: final X509AuthenticationToken token = (X509AuthenticationToken) SecurityUtils
47: .convertCredentialsToSecurityContext(c);
48:
49: assertEquals(c.getX509Certificate(), token.getCredentials());
50: }
51:
52: }
|