A estrutura SSO do Build Forge fornece a capacidade de integração com várias soluções SSL do mercado. A estrutura SSO é baseada em interceptor, o que significa que ela intercepta um pedido HTTP e fornece métodos para manipulá-lo. Você pode gravar interceptores customizados para receber e validar artefatos de segurança no pedido HTTP. Especialmente, o interceptor pode definir tokens na resposta HTTP e, em seguida, procurar esses tokens em um pedido sucessivo.
Duas soluções de SSO são fornecidas com o Build Forge:
com.buildforge.services.server.sso.ISSOIntercaptor
Ele
está localizado no componente da camada de serviços:<bfinstall>/Apache/tomcat/webapps/rbf-services/WEB-INF/classes
A interface fornece os seguintes métodos.
As configurações de interceptores são definidas em
. As configurações a seguir são enviadas com o Build Forge:Depois de implementar uma classe de interceptor e colocá-la no servidor de aplicativo Apache Tomcat do Build Forge, configure uma nova configuração SSO aqui. A classe é uma propriedade da configuração SSO.
A ordem dessa lista determina a ordem na qual os interceptores são consultados para tratar as solicitações. É possível configurar vários interceptores para tratar pedidos. Durante um login, cada interceptor é consultado na ordem. O interceptor que trata o pedido é o primeiro interceptor ativo cujos atributos são apropriados para os atributos do pedido. Somente um interceptor trata o pedido. É sempre o primeiro que responde verdadeiro para isTargetInterceptor.
Para criar um interceptor customizado no Build Forge, faça o seguinte:
A classe deve implementar a interface ISSOInterceptor.
<bfinstall>/Apache/tomcat/webapps/rbf-services/WEB-INF/classes
Durante um pedido, as configurações de SSO ativas são acessadas na ordem em que aparecem nesse painel. Sua configuração deve ser colocada antes da configuração de Formulário de SSO, porque é ativa por padrão e sempre retorna verdadeiro quando acessada. A configuração SPNEGO SSO é inativa por padrão.
O exemplo a seguir é obtido do WebSphere SSO Interceptor, que é usado para integrar a segurança do WebSphere com o Build Forge.
O interceptor usa o reflexo para encontrar a classe WSSubject do WebSphere. A classe tem um método getCallerPrincipal para retornar o proprietário usado para efetuar login no AuthServlet. O AuthServlet precisa estar protegido para que o WAS seja autenticado nele.
Outros métodos estão disponíveis que podem retornar ainda mais informações. Estão disponíveis métodos semelhantes para funcionar com qualquer servidor de aplicativo.
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 a implementação de authenticateRequest, você deve definir um status de resposta antes de retornar:
responseAttributes.setStatus(HttpServletResponse.SC_OK);
responseAttributes.setStatus(HttpServletResponse,SC_FORBIDDEN);
responseAttributes.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
responseAttributes.sendRedirecct(url);
Há valores de status adicionais que podem ser usados. Consulte o JavaDoc para obter HttpServletResponse.
Se o interceptor customizado não funcionar corretamente quando testado, muito provavelmente o problema será de autenticação. Você vê uma página de erro com as seguintes informações:
Erro no BuildForge
Acesso negado ao console do Buil Forge
"Erro ao autenticar:
com.buildforge.services.common.api.APIException - API:
Erro de Autenticação."
Clique aqui para tentar o mesmo tipo de login novamente
ou clique aqui para forçar um login por formulário (ID do usuário/senha).
Você tem duas opções de recuperação:
Os seguintes comentários e listagens de origem fornecem mais informações sobre os métodos na interface 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;