Package org.jasig.portal.security

Examples of org.jasig.portal.security.IPerson


    public void testIsCacheValidAlwaysCache() throws Exception {
        final ChannelStaticData channelStaticData = new ChannelStaticData();
        channelStaticData.setChannelPublishId("pub1");
        channelStaticData.setChannelSubscribeId("sub1");
       
        final IPerson person = createMock(IPerson.class);
        channelStaticData.setPerson(person);


        final MockHttpServletRequest request = new MockHttpServletRequest();
        final MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here


    public void testIsCacheValidCacheWithNullValidity() throws Exception {
        final ChannelStaticData channelStaticData = new ChannelStaticData();
        channelStaticData.setChannelPublishId("pub1");
        channelStaticData.setChannelSubscribeId("sub1");
       
        final IPerson person = createMock(IPerson.class);
        channelStaticData.setPerson(person);


        final MockHttpServletRequest request = new MockHttpServletRequest();
        final MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

    public void testIsCacheValidCacheStillGood() throws Exception {
        final ChannelStaticData channelStaticData = new ChannelStaticData();
        channelStaticData.setChannelPublishId("pub1");
        channelStaticData.setChannelSubscribeId("sub1");
       
        final IPerson person = createMock(IPerson.class);
        channelStaticData.setPerson(person);


        final MockHttpServletRequest request = new MockHttpServletRequest();
        final MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

    public void testIsCacheValidCacheExpired() throws Exception {
        final ChannelStaticData channelStaticData = new ChannelStaticData();
        channelStaticData.setChannelPublishId("pub1");
        channelStaticData.setChannelSubscribeId("sub1");
       
        final IPerson person = createMock(IPerson.class);
        channelStaticData.setPerson(person);


        final MockHttpServletRequest request = new MockHttpServletRequest();
        final MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

    public void testIsCacheValidWindowOverride() throws Exception {
        final ChannelStaticData channelStaticData = new ChannelStaticData();
        channelStaticData.setChannelPublishId("pub1");
        channelStaticData.setChannelSubscribeId("sub1");
       
        final IPerson person = createMock(IPerson.class);
        channelStaticData.setPerson(person);


        final MockHttpServletRequest request = new MockHttpServletRequest();
        final MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

       
        verify(portletDefinitionRegistry, portletDefinition, portletRequestParameterManager, portletEntity, portletEntityRegistry, portletWindow, portletWindowRegistry, person);
    }
   
    public void testRender() throws Exception {
        final IPerson person = createMock(IPerson.class);
       
        final ChannelStaticData channelStaticData = new ChannelStaticData();
        channelStaticData.setChannelPublishId("pub1");
        channelStaticData.setChannelSubscribeId("sub1");
        channelStaticData.setPerson(person);
View Full Code Here

            // Replace the passed in IPerson with the additional descriptor if the
            // additional descriptor is an IPerson object created by the security context
            // NOTE: This is not the preferred method, creation of IPerson objects should be
            //       handled by the PersonManager.
            if (addInfo instanceof IPerson) {
               IPerson newPerson = (IPerson)addInfo;
               person.setFullName(newPerson.getFullName());
               for (Enumeration e = newPerson.getAttributeNames(); e.hasMoreElements();) {
                  String attributeName = (String)e.nextElement();
                  person.setAttribute(attributeName, newPerson.getAttribute(attributeName));
               }
               resetEntityIdentifier(person, newPerson);
            }
            // If the additional descriptor is a map then we can
            // simply copy all of these additional attributes into the IPerson
View Full Code Here

        }
       
        final IPersonManager personManager = PersonManagerLocator.getPersonManager();

        // Update the session timeout for an unauthenticated user.
        final IPerson person = personManager.getPerson(writableRequest);
        if (person != null && !person.getSecurityContext().isAuthenticated()) {

            if (unauthenticatedUserSessionTimeout != 0) {
                session.setMaxInactiveInterval(unauthenticatedUserSessionTimeout);
               
                if (log.isDebugEnabled()) {
View Full Code Here

          //No original person in session so check for swap request
          if (originalUid == null) {
              targetUid = (String)s.getAttribute(SWAP_TARGET_UID);
              if (targetUid != null) {
                  final IPerson person = personManager.getPerson(request);
                  originalUid = person.getName();
                  swap = true;
              }
          }
          else {
              final IPerson person = personManager.getPerson(request);
              targetUid = person.getName();
          }

            s.invalidate();
      } catch (IllegalStateException ise) {
        // ISE indicates session was already invalidated.
        // This is fine.  This servlet trying to guarantee that the session has been invalidated;
        // it doesn't have to insist that it is the one that invalidated it.
        if (log.isTraceEnabled()) {
          log.trace("LoginServlet attempted to invalidate an already invalid session.", ise);
        }
      }
    }

    //  Create the user's session
    HttpSession s = request.getSession(true);
   
    IPerson person = null;
    try {
        final HashMap principals;
        final HashMap credentials;
       
        // Get the person object associated with the request
        person = personManager.getPerson(request);
       
        //If doing an identity swap
        if (targetUid != null && originalUid != null) {
            if (swap) {
                swapperLog.warn("Swapping identity for '" + originalUid + "' to '" + targetUid + "'");

                //Track the originating user
                s.setAttribute(SWAP_ORIGINAL_UID, originalUid);
               
                //Setup the swapped person
                person.setUserName(targetUid);
            }
            else {
                swapperLog.warn("Reverting swapped identity from '" + targetUid + "' to '" + originalUid + "'");
               
                person.setUserName(originalUid);
            }
           
            //Setup the custom security context
            final IdentitySwapperPrincipal identitySwapperPrincipal = new IdentitySwapperPrincipal(person);
            final IdentitySwapperSecurityContext identitySwapperSecurityContext = new IdentitySwapperSecurityContext(identitySwapperPrincipal);
            person.setSecurityContext(identitySwapperSecurityContext);
           
            principals = new HashMap();
            credentials = new HashMap();
        }
        //Norm authN path
        else {
          // WE grab all of the principals and credentials from the request and load
          // them into their respective HashMaps.
          principals = getPropertyFromRequest (principalTokens, request);
          credentials = getPropertyFromRequest (credentialTokens, request);
        }

      // Attempt to authenticate using the incoming request
      m_authenticationService.authenticate(principals, credentials, person);
    } catch (Exception e) {
      // Log the exception
      log.error("Exception authenticating the request", e);
      // Reset everything
      request.getSession(false).invalidate();
      // Add the authentication failure
      request.getSession(true).setAttribute("up_authenticationError", "true");
      person = null;
    }
   
   
   
    // create the redirect URL, adding fname and args parameters if necessary
    String redirectTarget = null;

    final String refUrl = request.getParameter("refUrl");
    if (refUrl != null) {
        if (refUrl.startsWith("/")) {
            redirectTarget = refUrl;
        }
        else {
            log.warn("Refernce URL passed in does not start with a / and will be ignored: " + refUrl);
        }
    }
   
    if (redirectTarget == null) {
        /* Grab the target functional name, if any, off the login request.
         * Also any arguments for the target
         * We will pass them  along after authentication.
         */
        String targetFname = request.getParameter("uP_fname");
       
      if (targetFname == null){
        redirectTarget = request.getContextPath() + "/" + redirectString;
      } else {
        StringBuilder sb = new StringBuilder();
        sb.append(request.getContextPath());
        sb.append("/tag.idempotent.");
        sb.append(redirectString);
        sb.append("?uP_fname=");
        sb.append(URLEncoder.encode(targetFname, "UTF-8"));
        Enumeration<String> e = request.getParameterNames();
        while(e.hasMoreElements()){
          String paramName = e.nextElement();
          if(!paramName.equals("uP_fname")){
            sb.append('&');
            sb.append(paramName);
            sb.append('=');
            sb.append(URLEncoder.encode(request.getParameter(paramName),"UTF-8"));
          }
        }   
        redirectTarget = sb.toString();
      }
    }

  if (person == null || !person.getSecurityContext().isAuthenticated()) {
     if ( request.getMethod().equals("POST") )
         request.getSession(false).setAttribute("up_authenticationAttempted", "true");
     // Preserve the attempted username so it can be redisplayed to the user by CLogin
     String attemptedUserName = request.getParameter("userName");
     if (attemptedUserName != null)
View Full Code Here

        catch (IllegalStateException ise) {
            this.logger.warn("No current portal request available, cannot determine current user name.");
            return null;
        }
       
        final IPerson person = this.personManager.getPerson(portalRequest);
        if (person == null) {
            this.logger.warn("IPersonManager returned no IPerson for request, cannot determine current user name. " + portalRequest);
            return null;
        }
       
        return person.getUserName();
    }
View Full Code Here

TOP

Related Classes of org.jasig.portal.security.IPerson

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.