View Javadoc

1   /*
2    * The MIT License
3    *
4    * Original work sponsored and donated by National Board of e-Health (NSI), Denmark (http://www.nsi.dk)
5    *
6    * Copyright (C) 2011 National Board of e-Health (NSI), Denmark (http://www.nsi.dk)
7    *
8    * Permission is hereby granted, free of charge, to any person obtaining a copy of
9    * this software and associated documentation files (the "Software"), to deal in
10   * the Software without restriction, including without limitation the rights to
11   * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12   * of the Software, and to permit persons to whom the Software is furnished to do
13   * so, subject to the following conditions:
14   *
15   * The above copyright notice and this permission notice shall be included in all
16   * copies or substantial portions of the Software.
17   *
18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24   * SOFTWARE.
25   *
26   * $HeadURL: https://svn.softwareborsen.dk/sosi/trunk/modules/seal/src/main/java/dk/sosi/seal/pki/SOSITestFederation.java $
27   * $Id: SOSITestFederation.java 8697 2011-09-02 10:33:55Z chg@lakeside.dk $
28   */
29  package dk.sosi.seal.pki;
30  
31  import dk.sosi.seal.pki.impl.HashMapCertificateCache;
32  import dk.sosi.seal.pki.internal.SOSISTSCertificateMatcher;
33  
34  import java.util.Properties;
35  
36  /**
37   * Implementation of <code>Federation</code> using the test federation defined by OCES Systemtest CA II and
38   * the STS test system.
39   * 
40   * @author thomas@signaturgruppen.dk
41   * @author $LastChangedBy: chg@lakeside.dk $
42   * @version $Revision: 8697 $
43   * @since 1.0
44   */
45  
46  public class SOSITestFederation extends Federation {
47  
48  	//The SOSI STS test certificate has dn:
49  	//cn=Danske Regioner - SOSI STS+serialNumber=CVR:55832218-UID:1163447368627,o=Danske Regioner // CVR:55832218,c=DK
50  	private final static String TEST_STS_SUBJECT_SERIALNUMBER = "CVR:55832218-UID:1163447368627";
51  
52      private final static String NEW_FOCES_TEST_STS_SUBJECT_NAME_PREFIX = "SOSI Test Federation";
53  
54      private final SOSISTSCertificateMatcher matcher;
55  
56      @Deprecated
57      public SOSITestFederation(Properties properties, IntermediateCertificateCache intermediateCertificateCache) {
58          this(properties, intermediateCertificateCache, new NaiveCertificateStatusChecker(properties));
59      }
60  
61      @Deprecated
62      public SOSITestFederation(Properties properties, IntermediateCertificateCache intermediateCertificateCache, CertificateStatusChecker certificateStatusChecker) {
63          super(properties, CertificationAuthorityFactory.createNewCertificationAuthority(properties, CertificationAuthorityFactory.OCES_SYSTEMTEST_CA, certificateStatusChecker, intermediateCertificateCache), TEST_STS_SUBJECT_SERIALNUMBER);
64          matcher = new SOSISTSCertificateMatcher(TEST_STS_SUBJECT_SERIALNUMBER, NEW_FOCES_TEST_STS_SUBJECT_NAME_PREFIX);
65      }
66  
67      public SOSITestFederation(Properties properties) {
68          this(properties, new HashMapCertificateCache());
69      }
70  
71      public SOSITestFederation(Properties properties, CertificateCache cache) {
72          this(properties, cache, new NaiveCertificateStatusChecker(properties));
73      }
74  
75      public SOSITestFederation(Properties properties, CertificateCache cache, CertificateStatusChecker certificateStatusChecker) {
76          //TODO replace with call to non-deprecated constructor in next seal release
77          super(properties, CertificationAuthorityFactory.create(properties, CertificationAuthorityFactory.OCES_SYSTEMTEST_CA, certificateStatusChecker, cache), TEST_STS_SUBJECT_SERIALNUMBER);
78          matcher = new SOSISTSCertificateMatcher(TEST_STS_SUBJECT_SERIALNUMBER, NEW_FOCES_TEST_STS_SUBJECT_NAME_PREFIX);
79      }
80  
81      @Override
82      protected boolean subjectDistinguishedNameMatches(DistinguishedName subjectDistinguishedName) {
83          return matcher.matches(subjectDistinguishedName);
84      }
85  }