Package org.apache.jetspeed.components

Examples of org.apache.jetspeed.components.ComponentManager


    {
        // initialize
        super.init(config);

        // get jetspeed component manager configuration for decorations
        ComponentManager cm = Jetspeed.getComponentManager();
        if (null == cm// TODO: retry loop
            throw new ServletException("Could not get Jetspeed Component Manager");
       
        decorationLocator = (TemplateLocator) cm.getComponent("DecorationLocator");

        // initialize thread safe velocity engine cache
        int cacheSize = (int) getLongInitParameter(config, CACHE_SIZE_PARAMETER, DEFAULT_CACHE_SIZE);
        velocityEngineConfigCache = new LRUMap(cacheSize);
        velocityEngineCache = new LRUMap(cacheSize/2);
View Full Code Here


            HttpServletRequest request = (HttpServletRequest)sRequest;
            String username = request.getParameter(LoginConstants.USERNAME);
            String password = request.getParameter(LoginConstants.PASSWORD);           
            if (username != null)
            {
                ComponentManager cm = Jetspeed.getComponentManager();
                UserManager userManager = (UserManager)cm.getComponent("org.apache.jetspeed.security.UserManager");
                AuditActivity audit = (AuditActivity)cm.getComponent("org.apache.jetspeed.audit.AuditActivity");
                AuthenticationProvider authProvider = (AuthenticationProvider)cm.getComponent("org.apache.jetspeed.security.AuthenticationProvider");
               
                // Commenting out for the using latest securty API's
                //boolean success = userManager.authenticate(username, password);
                //if (success)
                AuthenticatedUser authUser = null;
                try{
                  authUser = authProvider.authenticate(username, password)
                }
                catch (SecurityException e)
                {
                    audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "PortalFilter");                   
                    request.getSession().setAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_INVALID_PASSWORD);
        }
                if (authUser != null)
                {
                    audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "PortalFilter");
                    PortalAuthenticationConfiguration authenticationConfiguration = (PortalAuthenticationConfiguration)
                        cm.getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");
                    if (authenticationConfiguration.isCreateNewSessionOnLogin())
                    {
                        request.getSession().invalidate();
                    }
                    else
                    {
                        UserContentCacheManager userContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");
                        userContentCacheManager.evictUserContentCache(username, request.getSession().getId());
                    }
                    if (authUser.getUser() == null)
                    {
                        try
View Full Code Here

  {
  }

  public void doFilter(ServletRequest sRequest, ServletResponse sResponse, FilterChain filterChain) throws IOException, ServletException
  {
        ComponentManager cm = Jetspeed.getComponentManager();
    AuthenticationProvider authProvider = (AuthenticationProvider) cm.getComponent("org.apache.jetspeed.security.AuthenticationProvider");
    if (sRequest instanceof HttpServletRequest)
    {
      HttpServletRequest request = (HttpServletRequest) sRequest;
      if (userNameHeader == null)
      {
        synchronized (sem)
        {
          ShibbolethConfiguration config = (ShibbolethConfiguration) cm.getComponent(
              "org.apache.jetspeed.security.shibboleth.ShibbolethConfiguration");
          userNameHeader = config.getHeaderMapping().get(ShibbolethConfiguration.USERNAME);
        }
      }
      String username = request.getHeader(userNameHeader);
      if (username != null)
      {
        Subject subject = (Subject) request.getSession().getAttribute(PortalReservedParameters.SESSION_KEY_SUBJECT);
        if (subject != null)
        {
          Principal principal = SubjectHelper.getPrincipal(subject, UserSubjectPrincipal.class);
          if (principal != null)
          {
            if (principal.getName().equals(username))
            {
              sRequest = wrapperRequest(request, subject, principal);
              if (filterChain != null)
              {
                filterChain.doFilter(sRequest, sResponse);
                return;
              }
            }
          }
        }
        UserManager userManager = (UserManager) cm.getComponent("org.apache.jetspeed.security.UserManager");
        AuditActivity audit = (AuditActivity) cm.getComponent("org.apache.jetspeed.audit.AuditActivity");
        ShibbolethConfiguration config = (ShibbolethConfiguration) cm.getComponent(
            "org.apache.jetspeed.security.shibboleth.ShibbolethConfiguration");
        boolean success = false;
        if (config.isAuthenticate())
        {
          try
          {
            authProvider.authenticate(username, username);
            success = true;
          }
          catch (SecurityException e)
          {
            throw new ServletException();
          }
        }
        else
        {
          try
          {
            // load the user principals (roles, groups, credentials)
            User user = userManager.getUser(username);
            if (user != null)
            {
              subject = userManager.getSubject(user);
            }
            success = true;
          }
          catch (SecurityException sex)
          {
            success = false;
          }
        }
        if (success)
        {
          audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "ShibbolethFilter");
          PortalAuthenticationConfiguration authenticationConfiguration = (PortalAuthenticationConfiguration)
              cm.getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");
          if (authenticationConfiguration.isCreateNewSessionOnLogin())
          {
            request.getSession().invalidate();
          }
          else
          {
                        UserContentCacheManager userContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");
                        userContentCacheManager.evictUserContentCache(username, request.getSession().getId());
          }
          subject = null;
          try
          {
View Full Code Here

    {
        // initialize
        super.init(config);

        // get jetspeed component manager configuration for decorations
        ComponentManager cm = Jetspeed.getComponentManager();
        int count =0;
        while(cm == null) {
            try {
                Thread.sleep(200);
            } catch(InterruptedException ie) {
               
            }
            cm = Jetspeed.getComponentManager();
            if( count > 5 ) {
                if (null == cm)
                    throw new ServletException("Could not get Jetspeed Component Manager after "+count+"tries");
            }
            count++;
       
        }
        decorationLocator = (TemplateLocator) cm.getComponent("DecorationLocator");

        // initialize thread safe velocity engine cache
        int cacheSize = (int) getLongInitParameter(config, CACHE_SIZE_PARAMETER, DEFAULT_CACHE_SIZE);
        velocityEngineConfigCache = new LRUMap(cacheSize);
        velocityEngineCache = new LRUMap(cacheSize/2);
View Full Code Here

        session.removeAttribute(LoginConstants.USERNAME);
        session.removeAttribute(LoginConstants.PASSWORD);
        session.removeAttribute(LoginConstants.RETRYCOUNT);
        session.removeAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);

        ComponentManager cm = Jetspeed.getComponentManager();
        UserContentCacheManager userContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");
        userContentCacheManager.evictUserContentCache(username, session.getId());
        AuditActivity audit = (AuditActivity)cm.getComponent("org.apache.jetspeed.audit.AuditActivity");
        if (audit != null)
        {
            audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "Active Authentication");
        }
       
View Full Code Here

       
      HttpServletRequest request = null;
        if (sRequest instanceof HttpServletRequest)
        {
            request = (HttpServletRequest)sRequest;
            ComponentManager cm = Jetspeed.getComponentManager();
            UserManager userManager = (UserManager)cm.getComponent("org.apache.jetspeed.security.UserManager");
            HttpSession session = request.getSession(true);
        String userName = (String) session.getAttribute(CAS_FILTER_USER)
        System.out.println("user: " + userName);
       
        RoleManager roleManager = (RoleManager)cm.getComponent("org.apache.jetspeed.security.RoleManager");
        GroupManager groupManager = (GroupManager)cm.getComponent("org.apache.jetspeed.security.GroupManager");          
        
        User user = null;
        try {
        user = userManager.getUser(userName);
      }
        catch (SecurityException e)
        {
        System.out.println("user: " + userName + " not in j2 db");
        PortalAdministration portalAdministration = (PortalAdministration)cm.getComponent("PortalAdministration");
        try {
          List roles = roleManager.getRoles("user");
          List groups = groupManager.getGroups("");
          portalAdministration.registerUser(userName, portalAdministration.generatePassword());
         
View Full Code Here

  {
  }

  public void doFilter(ServletRequest sRequest, ServletResponse sResponse, FilterChain filterChain) throws IOException, ServletException
  {
        ComponentManager cm = Jetspeed.getComponentManager();
    AuthenticationProvider authProvider = (AuthenticationProvider) cm.getComponent("org.apache.jetspeed.security.AuthenticationProvider");
    if (sRequest instanceof HttpServletRequest)
    {
      HttpServletRequest request = (HttpServletRequest) sRequest;
            HttpSession httpSession = PortalSessionValidationFilter.getValidSession(request);
      if (userNameHeader == null)
      {
        synchronized (sem)
        {
          ShibbolethConfiguration config = (ShibbolethConfiguration) cm.getComponent(
              "org.apache.jetspeed.security.shibboleth.ShibbolethConfiguration");
          userNameHeader = config.getHeaderMapping().get(ShibbolethConfiguration.USERNAME);
        }
      }
      String username = request.getHeader(userNameHeader);
      if (username != null)
      {
        Subject subject = (Subject) request.getSession().getAttribute(PortalReservedParameters.SESSION_KEY_SUBJECT);
        if (subject != null)
        {
          Principal principal = SubjectHelper.getPrincipal(subject, UserSubjectPrincipal.class);
          if (principal != null)
          {
            if (principal.getName().equals(username))
            {
              sRequest = wrapperRequest(request, subject, principal);
              if (filterChain != null)
              {
                filterChain.doFilter(sRequest, sResponse);
                return;
              }
            }
          }
        }
        UserManager userManager = (UserManager) cm.getComponent("org.apache.jetspeed.security.UserManager");
        AuditActivity audit = (AuditActivity) cm.getComponent("org.apache.jetspeed.audit.AuditActivity");
        ShibbolethConfiguration config = (ShibbolethConfiguration) cm.getComponent(
            "org.apache.jetspeed.security.shibboleth.ShibbolethConfiguration");
        boolean success = false;
        if (config.isAuthenticate())
        {
          try
          {
            authProvider.authenticate(username, username);
            success = true;
          }
          catch (SecurityException e)
          {
            throw new ServletException();
          }
        }
        else
        {
          try
          {
            // load the user principals (roles, groups, credentials)
            User user = userManager.getUser(username);
            if (user != null)
            {
              subject = userManager.getSubject(user);
            }
            success = true;
          }
          catch (SecurityException sex)
          {
            success = false;
          }
        }
        if (success)
        {
          audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "ShibbolethFilter");
          PortalAuthenticationConfiguration authenticationConfiguration = (PortalAuthenticationConfiguration)
              cm.getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");
          if (authenticationConfiguration.isCreateNewSessionOnLogin() && httpSession != null && !httpSession.isNew())
          {
            request.getSession().invalidate();
          }
          else
          {
                        UserContentCacheManager userContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");
                        userContentCacheManager.evictUserContentCache(username, request.getSession().getId());
          }
          subject = null;
          try
          {
View Full Code Here

            String username = request.getParameter(LoginConstants.USERNAME);
            String password = request.getParameter(LoginConstants.PASSWORD);           
            HttpSession httpSession = PortalSessionValidationFilter.getValidSession(request);
            if (username != null)
            {
                ComponentManager cm = Jetspeed.getComponentManager();
                UserManager userManager = (UserManager)cm.getComponent("org.apache.jetspeed.security.UserManager");
                AuditActivity audit = (AuditActivity)cm.getComponent("org.apache.jetspeed.audit.AuditActivity");
                AuthenticationProvider authProvider = (AuthenticationProvider)cm.getComponent("org.apache.jetspeed.security.AuthenticationProvider");
               
                // Commenting out for the using latest securty API's
                //boolean success = userManager.authenticate(username, password);
                //if (success)
                AuthenticatedUser authUser = null;
                try{
                  authUser = authProvider.authenticate(username, password)
                }
                catch (SecurityException e)
                {
                    audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "PortalFilter");                   
                    request.getSession().setAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_INVALID_PASSWORD);
        }
                if (authUser != null)
                {
                    audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "PortalFilter");
                    PortalAuthenticationConfiguration authenticationConfiguration = (PortalAuthenticationConfiguration)
                        cm.getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");
                    if (authenticationConfiguration.isCreateNewSessionOnLogin() && httpSession != null && !httpSession.isNew())
                    {
                        request.getSession().invalidate();
                    }
                    else
                    {
                        UserContentCacheManager userContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");
                        userContentCacheManager.evictUserContentCache(username, request.getSession().getId());
                    }
                    if (authUser.getUser() == null)
                    {
                        try
View Full Code Here

        {
            throw new ServletException("Unexpected OpenID exception: "+oide, oide);
        }
       
        // configure portal components
        ComponentManager cm = Jetspeed.getComponentManager();
        portalUserManager = (UserManager)cm.getComponent("org.apache.jetspeed.security.UserManager");
        portalAdministration = (PortalAdministration)cm.getComponent("PortalAdministration");
        portalAudit = (AuditActivity)cm.getComponent("org.apache.jetspeed.audit.AuditActivity");       
        portalAuthenticationConfiguration = (PortalAuthenticationConfiguration)cm.getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");
        portalUserContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");

        // registration configuration parameters
        if (Boolean.parseBoolean(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_CONFIG_INIT_PARAM_NAME)))
        {
            initRegistrationConfiguration = new OpenIDRegistrationConfiguration();
View Full Code Here

        return null;
    }
   
    public Pipeline getPipelineById(String pipelineId)
    {
        ComponentManager componentManager = Jetspeed.getComponentManager();
       
        if (componentManager == null)
        {
            return null;
        }
       
        return (Pipeline) componentManager.getComponent(pipelineId);
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.components.ComponentManager

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.