Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
  //  ------------------------------------------------------------------------
  //  All rights reserved. This program and the accompanying materials
  //  are made available under the terms of the Eclipse Public License v1.0
  //  and Apache License v2.0 which accompanies this distribution.
  //
  //      The Eclipse Public License is available at
 //      http://www.eclipse.org/legal/epl-v10.html
 //
 //      The Apache License v2.0 is available at
 //      http://www.opensource.org/licenses/apache2.0.php
 //
 //  You may elect to redistribute this code under either of these licenses.
 //  ========================================================================
 //
 
 
 package org.eclipse.jetty.security.authentication;
 
 
 
 
 public class DeferredAuthentication implements Authentication.Deferred
 {
     private static final Logger LOG = Log.getLogger(DeferredAuthentication.class);
     protected final LoginAuthenticator _authenticator;
     private Object _previousAssociation;
 
     /* ------------------------------------------------------------ */
     public DeferredAuthentication(LoginAuthenticator authenticator)
     {
         if (authenticator == null)
             throw new NullPointerException("No Authenticator");
         this. = authenticator;
     }
 
     /* ------------------------------------------------------------ */
    
 
     public Authentication authenticate(ServletRequest request)
     {
         try
         {
             Authentication authentication = .validateRequest(request,,true);
             
             if (authentication!=null && (authentication instanceof Authentication.User) && !(authentication instanceof Authentication.ResponseSent))
             {
                 LoginService login_service.getLoginService();
                 IdentityService identity_service=login_service.getIdentityService();
                 
                 if (identity_service!=null)
                     =identity_service.associate(((Authentication.User)authentication).getUserIdentity());
                 
                 return authentication;
             }
         }
         catch (ServerAuthException e)
         {
             .debug(e);
         }
 
         return this;
     }
     
     /* ------------------------------------------------------------ */
    
 
     public Authentication authenticate(ServletRequest requestServletResponse response)
     {
         try
         {
             LoginService login_service.getLoginService();
             IdentityService identity_service=login_service.getIdentityService();
             
            Authentication authentication = .validateRequest(request,response,true);
            if (authentication instanceof Authentication.User && identity_service!=null)
                =identity_service.associate(((Authentication.User)authentication).getUserIdentity());
            return authentication;
        }
        catch (ServerAuthException e)
        {
            .debug(e);
        }
        return this;
    }
    /* ------------------------------------------------------------ */
    
    public Authentication login(String usernameObject passwordServletRequest request)
    {
        UserIdentity identity = .login(usernamepasswordrequest);
        if (identity != null)
        {
            IdentityService identity_service = .getLoginService().getIdentityService();
            UserAuthentication authentication = new UserAuthentication("API",identity);
            if (identity_service != null)
                =identity_service.associate(identity);
            return authentication;
        }
        return null;
    }
    /* ------------------------------------------------------------ */
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    

Parameters:
response
Returns:
true if this response is from a deferred call to authenticate(javax.servlet.ServletRequest)
    public static boolean isDeferred(HttpServletResponse response)
    {
        return response==;
    }
    
    /* ------------------------------------------------------------ */
    /* ------------------------------------------------------------ */
    /* ------------------------------------------------------------ */
    {
        public void addCookie(Cookie cookie)
        {
        }
        public void addDateHeader(String namelong date)
        {
        }
        public void addHeader(String nameString value)
        {
        }
        public void addIntHeader(String nameint value)
        {
        }
        public boolean containsHeader(String name)
        {
            return false;
        }
        public String encodeRedirectURL(String url)
        {
            return null;
        }
        public String encodeRedirectUrl(String url)
        {
            return null;
        }
        public String encodeURL(String url)
        {
            return null;
        }
        public String encodeUrl(String url)
        {
            return null;
        }
        public void sendError(int scthrows IOException
        {
        }
        public void sendError(int scString msgthrows IOException
        {
        }
        public void sendRedirect(String locationthrows IOException
        {
        }
        public void setDateHeader(String namelong date)
        {
        }
        public void setHeader(String nameString value)
        {
        }
        public void setIntHeader(String nameint value)
        {
        }
        public void setStatus(int sc)
        {
        }
        public void setStatus(int scString sm)
        {
        }
        public void flushBuffer() throws IOException
        {
        }
        public int getBufferSize()
        {
            return 1024;
        }
        public String getCharacterEncoding()
        {
            return null;
        }
        public String getContentType()
        {
            return null;
        }
        public Locale getLocale()
        {
            return null;
        }
        public ServletOutputStream getOutputStream() throws IOException
        {
            return ;
        }
        public PrintWriter getWriter() throws IOException
        {
            return IO.getNullPrintWriter();
        }
        public boolean isCommitted()
        {
            return true;
        }
        public void reset()
        {
        }
        public void resetBuffer()
        {
        }
        public void setBufferSize(int size)
        {
        }
        public void setCharacterEncoding(String charset)
        {
        }
        public void setContentLength(int len)
        {
        }
        public void setContentType(String type)
        {
        }
        public void setLocale(Locale loc)
        {
        }
	{
	    return Collections.emptyList();
	}
	public String getHeader(String arg0)
	{
	    return null;
	}
	{
            return Collections.emptyList();
	}
	public int getStatus()
	{
	    return 0;
	}
    };
    /* ------------------------------------------------------------ */
    /* ------------------------------------------------------------ */
    /* ------------------------------------------------------------ */
    private static ServletOutputStream __nullOut = new ServletOutputStream()
    {
        public void write(int bthrows IOException
        {
        }
        public void print(String sthrows IOException
        {
        }
        public void println(String sthrows IOException
        {
        }
    };
    
New to GrepCode? Check out our FAQ X