List of usage examples for org.apache.shiro.subject Subject releaseRunAs
PrincipalCollection releaseRunAs();
From source file:com.wegas.core.security.rest.UserController.java
License:MIT License
/** * See like an other user specified by it's jpaAccount id. Administrators * only./*from w w w. j a va 2s . co m*/ * * @param accountId jpaAccount id */ @POST @Path("Be/{accountId: [1-9][0-9]*}") public void runAs(@PathParam("accountId") Long accountId) { Subject oSubject = SecurityUtils.getSubject(); if (oSubject.isRunAs()) { oSubject.releaseRunAs(); //@TODO: check shiro version > 1.2.1 (SHIRO-380) } oSubject.checkRole("Administrator"); SimplePrincipalCollection subject = new SimplePrincipalCollection(accountId, "jpaRealm"); oSubject.runAs(subject); }