001: /*
002: * Copyright 2007 The Kuali Foundation
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.bus.security.credentials;
017:
018: import java.math.BigInteger;
019: import java.security.InvalidKeyException;
020: import java.security.NoSuchAlgorithmException;
021: import java.security.NoSuchProviderException;
022: import java.security.Principal;
023: import java.security.PublicKey;
024: import java.security.SignatureException;
025: import java.security.cert.CertificateEncodingException;
026: import java.security.cert.CertificateException;
027: import java.security.cert.CertificateExpiredException;
028: import java.security.cert.CertificateNotYetValidException;
029: import java.security.cert.X509Certificate;
030: import java.util.Date;
031: import java.util.Set;
032:
033: import junit.framework.TestCase;
034:
035: /**
036: *
037: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
038: * @version $Revision: 1.2.16.1.6.1 $ $Date: 2007/10/17 20:32:06 $
039: * @since 0.9
040: *
041: */
042: public class X509CredentialsSourceTest extends TestCase {
043:
044: private X509CredentialsSource credentialsSource;
045:
046: private X509Certificate cert = new KualiX509Certificate();
047:
048: @Override
049: protected void setUp() throws Exception {
050: super .setUp();
051:
052: this .credentialsSource = new X509CredentialsSource(cert);
053: }
054:
055: public void testX509Certificate() {
056: final X509Credentials context = (X509Credentials) this .credentialsSource
057: .getCredentials("test");
058: assertNotNull(context);
059: final X509Certificate cert = context.getX509Certificate();
060:
061: assertEquals(this .cert, cert);
062: }
063:
064: public static class KualiX509Certificate extends X509Certificate {
065:
066: protected KualiX509Certificate() {
067: // nothing to do
068: }
069:
070: public void checkValidity() throws CertificateExpiredException,
071: CertificateNotYetValidException {
072: // nothing to do
073: }
074:
075: public void checkValidity(Date date)
076: throws CertificateExpiredException,
077: CertificateNotYetValidException {
078: // nothing to do
079: }
080:
081: public int getBasicConstraints() {
082: return 0;
083: }
084:
085: public Principal getIssuerDN() {
086: return null;
087: }
088:
089: public boolean[] getIssuerUniqueID() {
090: return null;
091: }
092:
093: public boolean[] getKeyUsage() {
094: return null;
095: }
096:
097: public Date getNotAfter() {
098: return null;
099: }
100:
101: public Date getNotBefore() {
102: return null;
103: }
104:
105: public BigInteger getSerialNumber() {
106: return null;
107: }
108:
109: public String getSigAlgName() {
110: return null;
111: }
112:
113: public String getSigAlgOID() {
114: return null;
115: }
116:
117: public byte[] getSigAlgParams() {
118: return null;
119: }
120:
121: public byte[] getSignature() {
122: return null;
123: }
124:
125: public Principal getSubjectDN() {
126: return null;
127: }
128:
129: public boolean[] getSubjectUniqueID() {
130: return null;
131: }
132:
133: public byte[] getTBSCertificate()
134: throws CertificateEncodingException {
135: return null;
136: }
137:
138: public int getVersion() {
139: return 0;
140: }
141:
142: public Set<String> getCriticalExtensionOIDs() {
143: return null;
144: }
145:
146: public byte[] getExtensionValue(String arg0) {
147: return null;
148: }
149:
150: public Set<String> getNonCriticalExtensionOIDs() {
151: return null;
152: }
153:
154: public boolean hasUnsupportedCriticalExtension() {
155: return false;
156: }
157:
158: public byte[] getEncoded() throws CertificateEncodingException {
159: return null;
160: }
161:
162: public PublicKey getPublicKey() {
163: return null;
164: }
165:
166: public String toString() {
167: return null;
168: }
169:
170: public void verify(PublicKey arg0, String arg1)
171: throws CertificateException, NoSuchAlgorithmException,
172: InvalidKeyException, NoSuchProviderException,
173: SignatureException {
174: // nothing to do
175: }
176:
177: public void verify(PublicKey arg0) throws CertificateException,
178: NoSuchAlgorithmException, InvalidKeyException,
179: NoSuchProviderException, SignatureException {
180: // nothing to do
181: }
182: }
183: }
|