Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  1. Wählen Sie im Menü File > New > Other....
  2. Wählen Sie im folgenden Dialog Authentication Provider und klicken Sie Next >.
    Image Removed

...

Standard Navigator durch Authentication Navigator ersetzen

Der Standard Navigator muss durch den Authentication Navigator ersetzt werden. 

  1. Öffnen Sie eine UI Ihres Projektes (meist die MainUI) und klicken Sie in der Outline-View den navigator mit Rechtsklick an.
  2. Wählen Sie im folgenden Kontextmenü Change Bean Type.
  3. Geben Sie im folgenden Dialog bei Select an item to open > XdevAuthenticationNavigator ein.
  4. Klicken Sie auf OK.
    Image Removed
  5. Klicken Sie bei Properties > Views > Entries.
  6. Entfernen Sie im folgenden Dialog den Aufruf der MainView.
    Image Removed
  7. Fügen Sie Ihre LoginView hinzu.
  8. Klicken Sie auf + New.
  9. Klicken Sie auf View Type
  10. Geben Sie im folgenden Dialog LoginView ein. 
  11. Klicken Sie auf OK.
  12. Fügen Sie mindestens 1 weitere View hinzu und geben Sie dafür jeweils bei Path eine URI an, z.B. home.
    Image Removed
  13. Klicken Sie auf OK.
  14. Wählen Sie bei PropertiesViews > RedirectViewName > home aus.
  15. Wiederholen Sie dies gegebenenfalls für alle anderen UIs Ihres Projekts

Login-View generieren

  1. Klicken Sie im Project Management > User Interface auf Create new GUI element.
  2. Legen Sie im folgenden Dialog bei Name einen Namen für die View fest. 
  3. Wählen Sie bie Template > Login View with Login Form aus.
  4. Klicken Sie auf Finish.
    Image RemovedImage Added
  5. Klicken Sie im folgenden Hinweis zum RapidClipse Framework auf OK.
  6. Wählen Sie im folgenden Dialog bei Authenticator Provider Ihren Ihren Authenticator Provider (siehe Business Objects) aus.
  7. Klicken Sie auf Finish.


