Setup für J2EE-Sicherheit mit EGL-LDAP-Zugriff

Follow these instructions to set up and run the J2EE security with EGL LDAP access sample. To set up the sample, you import the data, configure J2EE security, and run the sample.

Vorbereitende Schritte

Um das Beispiel "J2EE-Sicherheit mit EGL-LDAP-Zugriff" zu verwenden, müssen Sie einen LDAP-kompatiblen Server verwenden. If you do not have an LDAP-compliant server, you can use an open-source server, such as, ApacheDS, and client, such as, Apache Directory Studio, that provides access to that server. Details finden Sie unter LDAP-kompatible Software konfigurieren.

Informationen zu diesem Vorgang

Diese Setup-Anweisungen gelten für ApacheDS und Apache Directory Studio. Wenn Sie einen anderen LDAP-kompatiblen Server verwenden, kann Ihre Konfiguration, abhängig von Ihrem Server, unterschiedlich sein.

Vorgehensweise

  1. Import the data:
    1. Um die Beispielprojekte in Ihren Arbeitsbereich zu laden, klicken Sie auf der Seite J2EE-Sicherheit mit EGL-LDAP-Zugriff auf Beispiel abrufen. Allow the workspace migration tool to perform any migration that is necessary.
    2. In the sample project, open each of the following files, and make sure that the content is appropriate for your server:
      • EGLSource/libraries/LdapLoginLib.egl, in which you might need to change the following providerURL entry:
        providerUrl String = "ldap://localhost:389/o=sample";
      • EGLSource/libraries/UserObjectLib.egl
    3. Import the sample data from SampleCompany.ldif file, which is in your project, to your directory server.
      • Wenn Sie einen vorhandenen LDAP-kompatiblen Server verwenden, importieren Sie die Beispieldaten aus der Datei SampleCompany.ldif, die sich an der folgenden Position befindet:
        Arbeitsbereich/SecureLDAPSample/
        Anmerkung: Arbeitsbereich ist der vollständig qualifizierte Pfadname Ihres EGL-Produktarbeitsbereichs, beispielsweise C:/MeinArbeitsbereich.
      • Wenn Sie die Open-Source-Apache-Software für Demonstrationszwecke verwenden, importieren Sie die Beispieldaten auf Ihren ApacheDS Directory Server, indem Sie die Anweisungen unter Beispieldaten mit Apache Directory Studio importieren befolgen.
  2. Configure J2EE security. For general information about setting up web-based, container-managed J2EE security, see "Using J2EE container-managed security".
    1. Set up WebSphere Application Server for J2EE security:
      1. Create an instance of WebSphere Application Server (for example, version 8.0) and start the server.
      2. Right-click the server and select Administration > Run administrative console.
      3. At the main administrative console, expand Security > Global security and then click Secure administration, applications, and infrastructure.
      4. Select Enable administrative security and Enable application security, but clear Use Java 2 security to restrict application access to local resources.
      5. In the Available realm definition section, select Standalone LDAP registry. Klicken Sie auf Set as current.
      6. Access the Standalone LDAP registry properties:
        1. Click Configure.
        2. On the Additional Properties tab of the Standalone LDAP registry properties window, click Advanced Lightweight Directory Access Protocol (LDAP) user registry settings.
        3. For the User filter, enter (&(uid=%v)(objectclass=person)), and click OK.
      7. Geben Sie als Namen des primären Benutzers mit Verwaltungsaufgaben msmith ein.
      8. Wählen Sie Automatically generated server identity aus.
      9. Enter your LDAP bind criteria, and click OK and Apply. If you use the open source Apache software for demonstration purposes, use the criteria listed in the table. Otherwise, use the defaults.
        Tabelle 1. LDAP bind criteria
        Bind criteria Wert
        LDAP-Servertyp Benutzerdefiniert
        Host localhost
        Port 389
        Basic distinguished name (DN) o=sample
        Definierter Bindungsname uid=msmith,ou=people,o=sample
        Kennwort für Bindung pass
      10. In the message box at the top of the window, click Save directly to the master configuration.
        Wichtig: Because you enabled administrative security, you must log in to WebSphere Application Server by using the user ID msmith and password pass. Wenn Sie die Verwaltungssicherheit nach dem Ausführen dieses Beispiels nicht länger benötigen, inaktivieren Sie die Verwaltungssicherheit.
      11. Beenden Sie die Administrationskonsole und stoppen Sie den Server.
    2. Set up your instance of WebSphere Application Server:
      1. Right-click your server and select Open.
      2. Specify automatic connection settings or change the server connection type from RMI to SOAP. Verwenden Sie den Standardport.
      3. Under Security, select Security is enabled on this server. For your user ID, enter msmith; for your password, enter pass. Make sure that Automatically trust server certificate during the SSL handshake is selected.
        Wichtig: To avoid authentication errors and needless looping, make sure that the user ID and password exactly match the credentials entered in the administrative console.
      4. Speichern Sie Ihre Änderungen.
    3. Laden Sie das Beispiel "J2EE-Sicherheit mit EGL-LDAP-Zugriff" herunter.
      The deployment descriptor (WebContent/WEB-INF/web.xml) for the project SecureLDAPSample was configured for J2EE security:
      • On the Security tab, the AllRole security role was added.
      • Die Integritätsbedingung für die Sicherheit "Constraint1" wurde hinzugefügt. Eine Integritätsbedingung gibt die Ressourcen in diesem Projekt an, die von J2EE-Sicherheit gesichert werden, sowie die Rollen, die auf diese Ressourcen zugreifen können. Constraint1 specifies that only people with the All Role security role can access the JSP pages, or resources, in this project that are defined under WebContent (“/*”).
      • Auf der Registerkarte Pages wurde die Authentifizierungsmethode auf "FORM" festgelegt. Dies gibt an, dass die formularbasierte Authentifizierung verwendet wird. A Login page and Error page were defined in the project and specified for use with form-based authentication.
      Der Implementierungsdeskriptor EarContent/META-INF/application.xml für das Projekt "SecureLDAPSampleEAR" wurde für J2EE-Sicherheit konfiguriert:
      • Auf der Registerkarte Security wurde die Sicherheitsrolle "AllRole" hinzugefügt.
      • Under WebSphere Bindings, All authenticated users was selected to map to AllRole. As a result, all user IDs in the SampleCompany directory are mapped to AllRole and can run this web application.
      If you have trouble running administrative security, you can disable it by working at the command line instead of at the administrative console. Um die Verwaltungssicherheit zu inaktivieren, gehen Sie folgendermaßen vor:
      1. Geben Sie in der Eingabeaufforderung Folgendes ein:
        WebSphere-Ausgangsverzeichnis\bin\wsadmin.bat -conntype NONE
        Anmerkung: WebSphere_home is the fully qualified path name of the install directory for WebSphere Application Server.
      2. When the system prompt is displayed again, type securityoff.
      3. Wenn Sie fertig sind, geben Sie quit ein.
      4. Starten Sie den Anwendungsserver erneut.
  3. Run the sample:
    1. Bereinigen Sie das Projekt "SecureLDAPSample".
    2. To generate the code, use the SecureLDAPSampleWebBuildOptions build descriptor , which is in SecureLDAPSample.eglbld.
    3. Right-click your instance of WebSphere Application Server. Klicken Sie auf Projekte hinzufügen und entfernen.
    4. Fügen Sie "SecureLDAPSampleEAR" zum Server hinzu und klicken Sie auf Fertig stellen.
    5. Start WebSphere Application Server to complete the security configuration:
      1. Right-click the server and select Administration > Run administrative console.
      2. Expand Applications and click Enterprise applications. The Enterprise Applications page is displayed.
      3. Click SecureLDAPSampleEAR. An application configuration page is displayed.
      4. In the Web Module Properties section, click Session Management. The Session Management page is displayed.
      5. In the General Properties section, click Security Integration.

      You do not need to repeat the security configuration if you run the sample again on the same server instance.

    6. Restart WebSphere Application Server.
    7. In the WebContent folder in SecureLDAPSample, right click welcome.jsp. Wählen Sie Ausführen als und anschließend Auf Server ausführen aus.
    8. On the login page, authenticate as Sample Company customer by typing the user ID ajones and the password pass; then click OK. The Welcome to Sample Company page opens. You can either display or update the data for ajones.
    9. Klicken Sie auf Aktualisieren.
    10. Change some of the data, and click Update and display. The changes are committed to the directory. The new data is displayed on the page.
    11. Starten Sie den Server und die Workbench erneut.
    12. On the server, run welcome.jsp and log in as a Sample Company employee by using the user ID msmith and the password pass. Sie können die Daten entweder anzeigen oder aktualisieren.

Feedback