Package de.iritgo.aktera.authentication

Examples of de.iritgo.aktera.authentication.AuthenticationManager


      try
      {
        req = ModelTools.createModelRequest();

        AuthenticationManager authMgr = (AuthenticationManager) req.getService(AuthenticationManager.ROLE,
                "default");

        authMgr.setUsername(user.getName());
        authMgr.setPassword(event.getPlainPassword());
        authMgr.setDomain("default");

        UserEnvironment userEnvironment = new DefaultUserEnvironment();
        Context context = new DefaultContext();

        ((DefaultContext) context).put(UserEnvironment.CONTEXT_KEY, userEnvironment);
        authMgr.login(userEnvironment);
        keelIritgoAuthMap.put(new Long(user.getUniqueId()), context);
      }
      catch (Exception x)
      {
        x.printStackTrace();
      }
      finally
      {
        ModelTools.releaseModelRequest(req);
      }
    }

    if ((event != null) && (event.isLoggedOut()))
    {
      User user = event.getUser();

      ModelRequest req = null;

      try
      {
        req = ModelTools.createModelRequest();

        AuthenticationManager authMgr = (AuthenticationManager) req.getService(AuthenticationManager.ROLE, "*");

        authMgr.setUsername(user.getName());
        authMgr.setPassword("");
        authMgr.setDomain("default");

        Context c = (Context) keelIritgoAuthMap.get(new Long(user.getUniqueId()));
        UserEnvironment userEnv = (UserEnvironment) c.get(UserEnvironment.CONTEXT_KEY);

        authMgr.logout(userEnv);
        keelIritgoAuthMap.remove(user.getUniqueId());
      }
      catch (Exception x)
      {
      }
View Full Code Here


      if (req.getParameters().containsKey("remember"))
      {
        remember = true;
      }

      AuthenticationManager authMgr = (AuthenticationManager) req.getService(AuthenticationManager.ROLE, domain);
      authMgr.setUsername(loginName);
      authMgr.setPassword(providedPassword);
      authMgr.setDomain(domain);

      HashMap map = new HashMap();
      map.put("request", req);
      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();
View Full Code Here

      {
        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);
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.authentication.AuthenticationManager

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.