Ergebnis:
  • GUI-Builder - Es wird eine Standard Login View im GUI-Builder generiert.
    Image RemovedImage Added
  • Javacode - Der gesamte Javacode dazu wird automatisch generiert.

    Code Block
    languagejava
    themeConfluence
    package com.company.exampledemoproject.ui;
    
    import com.company.exampledemoproject.business.MyAuthenticationProvider;
    import com.rapidclipse.vaadinframework.security.eventauthentication.ShortcutActionCredentialsUsernamePassword;
    import com.vaadinrapidclipse.ui.Alignment;
    import com.vaadin.ui.Buttonframework.server.security.authentication.Authentication;
    import com.vaadin.uiflow.component.CustomComponentComponentEvent;
    import com.vaadin.uiflow.component.NotificationComponentEventListener;
    import com.xdevvaadin.securityflow.authentication.AuthenticationFailedException;
    import com.xdev.security.authentication.CredentialsUsernamePasswordcomponent.login.AbstractLogin.ForgotPasswordEvent;
    import com.xdevvaadin.flow.securitycomponent.authenticationlogin.uiAbstractLogin.AuthenticationLoginEvent;
    import com.xdevvaadin.flow.securitycomponent.authorizationlogin.SubjectLoginForm;
    import com.xdevvaadin.ui.XdevButton;
    import com.xdev.ui.XdevGridLayoutflow.component.orderedlayout.FlexComponent;
    import com.xdevvaadin.ui.XdevPanel;
    import com.xdev.ui.XdevPasswordField;
    import com.xdev.ui.XdevTextField;
    import com.xdev.ui.XdevView;
    
    flow.component.orderedlayout.VerticalLayout;
    
    
    @com.rapidclipse.framework.server.security.authentication.LoginView
    public class LoginView extends XdevView implements com.xdev.security.authentication.ui.LoginView {
    
    	/**
    	 * 
    	 */
    VerticalLayout
    {
    	public LoginView()
    	{
    		super();
    		this.initUI();
    	}
    
    	@Override
    	public String getPassword() {
    		return txtPassword.getValue();
    	}
    
    	@Override
    	public String getUsername()
    {
    		return
    txtUsername.getValue();
    	}
    
    	/**
    	 * Event handler delegate method for the {@link XdevButtonLoginForm} 	 * {@link #cmdLogin#loginForm}.
    	 *
    	 * @see Button.ClickListener#buttonClick(Button.ClickEventComponentEventListener#onComponentEvent(ComponentEvent)
    	 * @eventHandlerDelegate Do NOT delete, used by UI designer!
    	 */
    	private void cmdLoginloginForm_buttonClick(Button.ClickEventonLogin(final LoginEvent event)
    	{
    		try {
    			final CredentialsUsernamePassword credentials = CredentialsUsernamePassword.New(
    			event.getUsername(), event.getPassword());
    		
    		MyAuthenticationProvider authenticatorProvider = MyAuthenticationProvider.getInstance();
    			Object
    authenticationResult = authenticatorProvider.provideAuthenticator().authenticate(credentials);
    			if(!Authentication.login(new Subject.ImplementationtryLogin(credentials.username()), authenticationResultauthenticatorProvider));
    		} catch (AuthenticationFailedException e) {
    			Notificationthis.loginForm.show("Invalid username/password"setError(true);
    		}
    	}
    	
    	/**
    	 * WARNING:Event Do NOT edit!<br>The content of thishandler delegate method isfor alwaysthe regenerated{@link 	LoginForm} * by the UI designer{@link #loginForm}.
    	 */
    	// <generated-code name="initUI">
    	private void initUI() {
    		this.gridLayout = new XdevGridLayout();
    		this.panel = new XdevPanel();
    		this.gridLayout2 = new XdevGridLayout();
    		this.txtUsername = new XdevTextField();
    		this.txtPassword = new XdevPasswordField();
    		this.cmdLogin = new XdevButton();
    	
    		this.panel.setCaption("Login");
    		this.panel.setTabIndex(0);
    		this.txtUsername.setCaption("Username");
    		this.txtPassword.setCaption("Password");
    		this.cmdLogin.setCaption("Login");
    		this.cmdLogin.setStyleName("friendly");
    		this.cmdLogin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    	
    		this.gridLayout2.setColumns(1);
    		this.gridLayout2.setRows(4);
    		this.txtUsername.setSizeUndefined();
    		this.gridLayout2.addComponent(this.txtUsername, 0, 0);
    		this.txtPassword.setSizeUndefined();
    		this.gridLayout2.addComponent(this.txtPassword, 0, 1);
    		this.cmdLogin.setSizeUndefined();
    		this.gridLayout2.addComponent(this.cmdLogin, 0, 2);
    		this.gridLayout2.setComponentAlignment(this.cmdLogin, Alignment.MIDDLE_RIGHT);
    		this.gridLayout2.setColumnExpandRatio(0, 10.0F);
    		CustomComponent gridLayout2_vSpacer = new CustomComponent();
    		gridLayout2_vSpacer.setSizeFull();
    		this.gridLayout2.addComponent(gridLayout2_vSpacer, 0, 3, 0, 3);
    		this.gridLayout2.setRowExpandRatio(3, 1.0F);
    		this.gridLayout2.setSizeFull();
    		this.panel.setContent(this.gridLayout2);
    		this.gridLayout.setColumns(1);
    		this.gridLayout.setRows(1);
    		this.panel.setSizeUndefined();
    		this.gridLayout.addComponent(this.panel, 0, 0);
    		this.gridLayout.setComponentAlignment(this.panel, Alignment.MIDDLE_CENTER);
    		this.gridLayout.setColumnExpandRatio(0, 10.0F);
    		this.gridLayout.setRowExpandRatio(0, 10.0F);
    		this.gridLayout.setSizeFull();
    		this.setContent(this.gridLayout);
    		this.setSizeFull();
    	
    		cmdLogin.addClickListener(event -> this.cmdLogin_buttonClick(event)* @see ComponentEventListener#onComponentEvent(ComponentEvent)
    	 * @eventHandlerDelegate Do NOT delete, used by UI designer!
    	 */
    	private void loginForm_onForgotPassword(final ForgotPasswordEvent event)
    	{
    		// TODO provide password recovery
    	}
    	
    	/* WARNING: Do NOT edit!<br>The content of this method is always regenerated by the UI designer. */
    	// <generated-code name="initUI">
    	private void initUI()
    	{
    		this.loginForm = new LoginForm();
    		
    		this.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
    		this.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
    		
    		this.add(this.loginForm);
    		this.setSizeFull();
    		
    		this.loginForm.addLoginListener(this::loginForm_onLogin);
    		this.loginForm.addForgotPasswordListener(this::loginForm_onForgotPassword);
    	} // </generated-code>
    	
    	// <generated-code name="variables">
    	private XdevButton cmdLogin;
    	private XdevGridLayout gridLayout, gridLayout2;
    	private XdevPanel panel;
    	private XdevPasswordField txtPassword;
    	private XdevTextField txtUsername; LoginForm loginForm;
    	// </generated-code>
    	
    }