@Named(value="net.sf.mmm.service.base.server.RemoteInvocationExceptionConverter") public class ExceptionUtilImpl extends ExceptionUtilLimitedImpl implements ExceptionUtil
ExceptionUtil
.Modifier and Type | Field and Description |
---|---|
private boolean |
enforceSerializableForClient |
private EnvironmentDetector |
environmentDetector |
private static ExceptionUtil |
instance |
CDI_NAME, NO_STACKTRACE
Constructor and Description |
---|
ExceptionUtilImpl()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
Throwable |
convertForClient(Throwable exception)
Converts the given
exception for the client. |
Throwable |
convertForSerialization(Throwable exception,
ExceptionTruncation truncation)
Converts the given
exception so it is ensured to be serializable. |
Throwable |
convertForUser(Throwable exception,
ExceptionTruncation truncation)
Converts the given
exception for end-users with potential truncation. |
EnvironmentDetector |
getEnvironmentDetector() |
static ExceptionUtil |
getInstance()
This method gets the singleton instance of this
ExceptionUtil . |
protected ExceptionTruncation |
getTruncationForClient() |
boolean |
isEnforceSerializableForClient() |
protected boolean |
isRemoveStacktrace() |
protected Throwable |
obfuscateException(Throwable exception) |
void |
setEnforceSerializableForClient(boolean enforceSerializableForClient) |
void |
setEnvironmentDetector(EnvironmentDetector environmentDetector) |
convertForUser, getStacktrace
createLogger, doInitialize, getLogger
doInitialized, getInitializationState, initialize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertForUser, getStacktrace
private static ExceptionUtil instance
getInstance()
private EnvironmentDetector environmentDetector
getEnvironmentDetector()
private boolean enforceSerializableForClient
isEnforceSerializableForClient()
public static ExceptionUtil getInstance()
ExceptionUtil
. Cdi.GET_INSTANCE
before using.public boolean isEnforceSerializableForClient()
true
if convertForClient(Throwable)
shall
enforce serializable exceptions
,
false
otherwise.public void setEnforceSerializableForClient(boolean enforceSerializableForClient)
enforceSerializableForClient
- is the new value of isEnforceSerializableForClient()
.public Throwable convertForSerialization(Throwable exception, ExceptionTruncation truncation)
exception
so it is ensured to be serializable.convertForSerialization
in interface ExceptionUtil
exception
- is the Throwable
to convert.truncation
- the ExceptionTruncation
to configure if details shall be removed. E.g.
ExceptionTruncation.REMOVE_ALL
.exception
. Guaranteed to implement
NlsThrowable
. By default an instance of
GenericSerializableException
.GenericSerializableException
,
NlsThrowable.createCopy(ExceptionTruncation)
public Throwable convertForUser(Throwable exception, ExceptionTruncation truncation)
exception
for end-users with potential truncation.convertForUser
in interface ExceptionUtil
exception
- is the exception to wrap.truncation
- the ExceptionTruncation
to configure if details shall be removed. E.g.
ExceptionTruncation.REMOVE_ALL
.NlsThrowable
.ExceptionUtilLimited.convertForUser(Throwable)
public Throwable convertForClient(Throwable exception)
exception
for the client. With client we mean any kind of system
that calls the current application via a remote interface. This can be a user-interface client, a
different server application, or the like. If the exception would be send to the client as is, then all
exception classes have to be available on the client side for de-serialization and all error details are
exposed to the client violating the OWASP principle sensitive data exposure. environment
. In development environment
and test environment
the details should be retained to support debugging. However, in
environments close
to production
, the details shall be removed.converted for the end-user
so that confusion with
technical details and exposure of internals in messages is avoided.converted
for serialization
.NlsThrowable
such as the
UUID
that is logged and transferred to the client,
you should call ExceptionUtilLimited.convertForUser(Throwable)
in advance.convertForClient
in interface ExceptionUtil
exception
- is the Throwable
that has been catched at an application boundary.Throwable
.protected Throwable obfuscateException(Throwable exception)
exception
- is the Throwable
to obfuscate.getTruncationForClient()
protected boolean isRemoveStacktrace()
true
if obfuscateException(Throwable)
shall remove the
stacktrace
of the resulting exception.protected ExceptionTruncation getTruncationForClient()
true
if exceptions shall be obfuscated, false
otherwise.public EnvironmentDetector getEnvironmentDetector()
EnvironmentDetector
instance.@Inject public void setEnvironmentDetector(EnvironmentDetector environmentDetector)
environmentDetector
- is the EnvironmentDetector
to Inject
.Copyright © 2001–2014 mmm-Team. All rights reserved.