本文整理汇总了Java中org.apache.wicket.authroles.authentication.AuthenticatedWebSession类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticatedWebSession类的具体用法?Java AuthenticatedWebSession怎么用?Java AuthenticatedWebSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticatedWebSession类属于org.apache.wicket.authroles.authentication包,在下文中一共展示了AuthenticatedWebSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LoginForm
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
public LoginForm(String markupId) {
super(markupId);
this.setDefaultModel(new CompoundPropertyModel<Object>(this));
this.add(new TextField("username").setRequired(true));
this.add(new PasswordTextField("password").setRequired(true));
Button submitBtn = new AjaxButton("loginBtn", Model.of("Sign In")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
if (AuthenticatedWebSession.get().signIn(username, password))
setResponsePage(DiscoverItemsPage.class);
else {
target.add(ComponentUtils.displayBlock(alert));
}
}
};
this.add(submitBtn);
this.setDefaultButton(submitBtn);
}
示例2: onSubmit
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
protected void onSubmit()
{
AuthenticatedWebSession session = AuthenticatedWebSession.get();
if (session.signIn(username, password)) {
log.debug("Login successful");
if (sessionRegistry != null) {
// Form-based login isn't detected by SessionManagementFilter. Thus handling
// session registration manually here.
HttpSession containerSession = ((ServletWebRequest) RequestCycle.get()
.getRequest()).getContainerRequest().getSession(false);
sessionRegistry.registerNewSession(containerSession.getId(), username);
}
setDefaultResponsePageIfNecessary();
}
else {
error("Login failed");
}
}
示例3: route
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
public Object route(final Object original) {
if(original != null) {
return original;
}
// ensure that any persisted objects have been deleted.
container.flush();
final BreadcrumbModelProvider wicketSession = (BreadcrumbModelProvider) AuthenticatedWebSession.get();
final BreadcrumbModel breadcrumbModel = wicketSession.getBreadcrumbModel();
final List<EntityModel> breadcrumbs = breadcrumbModel.getList();
final Optional<Object> firstViewModelOrNonDeletedPojoIfAny = breadcrumbs.stream()
.filter(entityModel -> entityModel != null).map(EntityModel::getObject)
.filter(objectAdapter -> objectAdapter != null).map(ObjectAdapter::getObject)
.filter(pojo -> !(pojo instanceof Persistable) || !((Persistable)pojo).dnIsDeleted())
.findFirst();
return firstViewModelOrNonDeletedPojoIfAny.orElse(homePage());
}
示例4: LogoutPage
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
protected LogoutPage(IPageLinkDescriptor signInPageLinkDescriptor) {
if(AuthenticatedWebSession.exists()) {
AuthenticatedWebSession.get().invalidate();
}
throw signInPageLinkDescriptor.newRestartResponseException();
}
示例5: commonInit
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@SuppressWarnings("serial")
private void commonInit()
{
add(new Label("username").setDefaultModel(new Model<>(SecurityContextHolder
.getContext().getAuthentication().getName())));
add(new StatelessLink<Void>("logout")
{
@Override
public void onClick()
{
AuthenticatedWebSession.get().signOut();
getSession().invalidate();
setResponsePage(getApplication().getHomePage());
}
});
add(new MarkupContainer("logoutTimer")
{
@Override
protected void onConfigure()
{
super.onConfigure();
setVisible(getAutoLogoutTime() > 0);
}
});
}
示例6: onSubmit
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
protected void onSubmit() {
AuthenticatedWebSession session = AuthenticatedWebSession.get();
if (session.signIn(username, password)) {
setResponsePage(HomePage.class);
} else {
error("Login failed");
}
}
示例7: onSubmit
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
public void onSubmit() {
LoginInfo loginInfo = (LoginInfo) form.getDefaultModelObject();
String username = loginInfo.getUsername();
String password = loginInfo.getPassword();
boolean signedIn = AuthenticatedWebSession.get().signIn(username, password);
HttpServletRequest httpServletRequest = WicketUtils.getHttpServletRequest();
if (signedIn) {
/**
* If login has been called because the user was not yet logged in, than continue to the original
* destination otherwise to the Home page
*/
try {
if (!continueToOriginalDestination()) {
setResponsePage(ArtifactoryApplication.get().getHomePage());
}
} catch (RuntimeException ignored) {
setResponsePage(ArtifactoryApplication.get().getHomePage());
}
//set a remember me cookie for the first success login
if (!ConstantValues.securityDisableRememberMe.getBoolean()) {
try {
rememberMeServices.loginSuccess(httpServletRequest, WicketUtils.getHttpServletResponse(),
AuthenticationHelper.getAuthentication());
} catch (UsernameNotFoundException e) {
log.warn("Remember Me service is not supported for transient external users.");
}
}
} else {
if (!ConstantValues.securityDisableRememberMe.getBoolean()) {
//Try the component based localizer first. If not found try the application localizer. Else use the default
error("Username or password are incorrect. Login failed.");
rememberMeServices.loginFail(httpServletRequest, getHttpServletResponse());
}
}
}
示例8: getHomePage
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
public Class<? extends Page> getHomePage() {
return AuthenticatedWebSession.get().isSignedIn()
&& SyncopeConsoleSession.get().owns(StandardEntitlement.MUST_CHANGE_PASSWORD)
? MustChangePassword.class
: Dashboard.class;
}
示例9: RegisterPage
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
public RegisterPage(PageParameters parameters) {
super(parameters);
if (AuthenticatedWebSession.exists() && AuthenticatedWebSession.get().isSignedIn()) {
redirect(DashboardPage.class);
return;
}
HttpServletRequest request = ((ServletWebRequest) RequestCycle.get().getRequest()).getContainerRequest();
ClientAuthenticationToken token = (ClientAuthenticationToken) request.getSession().getAttribute(Pac4jAuthenticationUtils.AUTH_TOKEN_ATTRIBUTE);
IModel<User> userModel = new GenericEntityModel<Long, User>(new User());
if (token != null && token.getUserProfile() != null) {
CommonProfile profile = (CommonProfile) token.getUserProfile();
if (profile.getEmail() != null) {
User user = userService.getByUserName(profile.getEmail());
if (user != null) {
LOGGER.warn("This email address is already used by another user");
getSession().warn(getString("register.userName.notUnique"));
}
}
userModel.getObject().setEmail(profile.getEmail());
userModel.getObject().setFullName(profile.getDisplayName());
userModel.getObject().setRemoteIdentifier(profile.getId());
}
addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("register.pageTitle"), RegisterPage.linkDescriptor()));
add(new Label("pageTitle", new ResourceModel("register.pageTitle")));
add(new RegisterFormPanel("registerFormPanel", userModel));
}
示例10: getWebSessionClass
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
return BasicApplicationSession.class;
}
示例11: getWebSessionClass
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
return ShowcaseSession.class;
}
示例12: CoreWicketAuthenticatedApplication
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
public CoreWicketAuthenticatedApplication() {
super();
// Get web session class to instantiate
webSessionClassRef = new WeakReference<Class<? extends AuthenticatedWebSession>>(getWebSessionClass());
}
示例13: hasAnyRole
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
public final boolean hasAnyRole(final Roles roles) {
final Roles sessionRoles = AuthenticatedWebSession.get().getRoles();
return sessionRoles != null && sessionRoles.hasAnyRole(roles);
}
示例14: onConfigure
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
@Override
protected void onConfigure()
{
super.onConfigure();
setVisible(AuthenticatedWebSession.get().isSignedIn());
}
示例15: get
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; //导入依赖的package包/类
public static EtcdWebSession get() {
return (EtcdWebSession)AuthenticatedWebSession.get();
}