try/catch block contains only Dircontext instance -> ssl connect app freeze

Hello,

1 week all was fine now its a mess again and i dont know...

scroll down pls to the last try/catch block. The code within i commented with /* code */ only the:

DirContext ctx =new InitialDirContext(propsPassword);

String neuesKennwortAD ="\"" + neuesKennwortTemp +"\"";

byte[] newpassword = neuesKennwortAD.getBytes("UTF-16LE");

ctx.close();

is still there, when i now press my JButton and try to connect via ssl the first time the app is running the app freezes for 10 seconds and i get this error msg:

javax.naming.ServiceUnavailableException: rhein:636; socket closed

If I try to connect further times while the app is running by pressing the JButton i can connect via ssl without any problem? THAT SUXX !

I have removed all code within the try/catch block only the Context i created is still there. What I am doing wrong ?

publicvoid actionPerformed(ActionEvent e)

{

char[] neuesKennwortArray= neuesKennwortPF.getPassword();

char[] neuesKennwortWdhArray = neuesKennwortWdhPF.getPassword();

if (e.getSource().equals(pwBT))

{

if(listeLehrer.isSelectionEmpty() & listeSchueler.isSelectionEmpty())

{

JOptionPane.showMessageDialog(frame,"Sie mssen einen Benutzer auswhlen!");

return;

}

elseif(!Arrays.equals(neuesKennwortArray,neuesKennwortWdhArray))

{

JOptionPane.showMessageDialog(frame,"Die eingegebenen Kennwrter sind nicht gleich!");

return;

}

elseif(neuesKennwortArray.length == 0 || neuesKennwortWdhArray.length == 0)

{

JOptionPane.showMessageDialog(frame,"Es wurde kein Kennwort eingegeben!");

return;

}

else

{

benutzernameEinlesen();// Fr diesen Benutzer wird das Kennwort gendert

neuesKennwortEinlesen();// Dieses Kennwort bekommt der obige Benutzer neu

// befindet. Dieser schulname bzw. z.B. OU="ASR" wird als Einstieg genommen, wenn sich der EDV-Lehrer

// mit dem W2K Server befindet. Somit gibt es nur noch das Unterverzeichnis

// Ein Properties speichert Schlssel/Wert Paare

Properties propsPassword =new Properties();

String keystore ="C:/Programme/Java/jre1.6.0_01/lib/security/ZertifikatBerlin";

System.setProperty("javax.net.ssl.trustStore",keystore);

// Die Methode put der Klasse Hashtable weist die rechten Werte (Stings hier) einen Schlssel zu (verschiedene Kontexte hier)

propsPassword.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

propsPassword.put(Context.REFERRAL,"follow");// verursacht Fehler mit W2K

propsPassword.put(Context.PROVIDER_URL,"ldaps://rhein:636");

propsPassword.put(Context.SECURITY_PROTOCOL,"SSL");

propsPassword.put(Context.SECURITY_AUTHENTICATION,"simple");

propsPassword.put(Context.SECURITY_PRINCIPAL, adminUser);

propsPassword.put(Context.SECURITY_CREDENTIALS,adminPassword);

try

{

DirContext ctx =new InitialDirContext(propsPassword);

/*

// Wert fr das Kenntwort in der Activev Directory erzeugen

// The username to be used for the password change

ModificationItem mods[] = new ModificationItem[1]; // in dem mods[] array wird 1 Moditem reserviert um speicher zu sparen,

// denn es wird auch nur 1 Wert in das mod[] array eingelesen und nicht mehr...

mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("unicodePwd", newpassword));

ctx.modifyAttributes(benutzernameRichtig,mods);

//JOptionPane.showMessageDialog(frame,"Passwort von Benutzer: " + benutzername + " wurde gendert!");

*/

ctx.close();

}

catch (Exception er)

{

fehlerNachrichtTF.setText(er.toString());

}

}

}

}

-

DirContext ctx =new InitialDirContext(propsPassword);

String neuesKennwortAD ="\"" + neuesKennwortTemp +"\"";

byte[] newpassword = neuesKennwortAD.getBytes("UTF-16LE");

ctx.close();

from the above code , when i remove the byte[] newpassword = etc... code the app dont freeze the first time it is run but when i add the byte[] newpassword = etc... code the app freezes, why?

PLEASE HELP!

and the most ridiculous thing is when i add the following code after the byte[] array:

errormessageTF.setText(newpassword.toString()); and output the password in a textfield the app dont freeze ?

What the heck is this? JNDI is getting one crazy if you do the least thing...

[6415 byte] By [4tha] at [2007-11-27 11:13:23]
# 1

Why are you closing the context ?

There is always some overhead/latency involved when setting up a SSL session, perhaps it shouldn't be 10 seconds.

Establish the context when the application starts and close the context when you close the app.

Don't open and close the context everytime you reset a password.

adler_stevena at 2007-7-29 14:00:34 > top of Java-index,Core,Core APIs...