1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.crypto.pkix.params.x509certificate

File DistinguishedName.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

8
16
6
1
97
54
10
0.62
2.67
6
1.67

Classes

Class Line # Actions
DistinguishedName 34 16 0% 10 0
1.0100%
 

Contributing tests

This file is covered by 35 tests. .

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;
21   
22    import java.io.IOException;
23   
24    import org.bouncycastle.asn1.x500.X500Name;
25    import org.xwiki.crypto.pkix.internal.BcPrincipalIdentifier;
26    import org.xwiki.crypto.pkix.params.PrincipalIndentifier;
27   
28    /**
29    * Represent a Principal distinguished name.
30    *
31    * @version $Id: 1a8587ed4df1eb600110a4acfcc6dfd66c7907bc $
32    * @since 5.4
33    */
 
34    public class DistinguishedName implements PrincipalIndentifier, BcPrincipalIdentifier
35    {
36    private final X500Name dn;
37   
38    /**
39    * Create a new distinguished name.
40    *
41    * @param name the DN name like in "CN=Common Name, O=Organisation"
42    */
 
43  180 toggle public DistinguishedName(Object name)
44    {
45  180 if (name instanceof String) {
46  126 this.dn = new X500Name((String) name);
47    } else {
48  54 this.dn = X500Name.getInstance(name);
49    }
50    }
51   
 
52  4 toggle @Override
53    public byte[] getEncoded() throws IOException
54    {
55  4 return this.dn.getEncoded();
56    }
57   
 
58  27 toggle @Override
59    public String getName()
60    {
61  27 return this.dn.toString();
62    }
63   
64    // BcPrincipalIdentifier internal interface
65   
 
66  71 toggle @Override
67    public X500Name getX500Name()
68    {
69  71 return this.dn;
70    }
71   
 
72  32 toggle @Override
73    public boolean equals(Object o)
74    {
75  32 if (this == o) {
76  1 return true;
77    }
78  31 if (!(o instanceof PrincipalIndentifier)) {
79  1 return false;
80    }
81   
82  30 X500Name name;
83  30 if (o instanceof BcPrincipalIdentifier) {
84  28 name = ((BcPrincipalIdentifier) o).getX500Name();
85    } else {
86  2 name = new X500Name(((PrincipalIndentifier) o).getName());
87    }
88   
89  30 return this.dn.equals(name);
90    }
91   
 
92  2 toggle @Override
93    public int hashCode()
94    {
95  2 return this.dn.hashCode();
96    }
97    }