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
78 changes: 66 additions & 12 deletions src/java.base/share/conf/security/java.security
Original file line number Diff line number Diff line change
Expand Up @@ -1384,17 +1384,29 @@ jdk.io.permissionsUseCanonicalPath=false
#
#jdk.security.allowNonCaAnchor=true

# JNDI Object Factories Filter
#
# The default Character set name (java.nio.charset.Charset.forName())
# for converting TLS ALPN values between byte arrays and Strings.
# Prior versions of the JDK may use UTF-8 as the default charset. If
# you experience interoperability issues, setting this property to UTF-8
# may help.
#
# jdk.tls.alpnCharset=UTF-8
jdk.tls.alpnCharset=ISO_8859_1

#
# Global JNDI Object Factories Filter
#
# This filter is used by the JNDI runtime to control the set of object factory classes
# which will be allowed to instantiate objects from object references returned by
# naming/directory systems. The factory class named by the reference instance will be
# matched against this filter. The filter property supports pattern-based filter syntax
# with the same format as jdk.serialFilter.
# with the same format as jdk.serialFilter. Limit patterns specified in the filter property
# are unused.
#
# Each pattern is matched against the factory class name to allow or disallow it's
# instantiation. The access to a factory class is allowed unless the filter returns
# REJECTED.
# Each class name pattern is matched against the factory class name to allow or disallow its
# instantiation. The access to a factory class is allowed if the filter returns
# ALLOWED.
#
# Note: This property is currently used by the JDK Reference implementation.
# It is not guaranteed to be examined and used by other implementations.
Expand All @@ -1407,11 +1419,53 @@ jdk.io.permissionsUseCanonicalPath=false
#jdk.jndi.object.factoriesFilter=*

#
# The default Character set name (java.nio.charset.Charset.forName())
# for converting TLS ALPN values between byte arrays and Strings.
# Prior versions of the JDK may use UTF-8 as the default charset. If
# you experience interoperability issues, setting this property to UTF-8
# may help.
# Protocol Specific JNDI/LDAP Object Factories Filter
#
# jdk.tls.alpnCharset=UTF-8
jdk.tls.alpnCharset=ISO_8859_1
# This filter is used by the JNDI/LDAP provider implementation in the JDK to further control the
# set of object factory classes which will be allowed to instantiate objects from object
# references bound to LDAP contexts. The factory class named by the reference instance will
# be matched against this filter. The filter property supports pattern-based filter syntax
# with the same format as jdk.serialFilter. Limit patterns specified in the filter property
# are unused.
#
# Each class name pattern is matched against the factory class name to allow or disallow its
# instantiation. The access to a factory class is allowed only when it is not rejected by this filter
# or by the global filter defined by "jdk.jndi.object.factoriesFilter", and at least one of these
# two filters returns ALLOWED.
#
# Note: This property is currently used by the JDK Reference implementation.
# It is not guaranteed to be examined and used by other implementations.
#
# If the system property jdk.jndi.ldap.object.factoriesFilter is also specified, it supersedes
# the security property value defined here. The default value of the property is
# "java.naming/com.sun.jndi.ldap.**;!*".
#
# The default pattern value allows any object factory class defined in the java.naming module
# to be specified by the reference instance, but rejects any other.
#jdk.jndi.ldap.object.factoriesFilter=java.naming/com.sun.jndi.ldap.**;!*

#
# Protocol Specific JNDI/RMI Object Factories Filter
#
# This filter is used by the JNDI/RMI provider implementation in the JDK to further control the
# set of object factory classes which will be allowed to instantiate objects from object
# references bound to RMI names. The factory class named by the reference instance will
# be matched against this filter. The filter property supports pattern-based filter syntax
# with the same format as jdk.serialFilter. Limit patterns specified in the filter property
# are unused.
#
# Each class name pattern is matched against the factory class name to allow or disallow its
# instantiation. The access to a factory class is allowed only when it is not rejected by this filter
# or by the global filter defined by "jdk.jndi.object.factoriesFilter", and at least one of these
# two filters returns ALLOWED.
#
# Note: This property is currently used by the JDK Reference implementation.
# It is not guaranteed to be examined and used by other implementations.
#
# If the system property jdk.jndi.rmi.object.factoriesFilter is also specified, it supersedes
# the security property value defined here. The default value of the property is
# "jdk.naming.rmi/com.sun.jndi.rmi.**;!*".
#
# The default pattern value allows any object factory class defined in the jdk.naming.rmi module
# to be specified by the reference instance, but rejects any other.
#jdk.jndi.rmi.object.factoriesFilter=jdk.naming.rmi/com.sun.jndi.rmi.**;!*
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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 Down Expand Up @@ -33,9 +33,10 @@
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.ldap.Control;
import javax.naming.spi.*;

