Package org.exoplatform.services.security

Examples of org.exoplatform.services.security.ConversationState


      {
         ExoContainer container = getContainer(httpSession.getServletContext());
         ConversationRegistry conversationRegistry =
            (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

         ConversationState conversationState = conversationRegistry.unregister(stateKey);

         if (conversationState != null)
         {
            if (LOG.isDebugEnabled())
               LOG.debug("Remove conversation state " + httpSession.getId());
            if (conversationState.getAttribute(ConversationState.SUBJECT) != null)
            {
               Subject subject = (Subject)conversationState.getAttribute(ConversationState.SUBJECT);
               String realmName =
                  container instanceof PortalContainer ? ((PortalContainer)container).getRealmName()
                     : PortalContainer.DEFAULT_REALM_NAME;
               LoginContext ctx = new LoginContext(realmName, subject);
               ctx.logout();
View Full Code Here


      // SYSTEM
      // TODO do we need to cache system state (identity) in registry?
      if (thisCredentials.getUserID().equals(SystemIdentity.SYSTEM))
      {
         Identity sid = new Identity(SystemIdentity.SYSTEM, new HashSet<MembershipEntry>());
         return new ConversationState(sid);
      }

      // prepare to new login
      // uses BasicCallbackHandler
      CallbackHandler handler = new BasicCallbackHandler(thisCredentials.getUserID(), thisCredentials.getPassword());

      // and try to login
      try
      {

         LoginContext loginContext = new LoginContext(config.getSecurityDomain(), handler);
         loginContext.login();

      }
      catch (javax.security.auth.login.LoginException e)
      {
         throw new LoginException("Login failed for " + thisCredentials.getUserID() + " " + e);
      }

      if (log.isDebugEnabled())
         log.debug("Logged " + thisCredentials.getUserID());

      // supposed to be set
      Identity identity = identityRegistry.getIdentity(thisCredentials.getUserID());
      if (identity == null)
      {
         throw new LoginException("Identity not found, check Loginmodule, userId " + thisCredentials.getUserID());
      }
      ConversationState state = new ConversationState(identity);
      String[] aNames = thisCredentials.getAttributeNames();
      for (String name : aNames)
      {
         state.setAttribute(name, thisCredentials.getAttribute(name));
      }

      ConversationState.setCurrent(state);
      return state;
View Full Code Here

    * @see org.exoplatform.services.jcr.access.AuthenticationPolicy#authenticate()
    */
   public ConversationState authenticate() throws LoginException
   {

      ConversationState state = ConversationState.getCurrent();

      if (state == null)
      {
         log.warn("No current identity found, ANONYMOUS one will be used");
         return new ConversationState(new Identity(SystemIdentity.ANONIM, new HashSet<MembershipEntry>()));
      }

      ConversationState.setCurrent(state);
      return state;

View Full Code Here

   {

      if (getState() == OFFLINE)
         LOG.warn("Repository " + getName() + " is OFFLINE.");

      ConversationState state;

      if (credentials != null)
         state = authenticationPolicy.authenticate(credentials);
      else
         state = authenticationPolicy.authenticate();
View Full Code Here

            UIAccountProfiles uiForm = event.getSource();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            UIApplication uiApp = context.getUIApplication();

            ConversationState state = ConversationState.getCurrent();
            String userName = ((User) state.getAttribute(CacheUserProfileFilter.USER_PROFILE)).getUserName();
            User user = service.getUserHandler().findUserByName(userName);
            if (user != null) {
                String oldEmail = user.getEmail();
                String newEmail = uiForm.getUIStringInput("email").getValue();

                // Check if mail address is already used
                Query query = new Query();
                query.setEmail(newEmail);
                if (service.getUserHandler().findUsers(query).getAll().size() > 0 && !oldEmail.equals(newEmail)) {
                    // Be sure it keep old value
                    user.setEmail(oldEmail);
                    Object[] args = { userName };
                    uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args));
                    return;
                }
                user.setFirstName(uiForm.getUIStringInput("firstName").getValue());
                user.setLastName(uiForm.getUIStringInput("lastName").getValue());
                user.setDisplayName(uiForm.getUIStringInput("displayName").getValue());
                user.setEmail(newEmail);
                uiApp.addMessage(new ApplicationMessage("UIAccountProfiles.msg.update.success", null));
                try {
                    service.getUserHandler().saveUser(user, true);
                } catch (Exception e) {
                    uiApp.addMessage(new ApplicationMessage("UIAccountProfiles.msg.update.fail", null, ApplicationMessage.ERROR));
                    return;
                }

                state.setAttribute(CacheUserProfileFilter.USER_PROFILE, user);
                UIWorkingWorkspace uiWorkingWS = Util.getUIPortalApplication().getChild(UIWorkingWorkspace.class);
                uiWorkingWS.updatePortletsByName("UserInfoPortlet");
                uiWorkingWS.updatePortletsByName("OrganizationPortlet");
            } else {
                JavascriptManager jsManager = Util.getPortalRequestContext().getJavascriptManager();
View Full Code Here

    * @param group
    * @return
    */
   public boolean isUserInGroup(String group)
   {
      ConversationState conv = ConversationState.getCurrent();
      Identity id = null;
      if (conv != null)
      {
         id = conv.getIdentity();
      }

      if (id == null)
      {
         return false;
View Full Code Here

      return false;
   }

   private Identity getIdentity()
   {
      ConversationState conv = ConversationState.getCurrent();
      if (conv == null)
      {
         return guest;
      }

      Identity id = conv.getIdentity();
      if (id == null)
      {
         return guest;
      }
View Full Code Here

         throw new LoginException(
                  "Credentials for the authentication should be CredentialsImpl or SimpleCredentials type");

      SessionFactory sessionFactory = (SessionFactory) container.getComponentInstanceOfType(SessionFactory.class);

      ConversationState newState =
               new ConversationState(new Identity(name, userState.getIdentity().getMemberships(), userState
                        .getIdentity().getRoles()));
      return (Session) sessionFactory.createSession(newState);

   }
View Full Code Here

      providerService = (SessionProviderService)container.getComponentInstanceOfType(SessionProviderService.class);
      stateRegistry = (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

      HttpServletRequest httpRequest = (HttpServletRequest)request;

      ConversationState state = ConversationState.getCurrent();
      SessionProvider provider = null;

      // NOTE not create new HTTP session, if session is not created yet
      // this means some settings is incorrect, see web.xml for filter
      // org.exoplatform.services.security.web.SetCurrentIdentityFilter
View Full Code Here

         throw new LoginException(
            "Credentials for the authentication should be CredentialsImpl or SimpleCredentials type");

      SessionFactory sessionFactory = (SessionFactory)container.getComponentInstanceOfType(SessionFactory.class);

      ConversationState newState =
         new ConversationState(new Identity(name, userState.getIdentity().getMemberships(), userState.getIdentity()
            .getRoles()));
      return (Session)sessionFactory.createSession(newState);

   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.security.ConversationState

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.