Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions test/jdk/java/security/Provider/NewInstance.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,21 +26,34 @@
* @bug 8039853
* @summary Provider.Service.newInstance() does not work with current
JDK JGSS Mechanisms
* @library /test/lib
*/

import java.security.*;
import java.util.*;

import jtreg.SkippedException;

import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class NewInstance {

public static void main(String[] args) throws Exception {
for (Provider p : Security.getProviders()) {

System.out.println("Removing SunPCSC provider from the list (A smartcard might not be installed).");
final List<Provider> providers = Arrays.stream(Security.getProviders())
.filter(provider -> !provider.getName().equals("SunPCSC"))
.collect(Collectors.toList());

for (Provider p : providers) {
System.out.println("---------");
System.out.println(p.getName() + ":" + p.getInfo());
if (p.getName().equals("SunPCSC")) {
System.out.println("A smartcard might not be installed. Skip test.");
continue;
}
Set<Provider.Service> set = p.getServices();
Iterator<Provider.Service> i = set.iterator();

Expand Down
11 changes: 7 additions & 4 deletions test/jdk/java/security/cert/CertStore/NoLDAP.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,20 +25,23 @@
* @bug 8004502
* @summary Sanity check that NoSuchAlgorithmException is thrown when requesting
* a CertStore of type "LDAP" and LDAP is not available.
* @library /test/lib
*/

import java.security.NoSuchAlgorithmException;
import java.security.cert.CertStore;
import java.security.cert.LDAPCertStoreParameters;
import jtreg.SkippedException;


public class NoLDAP {
public static void main(String[] args) throws Exception {
try {
Class.forName("javax.naming.ldap.LdapName");
System.out.println("LDAP is present, test skipped");
return;
} catch (ClassNotFoundException ignore) { }
throw new SkippedException("LDAP is present");
} catch (ClassNotFoundException ignore) {
System.err.println("Expected: class not found exception " + ignore.getMessage());
}

try {
CertStore.getInstance("LDAP", new LDAPCertStoreParameters());
Expand Down