Package org.glassfish.grizzly.http.server

Examples of org.glassfish.grizzly.http.server.Request


    }

    @Override
    public String format(Response response, Date timeStamp, long responseNanos) {
        final StringBuilder builder = new StringBuilder();
        final Request request = response.getRequest();
        for (Field field: fields) try {
            field.format(builder, request, response, timeStamp, responseNanos);
        } catch (Exception exception) {
            LOGGER.log(WARNING, "Exception formatting access log entry", exception);
            builder.append('-');
View Full Code Here


        return builder.toString();
    }

    String unsafeFormat(Response response, Date timeStamp, long responseNanos) {
        final StringBuilder builder = new StringBuilder();
        final Request request = response.getRequest();
        for (Field field: fields) {
            field.format(builder, request, response, timeStamp, responseNanos);
        }
        return builder.toString();
    }
View Full Code Here

        }
        final RestConfig restConfig = ResourceUtil.getRestConfig(locatorBridge.getRemoteLocator());

        Response.ResponseBuilder responseBuilder = Response.status(UNAUTHORIZED);
        RestActionReporter ar = new RestActionReporter();
        Request grizzlyRequest = request.get();

        // If the call flow reached here, the request has been authenticated by logic in RestAdapater
        // probably with an admin username and password.  The remoteHostName value
        // in the data object is the actual remote host of the end-user who is
        // using the console (or, conceivably, some other client).  We need to
        // authenticate here once again with that supplied remoteHostName to
        // make sure we enforce remote access rules correctly.
        String hostName = data.get("remoteHostName");
        boolean isAuthorized = false;
        boolean responseErrorStatusSet = false;
        Subject subject = null;
        try {
//            subject = ResourceUtil.authenticateViaAdminRealm(Globals.getDefaultHabitat(), grizzlyRequest, hostName);
            subject = ResourceUtil.authenticateViaAdminRealm(locatorBridge.getRemoteLocator(), grizzlyRequest, hostName);
            isAuthorized = ResourceUtil.isAuthorized(locatorBridge.getRemoteLocator(), subject, "domain/rest-sessions/rest-session", "create");
        } catch (RemoteAdminAccessException e) {
            responseBuilder.status(FORBIDDEN);
            responseErrorStatusSet = true;
        } catch (Exception e) {
            ar.setMessage("Error while authenticating " + e);
        }

        if (isAuthorized) {
            responseBuilder.status(OK);

            // Check to see if the username has been set (anonymous user case)
            String username = (String) grizzlyRequest.getAttribute("restUser");
            if (username != null) {
                ar.getExtraProperties().put("username", username);
            }
            ar.getExtraProperties().put("token", sessionManager.createSession(grizzlyRequest.getRemoteAddr(), subject, chooseTimeout(restConfig)));

        } else {
            if ( ! responseErrorStatusSet) {
                responseBuilder.status(UNAUTHORIZED);
            }
View Full Code Here

        }
        final RestConfig restConfig = ResourceUtil.getRestConfig(habitat);

        Response.ResponseBuilder responseBuilder = Response.status(UNAUTHORIZED);
        RestActionReporter ar = new RestActionReporter();
        Request grizzlyRequest = request.get();

        // If the call flow reached here, the request has been authenticated by logic in RestAdapater
        // probably with an admin username and password.  The remoteHostName value
        // in the data object is the actual remote host of the end-user who is
        // using the console (or, conceivably, some other client).  We need to
        // authenticate here once again with that supplied remoteHostName to
        // make sure we enforce remote access rules correctly.
        String hostName = data.get("remoteHostName");
        AdminAccessController.Access access = AdminAccessController.Access.NONE;
        Subject subject = null;
        try {
//            subject = ResourceUtil.authenticateViaAdminRealm(Globals.getDefaultHabitat(), grizzlyRequest, hostName);
            subject = ResourceUtil.authenticateViaAdminRealm(habitat, grizzlyRequest, hostName);
            access = (hostName == null) ? AdminAccessController.Access.FULL :
                    ResourceUtil.chooseAccess(habitat, subject, hostName);
        } catch (Exception e) {
            ar.setMessage("Error while authenticating " + e);
        }

        if (access == AdminAccessController.Access.FULL) {
            responseBuilder.status(OK);

            // Check to see if the username has been set (anonymous user case)
            String username = (String) grizzlyRequest.getAttribute("restUser");
            if (username != null) {
                ar.getExtraProperties().put("username", username);
            }
            ar.getExtraProperties().put("token", sessionManager.createSession(grizzlyRequest.getRemoteAddr(), subject, chooseTimeout(restConfig)));

        } else if (access == AdminAccessController.Access.FORBIDDEN) {
            responseBuilder.status(FORBIDDEN);
        }
View Full Code Here

        }
        final RestConfig restConfig = ResourceUtil.getRestConfig(habitat.getRemoteLocator());

        Response.ResponseBuilder responseBuilder = Response.status(UNAUTHORIZED);
        RestActionReporter ar = new RestActionReporter();
        Request grizzlyRequest = request.get();

        // If the call flow reached here, the request has been authenticated by logic in RestAdapater
        // probably with an admin username and password.  The remoteHostName value
        // in the data object is the actual remote host of the end-user who is
        // using the console (or, conceivably, some other client).  We need to
        // authenticate here once again with that supplied remoteHostName to
        // make sure we enforce remote access rules correctly.
        String hostName = data.get("remoteHostName");
        AdminAccessController.Access access = AdminAccessController.Access.NONE;
        Subject subject = null;
        try {
//            subject = ResourceUtil.authenticateViaAdminRealm(Globals.getDefaultHabitat(), grizzlyRequest, hostName);
            subject = ResourceUtil.authenticateViaAdminRealm(habitat.getRemoteLocator(), grizzlyRequest, hostName);
            access = (hostName == null) ? AdminAccessController.Access.FULL :
                    ResourceUtil.chooseAccess(habitat.getRemoteLocator(), subject, hostName);
        } catch (Exception e) {
            ar.setMessage("Error while authenticating " + e);
        }

        if (access == AdminAccessController.Access.FULL) {
            responseBuilder.status(OK);

            // Check to see if the username has been set (anonymous user case)
            String username = (String) grizzlyRequest.getAttribute("restUser");
            if (username != null) {
                ar.getExtraProperties().put("username", username);
            }
            ar.getExtraProperties().put("token", sessionManager.createSession(grizzlyRequest.getRemoteAddr(), subject, chooseTimeout(restConfig)));

        } else if (access == AdminAccessController.Access.FORBIDDEN) {
            responseBuilder.status(FORBIDDEN);
        }
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.http.server.Request

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.