Package com.ecyrd.jspwiki

Examples of com.ecyrd.jspwiki.WikiSession


     */
    @Override
    public final int doWikiStartTag()
        throws IOException
    {
        WikiSession session = m_wikiContext.getWikiSession();
        String status = session.getStatus();
        AuthenticationManager mgr = m_wikiContext.getEngine().getAuthenticationManager();
        boolean containerAuth = mgr.isContainerAuthenticated();
        boolean cookieAssertions = mgr.allowsCookieAssertions();

        if( m_status != null )
        {
            if ( ANONYMOUS.equals( m_status ))
            {
                if (status.equals(WikiSession.ANONYMOUS))
                {
                    return EVAL_BODY_INCLUDE;
                }
            }
            else if( AUTHENTICATED.equals( m_status ))
            {
                if (status.equals(WikiSession.AUTHENTICATED))
                {
                    return EVAL_BODY_INCLUDE;
                }
            }
            else if( ASSERTED.equals( m_status ))
            {
                if (status.equals(WikiSession.ASSERTED))
                {
                    return EVAL_BODY_INCLUDE;
                }
            }
            else if( ASSERTIONS_ALLOWED.equals( m_status ))
            {
                if ( cookieAssertions )
                {
                    return EVAL_BODY_INCLUDE;
                }
                return SKIP_BODY;
            }
            else if( ASSERTIONS_NOT_ALLOWED.equals( m_status ))
            {
                if ( !cookieAssertions )
                {
                    return EVAL_BODY_INCLUDE;
                }
                return SKIP_BODY;
            }
            else if( CONTAINER_AUTH.equals( m_status ))
            {
                if ( containerAuth )
                {
                    return EVAL_BODY_INCLUDE;
                }
                return SKIP_BODY;
            }
            else if( CUSTOM_AUTH.equals( m_status ))
            {
                if ( !containerAuth )
                {
                    return EVAL_BODY_INCLUDE;
                }
                return SKIP_BODY;
            }
            else if( KNOWN.equals( m_status ))
            {
                if ( !session.isAnonymous() )
                {
                    return EVAL_BODY_INCLUDE;
                }
                return SKIP_BODY;
            }
View Full Code Here


            {
                //
                //  Default back to the declared user name
                //
                WikiEngine engine = this.m_wikiContext.getEngine();
                WikiSession wikiSession = WikiSession.getWikiSession( engine, (HttpServletRequest)pageContext.getRequest() );
                Principal user = wikiSession.getUserPrincipal();

                if( user != null )
                {
                    result = user.getName();
                }
View Full Code Here

    private static final Pattern VALID_USER_NAME_PATTERN = Pattern.compile(notStartWithBlankOrColon + noColons);

    public final int doWikiStartTag() throws IOException
    {
        WikiEngine engine = this.m_wikiContext.getEngine();
        WikiSession wikiSession = WikiSession.getWikiSession(engine, (HttpServletRequest) pageContext.getRequest());
        Principal user = wikiSession.getUserPrincipal();

        if (user != null)
        {
            if (VALID_USER_NAME_PATTERN.matcher(user.getName()).matches())
            {
View Full Code Here

        m_action = action.toLowerCase();
    }

    public final int doWikiStartTag() throws IOException
    {
        WikiSession session = m_wikiContext.getWikiSession();
        if ( CLEAR.equals( m_action ) )
        {
            if ( m_topic == null )
            {
                session.clearMessages();
            }
            else
            {
                session.clearMessages( m_topic );
            }
        }
        else
        {
            String[] messages = ( m_topic == null ) ? session.getMessages() : session.getMessages( m_topic );
            if ( messages.length > 0 )
            {
                StringBuffer sb = new StringBuffer();
                if ( messages.length == 1 )
                {
View Full Code Here


    public String doPost(WikiContext context)
    {
        HttpServletRequest request = context.getHttpRequest();
        WikiSession session = context.getWikiSession();
        UserManager mgr = context.getEngine().getUserManager();

        String loginid   = request.getParameter("loginid");
        String loginname = request.getParameter("loginname");
        String fullname  = request.getParameter("fullname");
        String password  = request.getParameter("password");
        String password2 = request.getParameter("password2");
        String email     = request.getParameter("email");


        if( request.getParameter("action").equalsIgnoreCase("remove") )
        {
            try
            {
                mgr.getUserDatabase().deleteByLoginName(loginid);
                session.addMessage("User profile "+loginid+" ("+fullname+") has been deleted");
            }
            catch (NoSuchPrincipalException e)
            {
                session.addMessage("User profile has already been removed");
            }
            catch (WikiSecurityException e)
            {
                session.addMessage("Security problem: "+e);
            }
            return "";
        }


        if( password != null && password.length() > 0 && !password.equals(password2) )
        {
            session.addMessage("Passwords do not match!");
            return "";
        }

        UserProfile p;

        if( loginid.equals("--New--") )
        {
            // Create new user

            p = mgr.getUserDatabase().newProfile();
            p.setCreated( new Date() );
        }
        else
        {
            try
            {
                p = mgr.getUserDatabase().findByLoginName( loginid );
            }
            catch (NoSuchPrincipalException e)
            {
                session.addMessage("I could not find user profile "+loginid);
                return "";
            }
        }

        p.setEmail(email);
        p.setFullname(fullname);
        if( password != null && password.length() > 0 ) p.setPassword(password);
        p.setLoginName(loginname);

        try
        {
            mgr.getUserDatabase().save( p );
        }
        catch( WikiSecurityException e )
        {
            session.addMessage("Unable to save "+e.getMessage());
        }

        session.addMessage("User profile has been updated");

        return "";
    }
View Full Code Here

        }

        WikiSecurityEvent se = (WikiSecurityEvent)event;
        if ( se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED )
        {
            WikiSession session = (WikiSession)se.getSource();
            UserProfile[] profiles = (UserProfile[])se.getTarget();
            Principal[] oldPrincipals = new Principal[] {
                new WikiPrincipal( profiles[0].getLoginName() ),
                new WikiPrincipal( profiles[0].getFullname() ),
                new WikiPrincipal( profiles[0].getWikiName() ) };
View Full Code Here

        {
            // Prepare the WikiSession
            try
            {
                m_engine.getAuthenticationManager().login( httpRequest );
                WikiSession wikiSession = SessionMonitor.getInstance( m_engine ).find( httpRequest.getSession() );
                httpRequest = new WikiRequestWrapper( m_engine, httpRequest );
                if ( log.isDebugEnabled() )
                {
                    log.debug( "Executed security filters for user=" + wikiSession.getLoginPrincipal().getName() + ", path=" + httpRequest.getRequestURI() );
                }
            }
            catch ( WikiSecurityException e )
            {
                throw new ServletException( e );
View Full Code Here

TOP

Related Classes of com.ecyrd.jspwiki.WikiSession

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.