本文整理匯總了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;
}