本文整理汇总了Java中com.vaadin.server.VaadinRequest.getUserPrincipal方法的典型用法代码示例。如果您正苦于以下问题:Java VaadinRequest.getUserPrincipal方法的具体用法?Java VaadinRequest.getUserPrincipal怎么用?Java VaadinRequest.getUserPrincipal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.server.VaadinRequest
的用法示例。
在下文中一共展示了VaadinRequest.getUserPrincipal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAppStarted
import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
@EventListener
protected void onAppStarted(AppStartedEvent event) throws LoginException {
Connection connection = event.getApp().getConnection();
// can be already authenticated by another event listener
if (webIdpConfig.getIdpEnabled()
&& !connection.isAuthenticated()) {
VaadinRequest currentRequest = VaadinService.getCurrentRequest();
if (currentRequest != null) {
Principal principal = currentRequest.getUserPrincipal();
if (principal instanceof IdpSessionPrincipal) {
IdpSession idpSession = ((IdpSessionPrincipal) principal).getIdpSession();
Locale locale = event.getApp().getLocale();
ExternalUserCredentials credentials = new ExternalUserCredentials(principal.getName(), locale);
credentials.setSessionAttributes(
ImmutableMap.of(
IdpService.IDP_USER_SESSION_ATTRIBUTE,
idpSession.getId()
));
connection.login(credentials);
}
}
}
}
示例2: userSessionLoggedIn
import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Override
public void userSessionLoggedIn(UserSession session) {
VaadinRequest currentRequest = VaadinService.getCurrentRequest();
if (currentRequest != null) {
Principal principal = currentRequest.getUserPrincipal();
if (principal instanceof IdpSessionPrincipal) {
IdpSession idpSession = ((IdpSessionPrincipal) principal).getIdpSession();
session.setAttribute(IdpService.IDP_USER_SESSION_ATTRIBUTE, idpSession.getId());
}
}
}
示例3: getUIClass
import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Override
public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
VaadinRequest request = event.getRequest();
String url = parseUIMapping(request);
// If url is login, return LoginUI class
if (url.contains("login")) {
return LoginUI.class;
}
// If url is an empty url then return Secure if user is an
// authenticated else return login UI
if (url.isEmpty()) {
Principal principal = request.getUserPrincipal();
if (null == principal) {
return LoginUI.class;
}
return SecureUI.class;
}
// Return the secured UI
if (url.contains("secured")) {
return SecureUI.class;
}
return null;
}
示例4: isUserAuthenticated
import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
private boolean isUserAuthenticated(final VaadinRequest vaadinRequest) {
return vaadinRequest.getUserPrincipal() != null;
}
示例5: isUserAuthenticated
import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
private boolean isUserAuthenticated(VaadinRequest vaadinRequest) {
return vaadinRequest.getUserPrincipal() != null;
}