Open
Description
I am getting an exception
org.springframework.security.access.AccessDeniedException: Access is denied
at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:84)
at org.springframework.statemachine.security.StateMachineSecurityInterceptor.decide(StateMachineSecurityInterceptor.java:190)
at org.springframework.statemachine.security.StateMachineSecurityInterceptor.decide(StateMachineSecurityInterceptor.java:157)
at org.springframework.statemachine.security.StateMachineSecurityInterceptor.preTransition(StateMachineSecurityInterceptor.java:109)
at org.springframework.statemachine.support.StateMachineInterceptorList.preTransition(StateMachineInterceptorList.java:128)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.handleTriggerTrans(DefaultStateMachineExecutor.java:266)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.handleTriggerTrans(DefaultStateMachineExecutor.java:211)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.processTriggerQueue(DefaultStateMachineExecutor.java:449)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.access$200(DefaultStateMachineExecutor.java:65)
at org.springframework.statemachine.support.DefaultStateMachineExecutor$1.run(DefaultStateMachineExecutor.java:323)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.scheduleEventQueueProcessing(DefaultStateMachineExecutor.java:352)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.execute(DefaultStateMachineExecutor.java:163)
at org.springframework.statemachine.support.AbstractStateMachine.sendEventInternal(AbstractStateMachine.java:603)
at org.springframework.statemachine.support.AbstractStateMachine.sendEvent(AbstractStateMachine.java:218)
at org.springframework.statemachine.support.AbstractStateMachine.sendEvent(AbstractStateMachine.java:230)
This behavior is as expected by application based on spring security. However i want to catch this exception throw it back to my api user. For the same I have written a custom listener.
public class ErrorStateMachineListener
extends StateMachineListenerAdapter<AgreementSubStatus, AgreementEvents> {
@Override
public void stateMachineError(
StateMachine<AgreementSubStatus, AgreementEvents> stateMachine, Exception exception) {
//System.out.println("here i am -------------");
//throw new IllegalStateTransitionException("Illegal state transition.");
}
@Override
public void stateEntered(State<AgreementSubStatus, AgreementEvents> state){
//System.out.println("here i am 2-------------"+state.getId().name());
}
}
And registered this listener in
builder
.configureConfiguration()
.withConfiguration()
.listener(new ErrorStateMachineListener())
.autoStartup(true)
.and()
.withSecurity()
.enabled(true);
However the control never goes to this method --public void stateMachineError
Metadata
Metadata
Assignees
Labels
No labels