本文整理匯總了Java中java.security.cert.X509CertSelector.setMatchAllSubjectAltNames方法的典型用法代碼示例。如果您正苦於以下問題:Java X509CertSelector.setMatchAllSubjectAltNames方法的具體用法?Java X509CertSelector.setMatchAllSubjectAltNames怎麽用?Java X509CertSelector.setMatchAllSubjectAltNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.cert.X509CertSelector
的用法示例。
在下文中一共展示了X509CertSelector.setMatchAllSubjectAltNames方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSubjectAltName
import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
private void testSubjectAltName() throws IOException {
System.out.println("X.509 Certificate Match on subjectAltName");
// bad match
X509CertSelector selector = new X509CertSelector();
GeneralNameInterface dnsName = new DNSName("foo.com");
DerOutputStream tmp = new DerOutputStream();
dnsName.encode(tmp);
selector.addSubjectAlternativeName(2, tmp.toByteArray());
checkMatch(selector, cert, false);
// good match
DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.17"));
byte[] encoded = in.getOctetString();
SubjectAlternativeNameExtension ext = new SubjectAlternativeNameExtension(false, encoded);
GeneralNames names = (GeneralNames) ext.get(SubjectAlternativeNameExtension.SUBJECT_NAME);
GeneralName name = (GeneralName) names.get(0);
selector.setSubjectAlternativeNames(null);
DerOutputStream tmp2 = new DerOutputStream();
name.getName().encode(tmp2);
selector.addSubjectAlternativeName(name.getType(), tmp2.toByteArray());
checkMatch(selector, cert, true);
// good match 2 (matches at least one)
selector.setMatchAllSubjectAltNames(false);
selector.addSubjectAlternativeName(2, "foo.com");
checkMatch(selector, cert, true);
}
示例2: test_getMatchAllSubjectAltNames
import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
/**
* @tests java.security.cert.X509CertSelector#getMatchAllSubjectAltNames()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getMatchAllSubjectAltNames",
args = {}
)
public void test_getMatchAllSubjectAltNames() {
X509CertSelector selector = new X509CertSelector();
assertTrue("The matchAllNames initially should be true", selector
.getMatchAllSubjectAltNames());
selector.setMatchAllSubjectAltNames(false);
assertFalse("The value should be false", selector
.getMatchAllSubjectAltNames());
}
示例3: test_getPathToNames
import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
/**
* @tests java.security.cert.X509CertSelector#getPathToNames()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getPathToNames",
args = {}
)
public void test_getPathToNames() {
try {
GeneralName san0 = new GeneralName(new OtherName("1.2.3.4.5",
new byte[] { 1, 2, 0, 1 }));
GeneralName san1 = new GeneralName(1, "[email protected]");
GeneralName san2 = new GeneralName(2, "dNSName");
GeneralName san3 = new GeneralName(new ORAddress());
GeneralName san4 = new GeneralName(new Name("O=Organization"));
GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
GeneralName san7 = new GeneralName(7, "1.1.1.1");
GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");
GeneralNames sans1 = new GeneralNames();
sans1.addName(san0);
sans1.addName(san1);
sans1.addName(san2);
sans1.addName(san3);
sans1.addName(san4);
sans1.addName(san6);
sans1.addName(san7);
sans1.addName(san8);
GeneralNames sans2 = new GeneralNames();
sans2.addName(san0);
TestCert cert1 = new TestCert(sans1);
TestCert cert2 = new TestCert(sans2);
X509CertSelector selector = new X509CertSelector();
selector.setMatchAllSubjectAltNames(true);
selector.setPathToNames(null);
assertTrue("Any certificate should match in the case of null "
+ "subjectAlternativeNames criteria.", selector
.match(cert1)
&& selector.match(cert2));
Collection<List<?>> sans = sans1.getPairsList();
selector.setPathToNames(sans);
Collection<List<?>> col = selector.getPathToNames();
Iterator<List<?>> i = col.iterator();
while (i.hasNext()) {
Object o = i.next();
if (!(o instanceof List)) {
fail("expected a List");
}
}
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
}
示例4: test_setPathToNamesLjava_util_Collection
import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
/**
* @tests java.security.cert.X509CertSelector#setPathToNames(Collection<List<?>>)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "setPathToNames",
args = {java.util.Collection.class}
)
public void test_setPathToNamesLjava_util_Collection() {
try {
GeneralName san0 = new GeneralName(new OtherName("1.2.3.4.5",
new byte[] { 1, 2, 0, 1 }));
GeneralName san1 = new GeneralName(1, "[email protected]");
GeneralName san2 = new GeneralName(2, "dNSName");
GeneralName san3 = new GeneralName(new ORAddress());
GeneralName san4 = new GeneralName(new Name("O=Organization"));
GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
GeneralName san7 = new GeneralName(7, "1.1.1.1");
GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");
GeneralNames sans1 = new GeneralNames();
sans1.addName(san0);
sans1.addName(san1);
sans1.addName(san2);
sans1.addName(san3);
sans1.addName(san4);
sans1.addName(san6);
sans1.addName(san7);
sans1.addName(san8);
GeneralNames sans2 = new GeneralNames();
sans2.addName(san0);
TestCert cert1 = new TestCert(sans1);
TestCert cert2 = new TestCert(sans2);
X509CertSelector selector = new X509CertSelector();
selector.setMatchAllSubjectAltNames(true);
selector.setPathToNames(null);
assertTrue("Any certificate should match in the case of null "
+ "subjectAlternativeNames criteria.", selector
.match(cert1)
&& selector.match(cert2));
Collection<List<?>> sans = sans1.getPairsList();
selector.setPathToNames(sans);
Collection<List<?>> col = selector.getPathToNames();
Iterator<List<?>> i = col.iterator();
while (i.hasNext()) {
Object o = i.next();
if (!(o instanceof List)) {
fail("expected a List");
}
}
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
}
示例5: test_setSubjectAlternativeNamesLjava_util_Collection
import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
/**
* @tests java.security.cert.X509CertSelector#setSubjectAlternativeNames(Collection<List<?>>)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "setSubjectAlternativeNames",
args = {java.util.Collection.class}
)
public void test_setSubjectAlternativeNamesLjava_util_Collection() {
try {
GeneralName san0 = new GeneralName(new OtherName("1.2.3.4.5",
new byte[] { 1, 2, 0, 1 }));
GeneralName san1 = new GeneralName(1, "[email protected]");
GeneralName san2 = new GeneralName(2, "dNSName");
GeneralName san3 = new GeneralName(new ORAddress());
GeneralName san4 = new GeneralName(new Name("O=Organization"));
GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
GeneralName san7 = new GeneralName(7, "1.1.1.1");
GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");
GeneralNames sans1 = new GeneralNames();
sans1.addName(san0);
sans1.addName(san1);
sans1.addName(san2);
sans1.addName(san3);
sans1.addName(san4);
sans1.addName(san6);
sans1.addName(san7);
sans1.addName(san8);
GeneralNames sans2 = new GeneralNames();
sans2.addName(san0);
TestCert cert1 = new TestCert(sans1);
TestCert cert2 = new TestCert(sans2);
X509CertSelector selector = new X509CertSelector();
selector.setMatchAllSubjectAltNames(true);
selector.setSubjectAlternativeNames(null);
assertTrue("Any certificate should match in the case of null "
+ "subjectAlternativeNames criteria.", selector
.match(cert1)
&& selector.match(cert2));
Collection<List<?>> sans = sans1.getPairsList();
selector.setSubjectAlternativeNames(sans);
Collection<List<?>> col = selector.getSubjectAlternativeNames();
Iterator<List<?>> i = col.iterator();
while (i.hasNext()) {
Object o = i.next();
if (!(o instanceof List)) {
fail("expected a List");
}
}
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
}