Examples of UserEnvironment


Examples of de.iritgo.aktera.authentication.UserEnvironment

  public void createTables(String schema) throws PersistenceException
  {
    boolean securityBypass = false;

    UserEnvironment ue = null;

    if (keelContext != null)
    {
      try
      {
View Full Code Here

Examples of de.iritgo.aktera.authentication.UserEnvironment

      if (ctx == null)
      {
        return defaultLocale;
      }

      UserEnvironment userEnv = (UserEnvironment) ctx.get(UserEnvironment.CONTEXT_KEY);

      if (userEnv == null || userEnv.getUid() != UserEnvironment.ANONYMOUS_UID)
      {
        return defaultLocale;
      }

      if (userEnv.getAttribute(USER_CONTEXT_LOCALE_KEY) == null)
      {
        return defaultLocale;
      }

      return (Locale) userEnv.getAttribute(USER_CONTEXT_LOCALE_KEY);
    }
    catch (ModelException x)
    {
    }
    catch (ContextException x)
View Full Code Here

Examples of de.iritgo.aktera.authentication.UserEnvironment

      map.put("response", res);
      map.put("remember", new Boolean(remember));
      map.put("configuration", getConfiguration());
      authMgr.setOtherConfig(map);

      UserEnvironment ue = null;
      Context c = req.getContext();

      try
      {
        ue = (UserEnvironment) c.get(UserEnvironment.CONTEXT_KEY);
      }
      catch (ContextException e)
      {
        if (c instanceof DefaultContext)
        {
          ue = new DefaultUserEnvironment();
          ((DefaultContext) c).put(UserEnvironment.CONTEXT_KEY, ue);
        }
        else
        {
          throw new ModelException("Unable to write user env. to context, was '" + c.getClass().getName());
        }
      }

      authMgr.login(ue);

      try
      {
        HashMap cookies = new HashMap();

        if (remember)
        {
          String[] cookieSeq = getCryptSeq(configuration, "cookie");
          cookies.put(getLoginCookieName(configuration), encodeWithSeq(cookieSeq, loginName, req));
          cookies.put(getPasswordCookieName(configuration), encodeWithSeq(cookieSeq, providedPassword, req));
          cookies.put(getDomainCookieName(configuration), encodeWithSeq(cookieSeq, domain, req));
          res.addOutput("remembered", "$loginRemembered");
        }
        else
        {
          cookies.put(getLoginCookieName(configuration), "");
          cookies.put(getPasswordCookieName(configuration), "");
          cookies.put(getDomainCookieName(configuration), "");
          res.addOutput("remembered", "$loginNotRemembered");
        }

        res.setAttribute("cookies", cookies);
      }
      catch (ModelException e)
      {
        throw new LoginException("Error setting cookies - " + e.getMessage());
      }

      if (log.isDebugEnabled())
      {
        log.debug("Logged in authenticated user: " + loginName + " domain: " + domain);
        log.debug("\tPrincipals:");

        Iterator i = ue.getSubject().getPrincipals().iterator();
        while (i.hasNext())
        {
          Principal p = (Principal) i.next();
          log.debug(p.toString());
        }
View Full Code Here

Examples of de.iritgo.aktera.authentication.UserEnvironment

    if (config == null)
    {
      return res;
    }

    UserEnvironment userEnv = null;

    try
    {
      userEnv = (UserEnvironment) req.getContext().get(UserEnvironment.CONTEXT_KEY);
    }
    catch (ContextException x)
    {
    }

    Output outMenuList = res.createOutput("menuList");

    res.add(outMenuList);

    Configuration[] menus = config.getChildren("menu");

    for (int i = 0; i < menus.length; ++i)
    {
      Configuration menuConfig = menus[i];

      try
      {
        if (menuConfig.getAttribute("ifModule", null) != null
                && ! ModuleTools.moduleExists(req, menuConfig.getAttribute("ifModule")))
        {
          continue;
        }
      }
      catch (ConfigurationException x)
      {
      }

      String menuId = "menu_" + menuConfig.getAttribute("id", "");

      Output outMenu = null;

      for (Iterator j = outMenuList.getAll().iterator(); j.hasNext();)
      {
        Output aMenu = (Output) j.next();

        if (aMenu.getName().equals(menuId))
        {
          outMenu = aMenu;

          break;
        }
      }

      if (outMenu == null)
      {
        outMenu = res.createOutput(menuId);
        outMenuList.add(outMenu);
        outMenu.setAttribute("title", menuConfig.getAttribute("title", "$noTitle"));
      }

      Command cmd = null;

      Configuration[] items = menus[i].getChildren("item");

      int numVisibleItems = 0;

      for (int j = 0; j < items.length; ++j)
      {
        Configuration itemConfig = items[j];

        boolean itemAllowed = true;

        String model = itemConfig.getAttribute("model", null);

        if (model == null)
        {
          log.info("No model specified for menu item " + i + "/" + j);

          continue;
        }

        try
        {
          boolean validUser = itemConfig.getAttributeAsBoolean("validUser");

          try
          {
            itemAllowed = itemAllowed
                    && (validUser == (userEnv != null && userEnv.getUid() != UserEnvironment.ANONYMOUS_UID));
          }
          catch (AuthorizationException x)
          {
            itemAllowed = ! validUser;
          }
        }
        catch (ConfigurationException x)
        {
        }

        try
        {
          String userGroup = itemConfig.getAttribute("userGroup");

          try
          {
            itemAllowed = itemAllowed && userEnv != null && userEnv.getGroups().contains(userGroup);
          }
          catch (AuthorizationException x)
          {
            itemAllowed = false;
          }

          String notUserGroup = itemConfig.getAttribute("notUserGroup");

          if (notUserGroup != null)
          {
            try
            {
              itemAllowed = itemAllowed && userEnv != null
                      && ! userEnv.getGroups().contains(notUserGroup);
            }
            catch (AuthorizationException x)
            {
              itemAllowed = false;
            }
View Full Code Here

Examples of de.iritgo.aktera.authentication.UserEnvironment

      Context c = req.getContext();

      if (c != null)
      {
        UserEnvironment ue = (UserEnvironment) c.get(UserEnvironment.CONTEXT_KEY);

        try
        {
          loginName = ue.getLoginName();
        }
        catch (AuthorizationException e)
        {
          throw new ModelException("Authorization error", e);
        }
View Full Code Here

Examples of de.iritgo.aktera.authentication.UserEnvironment

    if (c == null)
    {
      throw new ModelException("No context established - request should have established context");
    }

    UserEnvironment userEnv = null;

    try
    {
      userEnv = (UserEnvironment) c.get(UserEnvironment.CONTEXT_KEY);

      if (userEnv != null)
      {
        int uid = userEnv.getUid();

        if (uid != UserEnvironment.ANONYMOUS_UID)
        {
          AuthenticationManager authMgr = (AuthenticationManager) req.getService(AuthenticationManager.ROLE,
                  "*");

          authMgr.setUsername(userEnv.getLoginName());
          authMgr.setPassword("");
          authMgr.setDomain(userEnv.getDomain());

          HashMap map = new HashMap();

          map.put("request", req);
          map.put("response", res);
          map.put("remember", new Boolean("off"));
          map.put("configuration", getConfiguration());
          authMgr.setOtherConfig(map);

          //Clear cookies if the clear-cookies config. attribute is true
          boolean clearCookies = configuration.getAttributeAsBoolean("clear-cookies", true);

          if (clearCookies)
          {
            HashMap cookies = new HashMap();

            cookies.put(getLoginCookieName(configuration), "");
            cookies.put(getPasswordCookieName(configuration), "");
            cookies.put(getDomainCookieName(configuration), "");
            res.setAttribute("cookies", cookies);
          }

          try
          {
            authMgr.logout(userEnv);
          }
          catch (Exception ee)
          {
            log.error("Logout Error", ee);
            throw new ModelException(ee);
          }

          userEnv.clearAttributes();
          userEnv.reset();

          //          DefaultContext dc = (DefaultContext) req.getContext ();
          //          dc.put (UserEnvironment.CONTEXT_KEY, null);
          PreferencesManager preferencesManager = (PreferencesManager) SpringTools
                  .getBean(PreferencesManager.ID);
View Full Code Here

Examples of de.iritgo.aktera.authentication.UserEnvironment

    {
      ModelRequest request = null;

      try
      {
        UserEnvironment userEnvironment = new FakeAdminUserEnvironment();
        Context context = new DefaultContext();
        ((DefaultContext) context).put(UserEnvironment.CONTEXT_KEY, userEnvironment);
        request = (ModelRequest) KeelTools.getService(ModelRequest.ROLE, "default-request", context);
        createOrUpdateAddress(request, data.get(), reporter, properties);
        data.remove();
View Full Code Here

Examples of de.iritgo.aktera.authentication.UserEnvironment

    int uid = 0;

    try
    {
      Context ctx = req.getContext();
      UserEnvironment ue = null;

      if (ctx != null)
      {
        try
        {
          ue = (UserEnvironment) ctx.get(UserEnvironment.CONTEXT_KEY);
          uid = ue.getUid();
        }
        catch (ContextException ce)
        {
          log.debug("Unable to acces user environment from context!");
        }
        catch (AuthorizationException x)
        {
          log.debug("AuthorizationException!");
        }

        if (ue != null)
        {
          try
          {
            if (ue.getUid() == UserEnvironment.ANONYMOUS_UID)
            {
              log.debug("BUG, this can't true");
            }
          }
          catch (AuthorizationException e)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.