
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
54 lines
1.5 KiB
Plaintext
54 lines
1.5 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
This rule raises an issue when an LDAP connection is created with ``++Context.SECURITY_AUTHENTICATION++`` set to ``++"none"++``.
|
|
|
|
[source,java]
|
|
----
|
|
// Set up the environment for creating the initial context
|
|
Hashtable<String, Object> env = new Hashtable<String, Object>();
|
|
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
|
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");
|
|
|
|
// Use anonymous authentication
|
|
env.put(Context.SECURITY_AUTHENTICATION, "none"); // Noncompliant
|
|
|
|
// Create the initial context
|
|
DirContext ctx = new InitialDirContext(env);
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
// Set up the environment for creating the initial context
|
|
Hashtable<String, Object> env = new Hashtable<String, Object>();
|
|
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
|
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");
|
|
|
|
// Use simple authentication
|
|
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
|
env.put(Context.SECURITY_PRINCIPAL, "cn=S. User, ou=NewHires, o=JNDITutorial");
|
|
env.put(Context.SECURITY_CREDENTIALS, getLDAPPassword());
|
|
|
|
// Create the initial context
|
|
DirContext ctx = new InitialDirContext(env);
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|