0 Replies Latest reply on Feb 2, 2005 3:21 PM by Boris Novos

    Problem to get user?s credentials from ORB object

    Boris Novos Newbie


      Hi,
      I have a problem to get user?s credentials on the server side from ORB object.

      I run a simple application on jboss-3.2.6
      - runs in ?all? configuration;
      - has modified standardjboss.xml - added security-domain
      - has modified login-config.xml - added corresponding to domain application-policy
      -all other config files, including jacorb.properties are in ?after installation? version

      Java client authenticates with the server, looks up a bean and calls compute().
      It seems that JAAS authentication works fine - I can see that MyServerLoginModule (extends UsernamePasswordLoginModule) is performing authentication and I can get user?s ID by calling inside the bean sessionContext.getCallerPrincipal().getName();

      Here is client code:

      UsernamePasswordHandler handler = new UsernamePasswordHandler("user1",
      "password1".toCharArray());

      LoginContext lc = null;
      try {
      lc = new LoginContext("client-login", handler);
      lc.login();

      } catch(LoginException e) {
      e1.printStackTrace();
      }


      Hashtable env = new Hashtable();
      env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.provider.url", "jnp://48.128.38.888:1099/");
      env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      env.put("jnp.socketFactory", "org.jnp.interfaces.TimedSocketFactory");
      env.put("jnp.timeout", "0");
      env.put("jnp.sotimeout", "0");

      try {
      Context ctx = new InitialContext(env);
      Object cobj = ctx.lookup(FiboHome.JNDI_NAME);
      FiboHome home = (FiboHome)PortableRemoteObject.narrow(cobj, FiboHome.class);
      Fibo fibo = home.create();
      fibo.compute(5);
      hello.remove();
      } catch(Exception e) {
      e.printStackTrace();
      }
      }


      Unfortunately, it is not good enough. I need to get user?s ID when I am outside of bean and I don?t have access to SessionContext. I am trying to get it from ORB object

      org.jacorb.orb.ORB orb = (org.jacorb.orb.ORB)CorbaORB.getInstance();
      org.omg.SecurityLevel2.Current current = CurrentHelper.narrow(orb.resolve_initial_references("SecurityCurrent"));

      //At this point all following calls return null or empty arrays. Looks like Current
      //does not hold any credentials

      SecAttribute[] secAttrs = current.get_attributes(new AttributeType[0]);
      ReceivedCredentials rc = current.received_credentials();
      Credentials[] own_credentials = current.own_credentials()
      Credentials[] cred = securityCurrent.get_credentials(CredentialType.SecNRCredentials);


      When run I see 2 warnings on server side
      14:51:47,332 WARN [security] Class null not found! Please check property "jacorb.security.access_decision"
      14:51:47,432 WARN [security] No PrincipalAuthenticator set. Will not authenticate!

      I looked at jacorb.properties and it seems that these properties are related to SSL, which I am not interested in at this point.

      Anyone knows what I am missing or doing wrong ?

      Another question, anyone knows how to get client?s IP address on server side ?


      Thanks in advance
      Boris