@Override public void render(final BasePage<?, ?> page, final Response.ResponseBuilder builder) { if (!BaseRs.this.auth().identity().equals(Identity.ANONYMOUS)) { try { page.append(new JxHuman(BaseRs.this.human())); } catch (final IOException ex) { throw new IllegalStateException(ex); } } } };
@Override public void render(final BasePage<?, ?> page, final Response.ResponseBuilder builder) { if (!BaseRs.this.auth().identity().equals(Identity.ANONYMOUS)) { try { page.append( new JaxbBundle("token", BaseRs.this.user().token()) ); } catch (final IOException ex) { throw new IllegalStateException(ex); } page.link(new Link("user:refresh", "/u/refresh")); } } };
/** * Get current user. * @return User */ protected final User user() { final Identity identity = this.auth().identity(); if (identity.equals(Identity.ANONYMOUS)) { throw FlashInset.forward( this.uriInfo().getBaseUriBuilder().clone() .path(IndexRs.class) .build(), "please login first", Level.SEVERE ); } return this.base().user(identity.urn()); }
@Override public void render(final BasePage<?, ?> page, final Response.ResponseBuilder builder) { if (!BaseRs.this.auth().identity().equals(Identity.ANONYMOUS)) { page.link(new Link("menu:home", "/")); page.link(new Link("menu:counters", "/counters")); page.link(new Link("menu:locks", "/k")); } } };
@Path("/") public Response index() throws IOException { if (!this.auth().identity().equals(Identity.ANONYMOUS)) { final Iterable<Talk> talks = new SafeHuman(this.human(), this).next();
/** * Get current human. * @return Human * @throws IOException If fails */ protected final Human human() throws IOException { final Identity identity = this.auth().identity(); if (identity.equals(Identity.ANONYMOUS)) { throw this.flash().redirect( this.uriInfo().getBaseUri(), "please login", Level.INFO ); } try { return this.base().human(identity.urn()); } catch (final Base.HumanNotFoundException ex) { throw new WebApplicationException( ex, Response.seeOther(this.uriInfo().getBaseUri()) .cookie(this.auth().logout()) .entity(ex.getLocalizedMessage()) .build() ); } }
@Override public void render(@NotNull final BasePage<?, ?> page, @NotNull final Response.ResponseBuilder builder) { final Identity identity = this.identity(); if (identity.equals(Identity.ANONYMOUS)) { for (final Provider prov : this.providers) {