@Loggable(value=1) public final class AuthInset extends Object implements Inset
Inset.Default, Inset.Runtime| Constructor and Description |
|---|
AuthInset(Resource res,
String sec)
Public ctor.
|
| Modifier and Type | Method and Description |
|---|---|
javax.ws.rs.core.NewCookie |
cookie(Identity identity)
Authentication cookie.
|
String |
encrypt(Identity identity)
Encrypt identity into text.
|
static String |
encrypt(Identity identity,
String key)
Encrypt identity into text.
|
Identity |
identity()
Get user's identity (
AuthException
if not authenticated). |
javax.ws.rs.core.NewCookie |
logout()
Logout authentication cookie.
|
void |
render(BasePage<?,?> page,
javax.ws.rs.core.Response.ResponseBuilder builder)
Render it into the response builder.
|
AuthInset |
with(Provider prov)
With this authentication provider.
|
public static String encrypt(@NotNull Identity identity, @NotNull String key)
identity - The identity to encryptkey - Security keypublic String encrypt(@NotNull Identity identity)
identity - The identity to encryptpublic AuthInset with(@NotNull Provider prov)
prov - Additional authentication provider@Cacheable(lifetime=1,
unit=SECONDS)
public Identity identity()
AuthException
if not authenticated).public void render(@NotNull
BasePage<?,?> page,
@NotNull
javax.ws.rs.core.Response.ResponseBuilder builder)
Insetpublic javax.ws.rs.core.NewCookie cookie(Identity identity)
identity - The identity to wrap into the cookie@Cacheable.FlushAfter public javax.ws.rs.core.NewCookie logout()
Use this cookie to log user out of the system, for example:
if (you_are_not_allowed()) {
throw new AuthException(
Response.seeOther(this.uriInfo().getBaseUri())
.cookie(this.auth().logout())
.build()
);
}
Copyright © 2011–2014 ReXSL.com. All rights reserved.