Package nexj.core.util.auth

Examples of nexj.core.util.auth.SimplePrincipal


   {
      InvocationContext context = (InvocationContext)Repository.getMetadata().getComponent("System.InvocationContext")
         .getInstance(null);

      context.setAudited(false);
      context.initialize((m_sUser == null) ? null : new SimplePrincipal(m_sUser));
      context.setLocale(Locale.getDefault());
      context.getUnitOfWork().commit();

      ThreadContextHolder.setContext(context);
View Full Code Here


    * Initializes the invocation context.
    */
   protected void init()
   {
      m_context = (InvocationContext)Repository.getMetadata().getComponent("System.InvocationContext").getInstance(null);
      m_context.initialize(new SimplePrincipal(getProperty("app.user", "anonymous")));
      m_context.setLocale(Locale.getDefault());
      m_context.setProtected(false);
      m_context.setSecure(false);
   }
View Full Code Here

      assertEquals("pre con", res.getResult(0));
   }

   public void testSecurity()
   {
      m_context.initialize(new SimplePrincipal("jsmith"));

      Server server = (Server)m_context.getComponentInstance("Server.Generic");
      Request req = new Request();

      req.addInvocation(new TransferObject("Contact", "read"),
         new Object[]{null, null, null, new Integer(-1), new Integer(0), Boolean.FALSE});

      try
      {
         server.invoke(req);
         fail("Expected SecurityViolationException");
      }
      catch (SecurityViolationException e)
      {
         assertEquals("err.runtime.privilege", e.getErrorCode());
         assertEquals("readContact", e.getErrorArgs()[0]);
      }

      req = new Request();
      req.addInvocation(new TransferObject("StringEnum", "read"),
         new Object[]{null, parse("(= value (SupportedLocaleEnum'en))"),
         null, new Integer(-1), new Integer(0), Boolean.FALSE});

      Response res = server.invoke(req);

      assertEquals(1, res.getResultCount());
      assertEquals(1, ((List)res.getResult(0)).size());

      req.getInvocation(0).getArguments()[1] = parse("(= (user) (User'getUser \"jsmith\"))");

      try
      {
         res = server.invoke(req);
         fail("Expected SecurityViolationException");
      }
      catch (SecurityViolationException e)
      {
         assertEquals("err.rpc.eventVisibility", e.getErrorCode());
         assertEquals("getUser", e.getErrorArgs()[0]);
         assertEquals("User", e.getErrorArgs()[1]);
      }

      req = new Request();
      req.addInvocation(new TransferObject("Address", "read"),
         new Object[]{null, parse("(!= (@ contact (instance? (@) Patient) birthdate) ())"),
         null, new Integer(-1), new Integer(0), Boolean.FALSE});

      try
      {
         server.invoke(req);
         fail("Expected SecurityViolationException");
      }
      catch (SecurityViolationException e)
      {
         assertEquals("err.rpc.attributeReadPrivilege", e.getErrorCode());
         assertEquals("birthdate", e.getErrorArgs()[0]);
         assertEquals("Patient", e.getErrorArgs()[1]);
         assertEquals("readContact", e.getErrorArgs()[2]);
      }

      m_context.initialize(new SimplePrincipal("jtest"));

      req = new Request();
      req.addInvocation(new TransferObject("Address", "read"),
         new Object[]{null, parse("(!= (@ contact (instance? (@) Patient) birthdate) ())"),
         null, new Integer(-1), new Integer(0), Boolean.FALSE});
View Full Code Here

      //Initialize InvocationContext
      Metadata metadata = Repository.getMetadata();
      InvocationContext context = new InvocationContext(metadata);

      context.setUserClass(metadata.getMetaclass("User"));
      context.initialize(new SimplePrincipal("jtest"));

      ThreadContextHolder.setContext(context);


      //Start work unit 1
View Full Code Here

      //Initialize InvocationContext
      Metadata metadata = Repository.getMetadata();
      InvocationContext context = new InvocationContext(metadata);

      context.setUserClass(metadata.getMetaclass("User"));
      context.initialize(new SimplePrincipal("jtest"));

      ThreadContextHolder.setContext(context);


      //Start work unit 1
View Full Code Here

      {
         System.setProperty(SysUtil.PROPERTY_PREFIX + SysUtil.CONFIG_PROPERTY, "/nexj/core/integration/test.server");
         m_metadata = Repository.getMetadata();

         m_context = (InvocationContext)Repository.getMetadata().getComponent("System.InvocationContext").getInstance(null);
         m_context.initialize(new SimplePrincipal("test"));
      }
      catch (Exception e)
      {
         fail();
      }
View Full Code Here

      {
         principal = ANONYMOUS_PRINCIPAL;
      }
      else
      {
         principal = new SimplePrincipal((String)user.getValue("name"));
      }

      setUser(user);
      m_principal = principal;
   }
View Full Code Here

         if (upgrade != null)
         {
            if (m_sUser != null && m_sUser.length() != 0)
            {
               context.login(new SimplePrincipal(m_sUser));
               Logger.resetContext(nCookie);
               nCookie = Logger.pushContext(context.getPrincipal().getName());
            }

            upgrade.invoke("upgrade");
View Full Code Here

      m_metadata.setTrustedCertificate(CertificateUtil.parseCertificate(envProps.getProperty("trust")));
      m_metadata.setGenericRPCAllowed(StringUtil.parseBoolean(envProps.getProperty("authRPC", "true")));

      String sAnonymousUser = envProps.getProperty("anonUser", "anonymous");

      m_metadata.setAnonymousUser(new SimplePrincipal(sAnonymousUser));
      m_metadata.setAnonymousRPCEnabled(StringUtil.parseBoolean(envProps.getProperty("anonRPC", "false")));
      m_metadata.setAnonymousFlatPageEnabled(StringUtil.parseBoolean(envProps.getProperty("anonWeb", "false")));

      final String sRPCPrivilege = envProps.getProperty("rpcPrivilege");
View Full Code Here

         if (sAddress != null)
         {
            nCookie = Logger.pushContext(sAddress);
         }

         context.login((sUser != null) ? new SimplePrincipal(sUser) : null);

         int nUserCookie = Logger.pushContext(context.getPrincipal().getName());

         if (nCookie == -1)
         {
View Full Code Here

TOP

Related Classes of nexj.core.util.auth.SimplePrincipal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.