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
- Import the data:
- 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.
- In the sample project, open each of the following files,
and make sure that the content is appropriate for your server:
- 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.
- Configure J2EE security. For general information
about setting up web-based, container-managed J2EE security, see "Using
J2EE container-managed security".
- Set up WebSphere Application
Server for J2EE security:
- Create an instance of WebSphere Application
Server (for example, version 8.0) and start the server.
- Right-click the server and select .
- At the main administrative console, expand and then click Secure
administration, applications, and infrastructure.
- Select Enable administrative security and Enable
application security, but clear Use Java 2
security to restrict application access to local resources.
- In the Available realm definition section,
select Standalone LDAP registry. Klicken Sie auf Set as current.
- Access the Standalone LDAP registry properties:
- Click Configure.
- On the Additional Properties tab of the Standalone LDAP registry
properties window, click Advanced Lightweight Directory
Access Protocol (LDAP) user registry settings.
- For the User filter, enter (&(uid=%v)(objectclass=person)),
and click OK.
- Geben Sie als Namen des primären Benutzers mit Verwaltungsaufgaben msmith ein.
- Wählen Sie Automatically generated server identity aus.
- 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 |
- 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.
- Beenden Sie die Administrationskonsole und stoppen Sie den Server.
- Set up your instance of WebSphere Application Server:
- Right-click your server and select Open.
- Specify automatic connection settings or change the server connection
type from RMI to SOAP.
Verwenden Sie den Standardport.
- 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.
- Speichern Sie Ihre Änderungen.
- 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:
- 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.
- When the system prompt is displayed again, type securityoff.
- Wenn Sie fertig sind, geben Sie quit ein.
- Starten Sie den Anwendungsserver erneut.
- Run the sample:
- Bereinigen Sie das Projekt "SecureLDAPSample".
- To generate the code, use the SecureLDAPSampleWebBuildOptions build
descriptor , which is in SecureLDAPSample.eglbld.
- Right-click your instance of WebSphere Application Server. Klicken Sie auf Projekte hinzufügen und entfernen.
- Fügen Sie "SecureLDAPSampleEAR" zum Server hinzu und klicken Sie auf Fertig stellen.
- Start WebSphere Application
Server to complete the security configuration:
- Right-click the server and select .
- Expand Applications and click Enterprise
applications. The Enterprise Applications page is displayed.
- Click SecureLDAPSampleEAR. An application
configuration page is displayed.
- In the Web Module Properties section, click Session
Management. The Session Management page is displayed.
- 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.
- Restart WebSphere Application
Server.
- In the WebContent folder in SecureLDAPSample,
right click welcome.jsp. Wählen Sie Ausführen als und anschließend Auf Server ausführen aus.
- 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.
- Klicken Sie auf Aktualisieren.
- 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.
- Starten Sie den Server und die Workbench erneut.
- 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.