1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.crypto.pkix.params.x509certificate.extension

File X509DnsName.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
7
5
1
79
33
6
0.86
1.4
5
1.2

Classes

Class Line # Actions
X509DnsName 32 7 0% 6 2
0.8571428785.7%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.crypto.pkix.params.x509certificate.extension;
21   
22    import org.bouncycastle.asn1.DERIA5String;
23    import org.bouncycastle.asn1.x509.GeneralName;
24    import org.xwiki.crypto.pkix.internal.extension.BcGeneralName;
25   
26    /**
27    * DNS domain general name.
28    *
29    * @version $Id: eece3fcd8c0e9b70478b79edcaac79e9870ae2da $
30    * @since 5.4
31    */
 
32    public class X509DnsName implements X509StringGeneralName, BcGeneralName
33    {
34    private final String domain;
35   
36    /**
37    * Constructs a DNS domain general name from the given string.
38    *
39    * @param domain the domain name compliant with RFC 1034.
40    */
 
41  1 toggle public X509DnsName(String domain)
42    {
43  1 this.domain = domain;
44    }
45   
46    /**
47    * Create a new instance from a Bouncy Castle general name.
48    *
49    * @param name the Bouncy Castle general name.
50    */
 
51  1 toggle public X509DnsName(GeneralName name)
52    {
53  1 if (name.getTagNo() != GeneralName.dNSName) {
54  0 throw new IllegalArgumentException("Incompatible general name: " + name.getTagNo());
55    }
56   
57  1 this.domain = DERIA5String.getInstance(name.getName()).getString();
58    }
59   
60    /**
61    * @return the domain name represented by this general name.
62    */
 
63  1 toggle public String getDomain()
64    {
65  1 return this.domain;
66    }
67   
 
68  1 toggle @Override
69    public String getName()
70    {
71  1 return this.domain;
72    }
73   
 
74  1 toggle @Override
75    public GeneralName getGeneralName()
76    {
77  1 return new GeneralName(GeneralName.dNSName, this.domain);
78    }
79    }