Package org.mortbay.jetty.security

Examples of org.mortbay.jetty.security.Authenticator


                substitutedPathInContext = substitutedPathInContext.replaceAll("%3A", "%3A%3A");
            if (substitutedPathInContext.indexOf(":") > -1)
                substitutedPathInContext = substitutedPathInContext.replaceAll(":", "%3A");


            Authenticator authenticator = getAuthenticator();
            boolean isAuthenticated = false;

            if (authenticator instanceof FormAuthenticator
                    && pathInContext.endsWith(FormAuthenticator.__J_SECURITY_CHECK)) {
                /**
                 * This is a post request to __J_SECURITY_CHECK. Stop now after authentication.
                 * Whether or not authentication succeeded, we return.
                 */
                authenticator.authenticate(realm, pathInContext, request, response);
                return false;
            }
            // attempt to access an unprotected resource that is not the
            // j_security_check.
            // if we are logged in, return the logged in principal.
            if (request != null) {
                // null response appears to prevent redirect to login page
                Principal user = authenticator.authenticate(realm, pathInContext,
                        request, null);
                if (user == null || user == SecurityHandler.__NOBODY) {
                    //TODO use run-as as nextCaller if present
                    ContextManager.setCallers(defaultPrincipal.getSubject(), defaultPrincipal.getSubject());
                    request.setUserPrincipal(new NotChecked());
                } else if (user != null) {
                    isAuthenticated = true;
                }
            }


            AccessControlContext acc = ContextManager.getCurrentContext();

            /**
             * JACC v1.0 section 4.1.1
             */
            WebUserDataPermission wudp = new WebUserDataPermission(substitutedPathInContext, new String[]{request.getMethod()}, transportType);
            acc.checkPermission(wudp);

            WebResourcePermission webResourcePermission = new WebResourcePermission(request);
            /**
             * JACC v1.0 section 4.1.2
             */
            if (isAuthenticated) {
                //current user is logged in, this is the actual check
                acc.checkPermission(webResourcePermission);
            } else {
                //user is not logged in: if access denied, try to log them in.
                try {
                    acc.checkPermission(webResourcePermission);
                } catch (AccessControlException e) {
                    //not logged in: try to log them in.
                    Principal user = authenticator.authenticate(realm, pathInContext, request, response);
                    if (user == SecurityHandler.__NOBODY) {
                        return true;
                    }
                    if (user == null) {
                        throw e;
View Full Code Here


        this.defaultPrincipal = generateDefaultPrincipal(defaultPrincipal,classLoader);
        this.checked = checkedPermissions;
        this.excludedPermissions = excludedPermissions;

        Authenticator authenticator = getAuthenticator();
        if (authenticator instanceof FormAuthenticator) {
            String formLoginPath = ((FormAuthenticator) authenticator).getLoginPage();
            if (formLoginPath.indexOf('?') > 0) {
                formLoginPath = formLoginPath.substring(0, formLoginPath.indexOf('?'));
            }
View Full Code Here

            Response response, WebResourcePermission resourcePermission,
            WebUserDataPermission dataPermission) throws IOException {
        boolean unauthenticated = !(checked.implies(resourcePermission) || checked.implies(dataPermission));
        boolean forbidden = excludedPermissions.implies(resourcePermission) || excludedPermissions.implies(dataPermission);

        Authenticator authenticator = getAuthenticator();
        if (!unauthenticated && !forbidden) {
            return authenticator.authenticate(realm, pathInContext, request,
                    response);
        } else if (authenticator instanceof FormAuthenticator
                && pathInContext.endsWith(FormAuthenticator.__J_SECURITY_CHECK)) {
            /**
             * This could be a post request to __J_SECURITY_CHECK.
             */
            return authenticator.authenticate(realm, pathInContext, request,
                    response);
        }

        // attempt to access an unprotected resource that is not the
        // j_security_check.
        // if we are logged in, return the logged in principal.
        if (request != null) {
            // null response appears to prevent redirect to login page
            Principal user = authenticator.authenticate(realm, pathInContext,
                    request, null);
            if (user != null) {
                return user;
            }
        }
View Full Code Here

        if (_userPrincipal != null && _userPrincipal instanceof SecurityHandler.NotChecked)
        {
            SecurityHandler.NotChecked not_checked=(SecurityHandler.NotChecked)_userPrincipal;
            _userPrincipal = SecurityHandler.__NO_USER;
           
            Authenticator auth=not_checked.getSecurityHandler().getAuthenticator();
            UserRealm realm=not_checked.getSecurityHandler().getUserRealm();
            String pathInContext=getPathInfo()==null?getServletPath():(getServletPath()+getPathInfo());
           
            if (realm != null && auth != null)
            {
                try
                {
                    auth.authenticate(realm, pathInContext, this, null);
                }
                catch (Exception e)
                {
                    Log.ignore(e);
                }
View Full Code Here

        if (_userPrincipal != null && _userPrincipal instanceof SecurityHandler.NotChecked)
        {
            SecurityHandler.NotChecked not_checked=(SecurityHandler.NotChecked)_userPrincipal;
            _userPrincipal = SecurityHandler.__NO_USER;
           
            Authenticator auth=not_checked.getSecurityHandler().getAuthenticator();
            UserRealm realm=not_checked.getSecurityHandler().getUserRealm();
            String pathInContext=getPathInfo()==null?getServletPath():(getServletPath()+getPathInfo());
           
            if (realm != null && auth != null)
            {
                try
                {
                    auth.authenticate(realm, pathInContext, this, null);
                }
                catch (Exception e)
                {
                    Log.ignore(e);
                }
View Full Code Here

    {
        XmlParser.Node method=node.get("auth-method");
        FormAuthenticator _formAuthenticator=null;
        if(method!=null)
        {
            Authenticator authenticator=null;
            String m=method.toString(false,true);
            if(Constraint.__FORM_AUTH.equals(m))
                authenticator=_formAuthenticator=new FormAuthenticator();
            else if(Constraint.__BASIC_AUTH.equals(m))
                authenticator=new BasicAuthenticator();
View Full Code Here

    {
        XmlParser.Node method=node.get("auth-method");
        FormAuthenticator _formAuthenticator=null;
        if(method!=null)
        {
            Authenticator authenticator=null;
            String m=method.toString(false,true);
            if(Constraint.__FORM_AUTH.equals(m))
                authenticator=_formAuthenticator=new FormAuthenticator();
            else if(Constraint.__BASIC_AUTH.equals(m))
                authenticator=new BasicAuthenticator();
View Full Code Here

        if (_userPrincipal != null && _userPrincipal instanceof SecurityHandler.NotChecked)
        {
            SecurityHandler.NotChecked not_checked=(SecurityHandler.NotChecked)_userPrincipal;
            _userPrincipal = SecurityHandler.__NO_USER;
           
            Authenticator auth=not_checked.getSecurityHandler().getAuthenticator();
            UserRealm realm=not_checked.getSecurityHandler().getUserRealm();
            String pathInContext=getPathInfo()==null?getServletPath():(getServletPath()+getPathInfo());
           
            if (realm != null && auth != null)
            {
                try
                {
                    auth.authenticate(realm, pathInContext, this, null);
                }
                catch (Exception e)
                {
                    Log.ignore(e);
                }
View Full Code Here

        if (_userPrincipal != null && _userPrincipal instanceof SecurityHandler.NotChecked)
        {
            SecurityHandler.NotChecked not_checked=(SecurityHandler.NotChecked)_userPrincipal;
            _userPrincipal = SecurityHandler.__NO_USER;
           
            Authenticator auth=not_checked.getSecurityHandler().getAuthenticator();
            UserRealm realm=not_checked.getSecurityHandler().getUserRealm();
            String pathInContext=getPathInfo()==null?getServletPath():(getServletPath()+getPathInfo());
           
            if (realm != null && auth != null)
            {
                try
                {
                    auth.authenticate(realm, pathInContext, this, null);
                }
                catch (Exception e)
                {
                    Log.ignore(e);
                }
View Full Code Here

        this.defaultPrincipal = generateDefaultPrincipal(defaultPrincipal,classLoader);
        this.checked = checkedPermissions;
        this.excludedPermissions = excludedPermissions;

        Authenticator authenticator = getAuthenticator();
        if (authenticator instanceof FormAuthenticator) {
            String formLoginPath = ((FormAuthenticator) authenticator).getLoginPage();
            if (formLoginPath.indexOf('?') > 0) {
                formLoginPath = formLoginPath.substring(0, formLoginPath.indexOf('?'));
            }
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.security.Authenticator

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.