77
88public class InsecureLdapAuth {
99 // BAD - Test LDAP authentication in cleartext using `DirContext`.
10- public void testCleartextLdapAuth (String ldapUserName , String password ) {
10+ public void testCleartextLdapAuth (String ldapUserName , String password ) throws Exception {
1111 String ldapUrl = "ldap://ad.your-server.com:389" ;
1212 Hashtable <String , String > environment = new Hashtable <String , String >();
1313 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
@@ -21,7 +21,7 @@ public void testCleartextLdapAuth(String ldapUserName, String password) {
2121 }
2222
2323 // BAD - Test LDAP authentication in cleartext using `DirContext`.
24- public void testCleartextLdapAuth (String ldapUserName , String password , String serverName ) {
24+ public void testCleartextLdapAuth (String ldapUserName , String password , String serverName ) throws Exception {
2525 String ldapUrl = "ldap://" +serverName +":389" ;
2626 Hashtable <String , String > environment = new Hashtable <String , String >();
2727 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
@@ -35,7 +35,7 @@ public void testCleartextLdapAuth(String ldapUserName, String password, String s
3535 }
3636
3737 // GOOD - Test LDAP authentication over SSL.
38- public void testSslLdapAuth (String ldapUserName , String password ) {
38+ public void testSslLdapAuth (String ldapUserName , String password ) throws Exception {
3939 String ldapUrl = "ldaps://ad.your-server.com:636" ;
4040 Hashtable <String , String > environment = new Hashtable <String , String >();
4141 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
@@ -49,7 +49,7 @@ public void testSslLdapAuth(String ldapUserName, String password) {
4949 }
5050
5151 // GOOD - Test LDAP authentication over SSL.
52- public void testSslLdapAuth2 (String ldapUserName , String password ) {
52+ public void testSslLdapAuth2 (String ldapUserName , String password ) throws Exception {
5353 String ldapUrl = "ldap://ad.your-server.com:636" ;
5454 Hashtable <String , String > environment = new Hashtable <String , String >();
5555 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
@@ -64,7 +64,7 @@ public void testSslLdapAuth2(String ldapUserName, String password) {
6464 }
6565
6666 // GOOD - Test LDAP authentication with SASL authentication.
67- public void testSaslLdapAuth (String ldapUserName , String password ) {
67+ public void testSaslLdapAuth (String ldapUserName , String password ) throws Exception {
6868 String ldapUrl = "ldap://ad.your-server.com:389" ;
6969 Hashtable <String , String > environment = new Hashtable <String , String >();
7070 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
@@ -78,7 +78,7 @@ public void testSaslLdapAuth(String ldapUserName, String password) {
7878 }
7979
8080 // GOOD - Test LDAP authentication in cleartext connecting to local LDAP server.
81- public void testCleartextLdapAuth2 (String ldapUserName , String password ) {
81+ public void testCleartextLdapAuth2 (String ldapUserName , String password ) throws Exception {
8282 String ldapUrl = "ldap://localhost:389" ;
8383 Hashtable <String , String > environment = new Hashtable <String , String >();
8484 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
@@ -92,7 +92,7 @@ public void testCleartextLdapAuth2(String ldapUserName, String password) {
9292 }
9393
9494 // BAD - Test LDAP authentication in cleartext using `InitialLdapContext`.
95- public void testCleartextLdapAuth3 (String ldapUserName , String password ) {
95+ public void testCleartextLdapAuth3 (String ldapUserName , String password ) throws Exception {
9696 String ldapUrl = "ldap://ad.your-server.com:389" ;
9797 Hashtable <String , String > environment = new Hashtable <String , String >();
9898 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
@@ -107,7 +107,7 @@ public void testCleartextLdapAuth3(String ldapUserName, String password) {
107107
108108
109109 // BAD - Test LDAP authentication in cleartext using `DirContext` and string literals.
110- public void testCleartextLdapAuth4 (String ldapUserName , String password ) {
110+ public void testCleartextLdapAuth4 (String ldapUserName , String password ) throws Exception {
111111 String ldapUrl = "ldap://ad.your-server.com:389" ;
112112 Hashtable <String , String > environment = new Hashtable <String , String >();
113113 environment .put ("java.naming.factory.initial" ,
@@ -131,7 +131,7 @@ private void setBasicAuth(Hashtable env, String ldapUserName, String password) {
131131 }
132132
133133 // GOOD - Test LDAP authentication with `ssl` configuration and basic authentication.
134- public void testCleartextLdapAuth5 (String ldapUserName , String password , String serverName ) {
134+ public void testCleartextLdapAuth5 (String ldapUserName , String password , String serverName ) throws Exception {
135135 String ldapUrl = "ldap://" +serverName +":389" ;
136136 Hashtable <String , String > environment = new Hashtable <String , String >();
137137 setSSL (environment );
@@ -143,7 +143,7 @@ public void testCleartextLdapAuth5(String ldapUserName, String password, String
143143 }
144144
145145 // BAD - Test LDAP authentication with basic authentication.
146- public void testCleartextLdapAuth6 (String ldapUserName , String password , String serverName ) {
146+ public void testCleartextLdapAuth6 (String ldapUserName , String password , String serverName ) throws Exception {
147147 String ldapUrl = "ldap://" +serverName +":389" ;
148148 Hashtable <String , String > environment = new Hashtable <String , String >();
149149 environment .put (Context .INITIAL_CONTEXT_FACTORY ,
0 commit comments