mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8175940: More certificate subject checking
Reviewed-by: ahgross, mullan
This commit is contained in:
parent
547745b881
commit
f92a050948
1 changed files with 39 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -194,31 +194,45 @@ public class DNSName implements GeneralNameInterface {
|
||||||
*/
|
*/
|
||||||
public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException {
|
public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException {
|
||||||
int constraintType;
|
int constraintType;
|
||||||
if (inputName == null)
|
if (inputName == null) {
|
||||||
constraintType = NAME_DIFF_TYPE;
|
return NAME_DIFF_TYPE;
|
||||||
else if (inputName.getType() != NAME_DNS)
|
}
|
||||||
constraintType = NAME_DIFF_TYPE;
|
String inName;
|
||||||
else {
|
switch (inputName.getType()) {
|
||||||
String inName =
|
case NAME_DNS:
|
||||||
(((DNSName)inputName).getName()).toLowerCase(Locale.ENGLISH);
|
inName = ((DNSName)inputName).getName();
|
||||||
String thisName = name.toLowerCase(Locale.ENGLISH);
|
break;
|
||||||
if (inName.equals(thisName))
|
case NAME_DIRECTORY:
|
||||||
constraintType = NAME_MATCH;
|
try {
|
||||||
else if (thisName.endsWith(inName)) {
|
inName = ((X500Name) inputName).getCommonName();
|
||||||
int inNdx = thisName.lastIndexOf(inName);
|
if (inName == null) {
|
||||||
if (thisName.charAt(inNdx-1) == '.' )
|
return NAME_DIFF_TYPE;
|
||||||
constraintType = NAME_WIDENS;
|
}
|
||||||
else
|
} catch (IOException ioe) {
|
||||||
constraintType = NAME_SAME_TYPE;
|
return NAME_DIFF_TYPE;
|
||||||
} else if (inName.endsWith(thisName)) {
|
}
|
||||||
int ndx = inName.lastIndexOf(thisName);
|
break;
|
||||||
if (inName.charAt(ndx-1) == '.' )
|
default:
|
||||||
constraintType = NAME_NARROWS;
|
return NAME_DIFF_TYPE;
|
||||||
else
|
}
|
||||||
constraintType = NAME_SAME_TYPE;
|
inName = inName.toLowerCase(Locale.ENGLISH);
|
||||||
} else {
|
String thisName = name.toLowerCase(Locale.ENGLISH);
|
||||||
|
if (inName.equals(thisName))
|
||||||
|
constraintType = NAME_MATCH;
|
||||||
|
else if (thisName.endsWith(inName)) {
|
||||||
|
int inNdx = thisName.lastIndexOf(inName);
|
||||||
|
if (thisName.charAt(inNdx-1) == '.' )
|
||||||
|
constraintType = NAME_WIDENS;
|
||||||
|
else
|
||||||
constraintType = NAME_SAME_TYPE;
|
constraintType = NAME_SAME_TYPE;
|
||||||
}
|
} else if (inName.endsWith(thisName)) {
|
||||||
|
int ndx = inName.lastIndexOf(thisName);
|
||||||
|
if (inName.charAt(ndx-1) == '.' )
|
||||||
|
constraintType = NAME_NARROWS;
|
||||||
|
else
|
||||||
|
constraintType = NAME_SAME_TYPE;
|
||||||
|
} else {
|
||||||
|
constraintType = NAME_SAME_TYPE;
|
||||||
}
|
}
|
||||||
return constraintType;
|
return constraintType;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue