0 Replies Latest reply: Nov 5, 2013 7:03 PM by Miguel Angel RSS

    Single Sign On with Java and ADF

    Miguel Angel

      I have tested this code in a simple java class to authenticate to the active directory and it works.(JDeveloper 11.1.2.3.0). This is a local test in my PC.

       

      private boolean autenticateAD(){

          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY, AD_INITIAL_CONTEXT_FACTORY);
          env.put(Context.SECURITY_AUTHENTICATION, AD_AUTHENTICATION);
          env.put(Context.PROVIDER_URL, AD_URL);
          env.put(Context.SECURITY_PRINCIPAL, usuario.concat(AD_DOMAIN));
          env.put(Context.SECURITY_CREDENTIALS, clave);

       

          DirContext dirContext = null;
          try {
              dirContext = new InitialDirContext(env);
              if (dirContext != null) {
                  System.out.println(dirContext.getEnvironment().size());
                  System.out.println(dirContext);
                  return true;
              }
          } catch (NamingException ex) {
              ex.printStackTrace();
          }
       

      return false;

      }

      When I put this code inside my login action(af:commandButton) the control flow case defined in my unbounded task flow doesn't work:

       

      public String btnIngresar_action() {
                  boolean autenticacionAD = autenticarAD();
                  if (autenticacionAD) {
             

               return "success";

            }

         return null;

                }

       

      The adf application is still in the login page.