import com.sun.jndi.toolkit.ctx.Continuation;
import com.sun.naming.internal.NamingManagerHelper;
import com.sun.naming.internal.ObjectFactoriesFilter;

final class LdapBindingEnumeration
extends AbstractLdapNamingEnumeration<Binding> {
Expand Down Expand Up @@ -78,8 +79,8 @@ public Object run() throws NamingException {
cn.add(atom);

try {
obj = DirectoryManager.getObjectInstance(obj, cn, homeCtx,
homeCtx.envprops, attrs);
obj = NamingManagerHelper.getDirObjectInstance(obj, cn, homeCtx,
homeCtx.envprops, attrs, ObjectFactoriesFilter::checkLdapFilter);

} catch (NamingException e) {
throw e;
Expand Down
9 changes: 5 additions & 4 deletions src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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 Down Expand Up @@ -27,7 +27,6 @@

import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.spi.*;
import javax.naming.event.*;
import javax.naming.ldap.*;
import javax.naming.ldap.LdapName;
Expand All @@ -54,6 +53,8 @@
import com.sun.jndi.toolkit.dir.HierMemDirCtx;
import com.sun.jndi.toolkit.dir.SearchFilter;
import com.sun.jndi.ldap.ext.StartTlsResponseImpl;
import com.sun.naming.internal.NamingManagerHelper;
import com.sun.naming.internal.ObjectFactoriesFilter;

/**
* The LDAP context implementation.
Expand Down Expand Up @@ -1111,8 +1112,8 @@ protected Object c_lookup(Name name, Continuation cont)
}

try {
return DirectoryManager.getObjectInstance(obj, name,
this, envprops, attrs);
return NamingManagerHelper.getDirObjectInstance(obj, name, this,
envprops, attrs, ObjectFactoriesFilter::checkLdapFilter);

} catch (NamingException e) {
throw cont.fillInException(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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 Down Expand Up @@ -27,12 +27,13 @@

import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.spi.*;
import javax.naming.ldap.*;

import java.util.Hashtable;
import java.util.StringTokenizer;
import com.sun.jndi.toolkit.dir.SearchFilter;
import com.sun.naming.internal.NamingManagerHelper;
import com.sun.naming.internal.ObjectFactoriesFilter;

/**
* A context for handling referrals.
Expand Down Expand Up @@ -116,8 +117,8 @@ final class LdapReferralContext implements DirContext, LdapContext {

Object obj;
try {
obj = NamingManager.getObjectInstance(ref, null, null, env);

obj = NamingManagerHelper.getObjectInstance(ref, null, null,
env, ObjectFactoriesFilter::checkLdapFilter);
} catch (NamingException e) {

if (handleReferrals == LdapClient.LDAP_REF_THROW) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, 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 Down Expand Up @@ -32,11 +32,12 @@
import java.util.Vector;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.spi.*;
import javax.naming.ldap.*;
import javax.naming.ldap.LdapName;

import com.sun.jndi.toolkit.ctx.Continuation;
import com.sun.naming.internal.NamingManagerHelper;
import com.sun.naming.internal.ObjectFactoriesFilter;

final class LdapSearchEnumeration
extends AbstractLdapNamingEnumeration<SearchResult> {
Expand Down Expand Up @@ -136,9 +137,9 @@ public Object run() throws NamingException {
// Call getObjectInstance before removing unrequested attributes
try {
// rcn is either relative to homeCtx or a fully qualified DN
obj = DirectoryManager.getObjectInstance(
obj = NamingManagerHelper.getDirObjectInstance(
obj, rcn, (relative ? homeCtx : null),
homeCtx.envprops, attrs);
homeCtx.envprops, attrs, ObjectFactoriesFilter::checkLdapFilter);
} catch (NamingException e) {
throw e;
} catch (Exception e) {
Expand Down
Loading