@Override public URN urn() { return this.identity.urn(); }
/** * With this URN. * @param urn The URN * @return This object */ public IdentityMocker withURN(final URN urn) { Mockito.doReturn(urn).when(this.identity).urn(); return this; }
/** * Public ctor. * @param identity Original identity */ public Simple(@NotNull final Identity identity) { this(identity.urn(), identity.name(), identity.photo()); } /**
/** * 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()); }
/** * 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() ); } }