La infraestructura de inicio de sesión único (SSO) de Build Forge® proporciona la capacidad de integrar muchas soluciones SSO del mercado. La infraestructura de SSO depende de un interceptor, es decir, intercepta una solicitud HTTP y proporciona métodos para gestionarla. Puede escribir interceptores personalizados para recibir y validar artefactos de seguridad en la solicitud HTTP. En particular, el interceptor puede establecer señales en la respuesta HTTP y, a continuación, buscar dichas señales en una solicitud sucesiva.
Con Build Forge® se proporcionan dos soluciones SSO:
com.buildforge.services.server.sso.ISSOInterceptor
Se encuentra en el componente de capa de servicios:<bfinstall>/Apache/tomcat/webapps/jas/WEB-INF/eclipse/plugins/com.ibm.jas-1.0.jar
La interfaz proporciona los siguientes métodos.
Las configuraciones del interceptor se definen en Build Forge®:
. Las siguientes configuraciones se suministran conDespués de implementar una clase de interceptor y colocarlo en el servidor de aplicaciones Apache Tomcat de Build Forge®, configure aquí una nueva configuración SSO. La clase es una propiedad de la configuración SSO.
El orden de la lista determina el orden en el que se consultan los interceptores para que gestionen las solicitudes. Puede configurar varios interceptores para gestionar solicitudes. Durante un inicio de sesión, cada interceptor se consulta en orden. El interceptor que gestiona la solicitud es el primer interceptor activo cuyos atributos sean adecuados para los atributos de la solicitud. Sólo un interceptor gestiona la solicitud. Siempre el primero que responda true a isTargetInterceptor.
Para crear un interceptor personalizado en Build Forge®, haga lo siguiente:
La clase debe implementar la interfaz ISSOInterceptor.
Durante una solicitud, se puede acceder a las configuraciones SSO activas en el orden en que aparecen en este panel. Dado que de forma predeterminada está activa y siempre devuelve true cuando se accede a la misma, debe colocar su configuración antes de la configuración de SSO de formulario. La configuración de SSO de SPNEGO está inactiva de forma predeterminada.
El ejemplo siguiente se toma del interceptor SSO de WebSphere, que se utiliza para integrar la seguridad de WebSphere Application Server con Build Forge®.
El interceptor utiliza el reflejo para buscar la clase de WebSphere WSSubject. La clase tiene un método getCallerPrincipal para devolver el principal usado para iniciar sesión en AuthServlet. AuthServlet se debe proteger para que WebSphere Application Server se pueda autenticar con el mismo.
Están disponibles otros métodos que pueden devolver aún más información. Están disponibles métodos similares para trabajar con cualquier servidor de aplicaciones.
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;
}
Durante la implementación de authenticateRequest, debe establecer un estado de respuesta antes de la devolución:
responseAttributes.setStatus(HttpServletResponse.SC_OK);
responseAttributes.setStatus(HttpServletResponse,SC_FORBIDDEN);
responseAttributes.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
responseAttributes.sendRedirecct(url);
Existen valores de estado adicionales que pueden utilizarse. Consulte JavaDoc para HttpServletResponse.
Si el interceptor personalizado no funciona correctamente al probarlo, el problema más probable será la autenticación. Se muestra una página de error con la información siguiente:
Build Forge Error
Access is denied to the Build Forge console
"Error authenticating:
com.buildforge.services.common.api.APIException - API:
Authentication Error."
Please click here to try the same type of login again
or click here to force a form login (user ID/password).
Tiene dos opciones para la recuperación:
Los siguientes comentarios y listados de fuente proporcionan más información sobre los métodos de la interfaz 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;