Package org.graylog2.restclient.models

Examples of org.graylog2.restclient.models.User


        final ArrayList<Node> nodes = Lists.newArrayList();
        for (AddressNodeId n : nodeDesc) {
            NodeSummaryResponse r = new NodeSummaryResponse();
            r.transportAddress = n.address;
            r.id = n.nodeId;
            final Node node = factory.fromSummaryResponse(r);
            node.touch();
            nodes.add(node);
        }
        serverNodes.put(nodes);
    }
View Full Code Here


public class SearchRouteHelper {

    public static Call getRoute(UniversalSearch search,
                                Http.Request request,
                                int page) {
        SearchSort order = search.getOrder();
        return getRoute(search, request, page, order.getField(), order.getDirection().toString().toLowerCase());
    }
View Full Code Here

            case EMAIL_TRANSPORT_FAILED:
                return new EmailTransportFailedNotification(notification);
            case STREAM_PROCESSING_DISABLED:
                String streamTitle;
                try {
                    final Stream stream = streamService.get(notification.getDetail("stream_id").toString());
                    streamTitle = stream.getTitle();
                } catch (APIException | IOException e) {
                    streamTitle = "(Stream title unavailable)";
                }
                int faultCount = (int) notification.getDetail("fault_count");
                return new StreamProcessingDisabledNotification(notification, streamTitle, faultCount);
View Full Code Here

    public static SessionService sessionService;

    @Override
    public String getUsername(Context ctx) {
        try {
            final User sessionUser = pipelineAuths(authenticateSessionUser(), authenticateBasicAuthUser());
            if (sessionUser == null) {
                return null;
            }
            return sessionUser.getName();
        } catch (Graylog2ServerUnavailableException e) {
            ctx.args.put(GRAYLOG_2_SERVER_MISSING_KEY, e);
            return null;
        }
    }
View Full Code Here

    }

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        // the current user has been previously loaded via doGetAuthenticationInfo before, use those permissions
        User user = UserService.current();
        if (!principals.getPrimaryPrincipal().equals(user.getName())) {
            log.info("retrieving loaded user {} from per-request user cache", principals.getPrimaryPrincipal());
            user = (User) Http.Context.current().args.get("perRequestUsersCache:" + principals.getPrimaryPrincipal().toString());
            if (user == null) {
                log.error("Cannot find previously loaded user, need to load it explicitely. This is unimplemented.");
                return null;
            }
        }
        final List<String> permissions = user.getPermissions();
        final SimpleAuthorizationInfo authzInfo = new SimpleAuthorizationInfo();
        if (log.isTraceEnabled()) {
            log.trace("Permissions for {} are {}", user.getName(), Ordering.natural().sortedCopy(user.getPermissions()));
        }
        authzInfo.setStringPermissions(Sets.newHashSet(permissions));
        return authzInfo;
    }
View Full Code Here

            final String sessionId = token.getPrincipal().toString();
            response = api.get(UserResponse.class)
                    .path("/users/{0}", token.getUsername())
                    .session(sessionId)
                    .execute();
            final User user = userFactory.fromResponse(response, sessionId);

            UserService.setCurrent(user);
            user.setSubject(new Subject.Builder(SecurityUtils.getSecurityManager())
                    .principals(new SimplePrincipalCollection(user.getName(), "REST realm"))
                    .authenticated(true)
                    .buildSubject());
        } catch (IOException e) {
            throw new Graylog2ServerUnavailableException("Could not connect to Graylog2 Server.", e);
        } catch (APIException e) {
View Full Code Here

        return redirect(redirectTarget);
    }

    public Result reset(String username) {
        User user = userService.load(username);
        if (user.setStartpage(null)) {
            flash("success", "Startpage of user was reset.");
        } else {
            flash("error", "Could not reset startpage.");
        }


        return redirect(routes.UsersController.editUserForm(user.getName()));
    }
View Full Code Here

            return status(504, views.html.errors.error.render(ApiClient.ERROR_MSG_IO, e, request()));
        }
    }

    public Result show(String id) {
        final User currentUser = currentUser();
        try {
            Dashboard dashboard = dashboardService.get(id);

            final BreadcrumbList bc = new BreadcrumbList();
            bc.addCrumb("Dashboards", routes.DashboardsController.index());
            bc.addCrumb(dashboard.getTitle(), routes.DashboardsController.show(dashboard.getId()));

            return ok(views.html.dashboards.show.render(currentUser, bc, dashboard));
        } catch (APIException e) {
            if (e.getHttpCode() == NOT_FOUND || e.getHttpCode() == FORBIDDEN) {
                String msg = "The requested dashboard was deleted and no longer exists.";
                final Startpage startpage = currentUser.getStartpage();
                if (startpage != null) {
                    if (new Startpage(Startpage.Type.DASHBOARD, id).equals(startpage)) {
                        msg += " Please reset your startpage.";
                    }
                }
View Full Code Here

        final List<String> permissions = permissionsService.all();
        return ok(views.html.system.users.index.render(currentUser(), breadcrumbs(), allUsers, permissions));
    }

    public Result show(String username) {
        final User user = userService.load(username);
        if (user == null) {
            String message = "User not found! Maybe it has been deleted.";
            return status(404, views.html.errors.error.render(message, new RuntimeException(), request()));
        }

        BreadcrumbList bc = breadcrumbs();
        bc.addCrumb(user.getFullName(), routes.UsersController.show(username));

        return ok(show.render(user, currentUser(), bc));
    }
View Full Code Here

    public Result editUserForm(String username) {
        BreadcrumbList bc = breadcrumbs();
        bc.addCrumb("Edit " + username, routes.UsersController.editUserForm(username));

        User user = userService.load(username);
        final Form<ChangeUserRequestForm> form = changeUserForm.fill(new ChangeUserRequestForm(user));
        boolean requiresOldPassword = checkRequireOldPassword(username);
        try {
            return ok(edit.render(
                            form,
                            username,
                            currentUser(),
                            user,
                            requiresOldPassword,
                            permissionsService.all(),
                            ImmutableSet.copyOf(user.getPermissions()),
                            DateTools.getGroupedTimezoneIds().asMap(),
                            streamService.all(),
                            dashboardService.getAll(),
                            bc)
            );
View Full Code Here

TOP

Related Classes of org.graylog2.restclient.models.User

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.