Java Code Examples for org.apache.catalina.connector.Request#getRequest()

The following examples show how to use org.apache.catalina.connector.Request#getRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthenticatorBase.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private JaspicState getJaspicState(AuthConfigProvider jaspicProvider, Request request,
        Response response, boolean authMandatory) throws IOException {
    JaspicState jaspicState = new JaspicState();

    jaspicState.messageInfo =
            new MessageInfoImpl(request.getRequest(), response.getResponse(), authMandatory);

    try {
        CallbackHandler callbackHandler = createCallbackHandler();
        ServerAuthConfig serverAuthConfig = jaspicProvider.getServerAuthConfig(
                "HttpServlet", jaspicAppContextID, callbackHandler);
        String authContextID = serverAuthConfig.getAuthContextID(jaspicState.messageInfo);
        jaspicState.serverAuthContext = serverAuthConfig.getAuthContext(authContextID, null, null);
    } catch (AuthException e) {
        log.warn(sm.getString("authenticator.jaspicServerAuthContextFail"), e);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return null;
    }

    return jaspicState;
}
 
Example 2
Source File: TomcatValve.java    From flex-blazeds with Apache License 2.0 6 votes vote down vote up
static Session getSession(Request request, boolean create) 
{

    HttpServletRequest hreq = (HttpServletRequest)request.getRequest();
    HttpSession hses = hreq.getSession(create);

    if (hses == null)
        return null;

    Manager manager = request.getContext().getManager();
    if (manager == null)
        return null;

    try 
    {
        return manager.findSession(hses.getId());
    }
    catch (IOException e) 
    {
        Log.getLogger(LogCategories.SECURITY).error("Error in TomcatValve getting session id " + hses.getId() + " : " + ExceptionUtil.toString(e));
        return null;
    }
}
 
Example 3
Source File: Tomcat7Valve.java    From flex-blazeds with Apache License 2.0 6 votes vote down vote up
static Session getSession(Request request, boolean create) 
{

    HttpServletRequest hreq = (HttpServletRequest)request.getRequest();
    HttpSession hses = hreq.getSession(create);

    if (hses == null)
        return null;

    Manager manager = request.getContext().getManager();
    if (manager == null)
        return null;

    try 
    {
        return manager.findSession(hses.getId());
    }
    catch (IOException e) 
    {
        Log.getLogger(LogCategories.SECURITY).error("Error in TomcatValve getting session id " + hses.getId() + " : " + ExceptionUtil.toString(e));
        return null;
    }
}
 
Example 4
Source File: TomcatValve.java    From flex-blazeds with Apache License 2.0 5 votes vote down vote up
private void invokeServletRequest(Request request)
{
    ServletRequest servRequest = request.getRequest();
    if (!(servRequest instanceof HttpServletRequest))
        return;

    // We only set the TomcatLoginImpl for gateway paths
    HttpServletRequest hrequest = (HttpServletRequest)servRequest;
    boolean match = checkIfPathMatches(hrequest.getServletPath(), hrequest.getRequestURI());
    if (match)
        handleMatch(request, hrequest.getUserPrincipal());
}
 
Example 5
Source File: Tomcat7Valve.java    From flex-blazeds with Apache License 2.0 5 votes vote down vote up
private void invokeServletRequest(Request request)
{
    ServletRequest servRequest = request.getRequest();
    if (!(servRequest instanceof HttpServletRequest))
        return;

    // We only set the TomcatLoginImpl for gateway paths
    HttpServletRequest hrequest = (HttpServletRequest)servRequest;
    boolean match = checkIfPathMatches(hrequest.getServletPath(), hrequest.getRequestURI());
    if (match)
        handleMatch(request, hrequest.getUserPrincipal());
}
 
Example 6
Source File: CdiEventRealm.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public SecurityConstraint[] findSecurityConstraints(final Request request, final Context context) {
    final SecurityConstraint[] sc = super.findSecurityConstraints(request, context);

    if (beanManager() == null) {
        return sc;
    }

    final FindSecurityConstraintsEvent event = new FindSecurityConstraintsEvent(request.getRequest(), context.getPath());
    beanManager().fireEvent(event);

    if (!event.getRoles().isEmpty()) {
        final SecurityConstraint s = new SecurityConstraint();
        final SecurityCollection collection = new SecurityCollection();

        collection.addPattern("/*"); // only for the current request
        collection.addMethod(request.getMethod());
        s.addCollection(collection);

        if (event.getUserConstraint() != null) {
            s.setUserConstraint(event.getUserConstraint());
        }

        for(final String r: event.getRoles()) {
            s.addAuthRole(r);
        }

        return new SecurityConstraint[] { s };
    }

    return sc;
}