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/SOSIFederation.java $
27   * $Id: SOSIFederation.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   * The implementation of <code>Federation</code> to be used in the production environment.
38   * 
39   * @author thomas@signaturgruppen.dk
40   * @author $LastChangedBy: chg@lakeside.dk $
41   * @version $Revision: 8697 $
42   * @since 1.0
43   */
44  public class SOSIFederation extends Federation {
45  
46  	private static final String STS_SUBJECT_SERIALNUMBER = "CVR:55832218-UID:1165408969529";
47  
48      private static final String NEW_FOCES_STS_SUBJECT_NAME_PREFIX = "SOSI Federation";
49  
50      private final SOSISTSCertificateMatcher matcher;
51  
52      @Deprecated
53      public SOSIFederation(Properties properties, IntermediateCertificateCache intermediateCertificateCache) {
54          this(properties, intermediateCertificateCache, new NaiveCertificateStatusChecker(properties));
55      }
56  
57      @Deprecated
58      public SOSIFederation(Properties properties, IntermediateCertificateCache intermediateCertificateCache, CertificateStatusChecker certificateStatusChecker) {
59  	    super(properties, CertificationAuthorityFactory.createNewCertificationAuthority(properties, CertificationAuthorityFactory.OCES_CA, certificateStatusChecker, intermediateCertificateCache), STS_SUBJECT_SERIALNUMBER);
60          matcher = new SOSISTSCertificateMatcher(STS_SUBJECT_SERIALNUMBER, NEW_FOCES_STS_SUBJECT_NAME_PREFIX);
61  	}
62  
63      public SOSIFederation(Properties properties) {
64          this(properties, new HashMapCertificateCache());
65      }
66  
67      public SOSIFederation(Properties properties, CertificateCache cache) {
68          this(properties, cache, new NaiveCertificateStatusChecker(properties));
69      }
70  
71      public SOSIFederation(Properties properties, CertificateCache cache, CertificateStatusChecker certificateStatusChecker) {
72          //TODO replace with call to non-deprecated constructor in next seal release
73          super(properties, CertificationAuthorityFactory.create(properties, CertificationAuthorityFactory.OCES_CA, certificateStatusChecker, cache), STS_SUBJECT_SERIALNUMBER);
74          matcher = new SOSISTSCertificateMatcher(STS_SUBJECT_SERIALNUMBER, NEW_FOCES_STS_SUBJECT_NAME_PREFIX);
75      }
76  
77      @Override
78      protected boolean subjectDistinguishedNameMatches(DistinguishedName subjectDistinguishedName) {
79          return matcher.matches(subjectDistinguishedName);
80      }
81  }