Reporting Errors and Warnings from Providers

Providers indicate errors and warnings in a variety of ways, including framework and stack-trace logging to the logging system. Provider authors can customize exception handling and reporting.

Nearly all provider methods include SecException to indicate a failure. At a minimum, the framework logs the exception's message and stack trace to the logging system. The framework may propagate the message to the client, depending on the provider type and the exception type. The framework may add the exceptions to the context warning list or log them for troubleshooting purposes.

In the provider implementation, use com.sybase.security.provider.ProviderServices to add a warning to the SecContext. The ProviderServices can be accessed from the shared map passed into the initialize method in the provider (ProviderServices)sharedState.get(ProviderConst.PROVIDER_SERVICES).

Authentication providers have an alternative mechanism to propagate warnings. When a LoginException is thrown from the login method of an authentication provider, the framework automatically adds a warning to the SecContext. If the LoginException instance already implements the SecWarning interface, the exception itself is added as a warning. Otherwise, the exception is wrapped in a lightweight wrapper (com.sybase.security.provider.SecLoginExceptionWarningImpl). The authentication provider can use the com.sybase.security.provider.SecLoginExceptionAuthenticationFailureWarningImpl class to simultaneously signify login failure and supply a more specific failure reason mapped from com.sybase.security.core.AuthenticationFailureReasons.

For more details, see the javadoc for these classes, and refer to the sample provider implementation in the server SDK.