-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Improve comparison of DNs
- Loading branch information
Showing
15 changed files
with
323 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/xades4j/verification/DistinguishedNameComparer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* XAdES4j - A Java library for generation and verification of XAdES signatures. | ||
* Copyright (C) 2018 Luis Goncalves. | ||
* | ||
* XAdES4j is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 3 of the License, or any later version. | ||
* | ||
* XAdES4j is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along | ||
* with XAdES4j. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package xades4j.verification; | ||
|
||
import com.google.inject.Inject; | ||
import javax.security.auth.x500.X500Principal; | ||
import org.bouncycastle.asn1.x500.X500Name; | ||
import xades4j.providers.X500NameStyleProvider; | ||
import xades4j.utils.X500ExtensibleNameStyle; | ||
|
||
/** | ||
* <b>Experimental API</b>. It may be changed or removed in future releases. | ||
* | ||
* @author luis | ||
*/ | ||
class DistinguishedNameComparer | ||
{ | ||
private final X500ExtensibleNameStyle x500NameStyle; | ||
private final X500NameStyleProvider x500NameStyleProvider; | ||
|
||
@Inject | ||
DistinguishedNameComparer(X500ExtensibleNameStyle x500NameStyle, X500NameStyleProvider x500NameStyleProvider) | ||
{ | ||
this.x500NameStyle = x500NameStyle; | ||
this.x500NameStyleProvider = x500NameStyleProvider; | ||
} | ||
|
||
/** | ||
* @exception IllegalArgumentException if the DN string is invalid | ||
*/ | ||
boolean areEqual(X500Principal parsedDn, String stringDn) | ||
{ | ||
X500Name first = X500Name.getInstance(parsedDn.getEncoded()); | ||
X500Name second = X500Name.getInstance(this.x500NameStyle, this.x500NameStyleProvider.fromString(stringDn).getEncoded()); | ||
return first.equals(second); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.