Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Search Base -
  • Suffix - 
  • Scurity Protocol - 
  • Security Authentication -


Ergebnis:
  • Project Management > Business Objects - Es wird die Klasse ExampleAuthenticationProvider.java generiert.

    Code Block
    languagejava
    themeConfluence
    package com.company.example.business;
    
    import javax.naming.directory.DirContext;
    
    import com.xdev.security.authentication.Authenticator;
    import com.xdev.security.authentication.AuthenticatorProvider;
    import com.xdev.security.authentication.CredentialsUsernamePassword;
    import com.xdev.security.authentication.ldap.LDAPAuthenticator;
    import com.xdev.security.authentication.ldap.LDAPConfiguration.LDAPConfigurationBuilder;
    
    public class MyAuthenticationProvider implements AuthenticatorProvider<CredentialsUsernamePassword, DirContext> {
    	private static MyAuthenticationProvider INSTANCE;
    
    	public static MyAuthenticationProvider getInstance() {
    		if (INSTANCE == null) {
    			INSTANCE = new MyAuthenticationProvider();
    		}
    
    		return INSTANCE;
    	}
    
    	private LDAPAuthenticator authenticator;
    
    	private MyAuthenticationProvider() {
    	}
    
    	@Override
    	public Authenticator<CredentialsUsernamePassword, DirContext> provideAuthenticator() {
    		if (this.authenticator == null) {
    			this.authenticator = new LDAPAuthenticator(
    					new LDAPConfigurationBuilder("ldap://192.168.90.7:389/dc=yourDomainComponent,dc=local")
    							.searchBase("OU=SBSUsers,OU=Users,OU=MyBusiness").suffix("@YOURDOMAIN.LOCAL")
    							.securityAuthentication("simple").build());
    		}
    
    		return this.authenticator;
    	}
    }