Das SSO-Framework von Build Forge® bietet die Möglichkeit zur Einbindung zahlreicher auf dem Markt erhältlicher SSO-Lösungen. Das SSO-Framework basiert auf Abfangprozessen, d. h., HTTP-Anforderungen werden abgefangen und es werden Methoden für deren Verarbeitung bereitgestellt. Sie können angepasste Abfangprozesse schreiben, damit Sicherheitsartefakte in einer HTTP-Anforderung empfangen und validiert werden. Insbesondere können von einem Abfangprozess Token in der HTTP-Antwort gesetzt werden, nach denen dann in einer nachfolgenden Anforderung gesucht wird.
Im Lieferumfang von Build Forge® sind zwei SSO-Lösungen enthalten:
com.buildforge.services.server.sso.ISSOInterceptor
Sie befindet sich in der Komponente Services Layer:<bf-installationsverzeichnis>/Apache/tomcat/webapps/jas/WEB-INF/eclipse/plugins/com.ibm.jas-1.0.jar
Die Schnittstelle stellt folgende Methoden bereit:
Abfangprozesse werden unter Build Forge® wird mit folgenden Konfigurationen ausgeliefert:
konfiguriert.Nachdem Sie eine Klasse als Abfangprozess implementiert und auf dem Apache Tomcat-Anwendungsserver für Build Forge® abgelegt haben, definieren Sie nun eine neue SSO-Konfiguration. Die Klasse ist nur eine Eigenschaft der SSO-Konfiguration.
Die Reihenfolge in der Liste ist ausschlaggebend für die Reihenfolge, in der die Abfangprozesse für die Verarbeitung von Anforderungen herangezogen werden. Sie können mehrere Abfangprozesse für die Verarbeitung von Anforderungen konfigurieren. Während eines Anmeldevorgangs werden die einzelnen Abfangprozesse nacheinander aufgerufen. Der Abfangprozess, der die Anforderung verarbeitet, ist der erste aktive Abfangprozess, dessen Attribute für die Attribute in der Anforderung geeignet sind. Die Anforderung wird nur von einem Abfangprozess verarbeitet. Dabei handelt es sich immer um den ersten Abfangprozess, bei dem für isTargetInterceptor der Wert "true" zurückgegeben wird.
So erstellen Sie einen angepassten Abfangprozess in Build Forge®:
Diese Klasse muss die Schnittstelle ISSOInterceptor implementieren.
Bei einer Anforderung erfolgt der Zugriff auf aktive SSO-Konfigurationen in der Reihenfolge, in der die Konfigurationen in dieser Anzeige erscheinen. Da sie standardmäßig aktiv ist und beim Zugriff immer true zurückgibt, muss die von Ihnen hinzugefügte Konfiguration vor der Konfiguration für Form SSO platziert werden. Die Konfiguration für SPNEGO SSO ist standardmäßig inaktiv.
Das folgende Beispiel bezieht sich auf den WebSphere-SSO-Abfangprozess, der zum Einbinden der WebSphere Application Server-Sicherheit in Build Forge® verwendet wird.
Bei dem Abfangprozess wird die Reflexion verwendet, um die WebSphere-Klasse "WSSubject" zu finden. Diese Klasse verfügt über die Methode getCallerPrincipal, von der der Principal für die Anmeldung beim Authentifizierungsservlet (AuthServlet) zurückgegeben wird. Das Authentifizierungsservlet muss geschützt werden, bevor die Authentifizierung für WebSphere Application Server darüber ausgeführt wird.
Zusätzlich stehen weitere Methoden zur Verfügung, von denen noch mehr Informationen zurückgegeben werden können. Ähnliche Methoden sind für die Arbeit mit beliebigen Anwendungsservern verfügbar.
public Result authenticateRequest
(Request requestAttributes, Response responseAttributes)
throws SSOException {
Result result = null;
try {
Class<?> cl =
Class.forName(“com.ibm.websphere.security.auth.WSSubject”);
Method theMethod = cl.getMethod("getCallerPrincipal",
(Class[])null);
String principal = (String)theMethod.invoke((Object[])null,
(Object[])null);
if (principal != null
&& principal.length() > 0
&& !principal.equals("UNAUTHENTICATED")) {
result = new Result(Result.UseridOnlyOID, domain, principal);
responseAttributes.setStatus(HttpServletResponse.SC_OK);
} catch (Exception e) {
throw new SSOException(e);
}
return result;
}
Bei der Implementierung von authenticateRequest müssen Sie vor der Rückgabe einen Antwortstatus setzen:
responseAttributes.setStatus(HttpServletResponse.SC_OK);
responseAttributes.setStatus(HttpServletResponse,SC_FORBIDDEN);
responseAttributes.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
responseAttributes.sendRedirecct(url);
Es können zusätzliche Statuswerte verwendet werden. Weitere Informationen finden Sie im JavaDoc für HttpServletResponse.
Wenn Ihr angepasster Abfangprozess im Test nicht ordnungsgemäß funktioniert, besteht wahrscheinlich ein Problem mit der Authentifizierung. Es wird eine Fehlerseite mit folgenden Informationen angezeigt:
Build Forge-Fehler
Zugriff auf Build Forge-Konsole verweigert.
"Fehler beim Authentifizieren:
com.buildforge.services.common.api.APIException - API:
Zugriff verweigert."
Klicken Sie hier, um dieselbe Anmeldung erneut zu versuchen,
oder klicken Sie hier, um eine formelle Anmeldung (mit Benutzer-ID und Kennwort) zu erzwingen.
Sie haben zwei Möglichkeiten für die Wiederherstellung:
Die folgenden Kommentare und Quellenlisten bieten weitere Informationen zu den Methoden in der Schnittstelle ISSOInterceptor.
initInterceptor
/**
* This method is called when the interceptor is loaded. A map of the
configuration properties is passed into the init method. You can create
the configuration properties from a BuildForge Environment and associate
it with the SSO configuration.
*
* @param initializationProps used to configure the implementation
* @return true if successful, false if an error should be reported.
* @throws SSOException if the initialization fails
**/
public boolean initInterceptor (Properties initializationProps) throws SSOException;
isTargetInterceptor
/**
* This methods will review the attributes in the requestAttributes Map
to determine if there is something that this interceptor should
act on. If the interceptor return is "true", then the interceptor will
be responsible for authenticating the request and the authenticateRequest
method is invoked. If the interceptor return is "false", then this
interceptor is skipped and the next isTargetInterceptor in the list will
be called. Ordering of the interceptors during the configuration will
return which interceptor has the first shot at authenticating a request.
*
* @param requestAttributes attributes found in the inbound request
* @return true if this interceptor will authenticate the request,
false if it will not.
* @throws SSOException
*
**/
public boolean isTargetInterceptor(Request requestAttributes) throws SSOException;
authenticateRequest
/**
* This method is called on an interceptor that returns true for the
isTargetInterceptor method. The Request will contain data used
to perform the authentication. The Response is for the interceptor
to send information back to the client. The Result returned will contain
the following information if the status code is 200:
*
* OID: an object identifier of the SecurityContext that can process token
information stored in this map when going to an Agent.
* Domain: a valid BF domain name or <default> if not known
(the username must be valid in the configured realm).
* Username: a valid BF username. This will be used to lookup BFUser attributes
that are used in checking authorization policy.
* @see com.buildforge.services.common.security.context.Result
*
* @param requestAttributes attributes found in the inbound request
* @param responseAttributes sent back in the outbound response
* @return com.buildforge.services.common.security.context.Result - result
information that tells BF how to handle the authentication request.
* @throws com.buildforge.services.server.sso.SSOException
**/
public Result authenticateRequest(
Request requestAttributes,
Response responseAttributes)
throws SSOException;
logoutRequest
/**
* This method is called to logout a request. The first interceptor that
returns true for the isTargetInterceptor method will perform the logout.
The main point is to clean up any user-related security information that
should not be kept. The interceptor can inspect the request and response
objects to determine what needs to be removed.
*
* @param requestAttributes attributes found in the inbound request
* @param responseAttributes sent back in the outbound response
* @return boolean - true if request redirect to exit page,
false if redirect to login page.
* @throws com.buildforge.services.server.sso.SSOException
**/
public boolean logoutRequest(
Request requestAttributes,
Response responseAttributes)
throws SSOException;