Package org.uberfire.security.server

Examples of org.uberfire.security.server.HttpSecurityContext


import static org.uberfire.security.server.SecurityConstants.*;

public class FormAuthenticationScheme implements AuthenticationScheme {

    public boolean isAuthenticationRequest(final SecurityContext context) {
        final HttpSecurityContext httpSecurityContext = checkInstanceOf("context", context, HttpSecurityContext.class);

        return httpSecurityContext.getRequest().getRequestURI().contains(HTTP_FORM_SECURITY_CHECK_URI);
    }
View Full Code Here


        return httpSecurityContext.getRequest().getRequestURI().contains(HTTP_FORM_SECURITY_CHECK_URI);
    }

    @Override
    public void challengeClient(SecurityContext context) {
        final HttpSecurityContext httpSecurityContext = checkInstanceOf("context", context, HttpSecurityContext.class);

        final RequestDispatcher rd = httpSecurityContext.getRequest().getRequestDispatcher(SecurityConstants.FORM_AUTH_PAGE);

        if (rd == null) {
            throw new RuntimeException("Unable to resolve RequestDispatcher.");
        }

        try {
          httpSecurityContext.getResponse().setStatus(401);
            rd.forward(httpSecurityContext.getRequest(), httpSecurityContext.getResponse());
        } catch (Exception e) {
            throw new AuthenticationException(e);
        }
    }
View Full Code Here

            throw new AuthenticationException(e);
        }
    }

    public Credential buildCredential(final SecurityContext context) {
        final HttpSecurityContext httpSecurityContext = checkInstanceOf("context", context, HttpSecurityContext.class);

        final String userName = httpSecurityContext.getRequest().getParameter(HTTP_FORM_USERNAME_PARAM);
        final String password = httpSecurityContext.getRequest().getParameter(HTTP_FORM_PASSWORD_PARAM);

        if (userName == null || password == null) {
            return null;
        }
View Full Code Here

    }

    @Override
    public void store( final SecurityContext context,
                       final Subject subject ) {
        final HttpSecurityContext httpContext = checkInstanceOf( "context", context, HttpSecurityContext.class );

        final String content = CRYPT_PROVIDER.encrypt( subject.getName(), null );
        final Cookie securityCookie = new Cookie( cookieName, content );
        securityCookie.setPath( "/" );
        securityCookie.setMaxAge( DEFAULT_EXPIRE_48_HOURS );

        httpContext.getResponse().addCookie( securityCookie );
    }
View Full Code Here

        httpContext.getResponse().addCookie( securityCookie );
    }

    @Override
    public void cleanup( final SecurityContext context ) {
        final HttpSecurityContext httpContext = checkInstanceOf( "context", context, HttpSecurityContext.class );

        final Cookie securityCookie = new Cookie( cookieName, EMPTY );
        securityCookie.setPath( "/" );
        securityCookie.setMaxAge( 0 );

        httpContext.getResponse().addCookie( securityCookie );

    }
View Full Code Here

        httpContext.getResponse().addCookie( securityCookie );

    }

    public Principal load( final SecurityContext context ) {
        final HttpSecurityContext httpContext = checkInstanceOf( "context", context, HttpSecurityContext.class );
        final String originalCookieValue = getCookieValue( cookieName, null, httpContext.getRequest().getCookies() );

        if ( originalCookieValue == null ) {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.uberfire.security.server.HttpSecurityContext

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.