@Override public void authorizeAccess() { AllowedMethodsInformation.checkAllowed(MethodType.GET_USER_TRANSACTION); } };
protected void realCheckPermission(MethodType methodType, InvocationType invocationType) { checkTransactionSync(methodType); if (invocationType != null) { if (denied.contains(new DeniedMethodKey(invocationType, methodType))) { throwException(methodType, invocationType); } } if (invocationType != InvocationType.CONCURRENT_CONTEXT && !beanManagedTransaction && methodType == MethodType.GET_USER_TRANSACTION) { throw EjbLogger.ROOT_LOGGER.unauthorizedAccessToUserTransaction(); } }
protected static void add(Set<DeniedMethodKey> otherDenied, InvocationType setEntityContext, MethodType timerServiceMethod) { otherDenied.add(new DeniedMethodKey(setEntityContext, timerServiceMethod)); }
/** * transaction sync is not affected by the current invocation, as multiple ejb methods may be invoked from afterCompletion */ private void checkTransactionSync(MethodType methodType) { //first we have to check the synchronization status //as the sync is not affected by the current invocation final CurrentSynchronizationCallback.CallbackType currentSync = CurrentSynchronizationCallback.get(); if (currentSync != null) { if (deniedSyncMethods.contains(new DeniedSyncMethodKey(currentSync, methodType))) { throwException(methodType, currentSync); } } }
@Override public int hashCode() { int result = callbackType != null ? callbackType.hashCode() : 0; result = 31 * result + (methodType != null ? methodType.hashCode() : 0); return result; } }
@Override protected void setup(Set<DeniedMethodKey> denied) { super.setup(denied); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_EJB_LOCAL_OBJECT); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_EJB_OBJECT); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_CALLER_PRINCIPLE); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.IS_CALLER_IN_ROLE); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_USER_TRANSACTION); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_TIMER_SERVICE); } }
/** * throw an exception when a method cannot be invoked * * @param methodType the method * @param invocationType the type of invocation that caused it to be disabled */ protected void throwException(MethodType methodType, InvocationType invocationType) { throw EjbLogger.ROOT_LOGGER.cannotCallMethod(methodType.getLabel(), invocationType.getLabel()); }
protected static void add(Set<DeniedSyncMethodKey> otherDenied, CurrentSynchronizationCallback.CallbackType callbackType, MethodType timerServiceMethod) { otherDenied.add(new DeniedSyncMethodKey(callbackType, timerServiceMethod)); }
@Override public void setRollbackOnly() throws IllegalStateException { AllowedMethodsInformation.checkAllowed(MethodType.SET_ROLLBACK_ONLY); super.setRollbackOnly(); }
@Override public int hashCode() { int result = invocationType != null ? invocationType.hashCode() : 0; result = 31 * result + (methodType != null ? methodType.hashCode() : 0); return result; } }
@Override protected void setup(Set<DeniedMethodKey> denied) { super.setup(denied); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_CALLER_PRINCIPLE); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.IS_CALLER_IN_ROLE); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_USER_TRANSACTION); add(denied, InvocationType.DEPENDENCY_INJECTION, MethodType.GET_TIMER_SERVICE); add(denied, InvocationType.POST_CONSTRUCT, MethodType.GET_CALLER_PRINCIPLE); add(denied, InvocationType.PRE_DESTROY, MethodType.GET_CALLER_PRINCIPLE); add(denied, InvocationType.POST_CONSTRUCT, MethodType.IS_CALLER_IN_ROLE); add(denied, InvocationType.PRE_DESTROY, MethodType.IS_CALLER_IN_ROLE); } }
/** * throw an exception when a method cannot be invoked * * @param methodType the method * @param callback the type of invocation that caused it to be disabled */ protected void throwException(MethodType methodType, CurrentSynchronizationCallback.CallbackType callback) { throw EjbLogger.ROOT_LOGGER.cannotCallMethod(methodType.getLabel(), callback.name()); }
@Override public boolean getRollbackOnly() throws IllegalStateException { AllowedMethodsInformation.checkAllowed(MethodType.GET_ROLLBACK_ONLY); return super.getRollbackOnly(); } }
@Override public UserTransaction getUserTransaction() throws IllegalStateException { AllowedMethodsInformation.checkAllowed(MethodType.GET_USER_TRANSACTION); return getComponent().getUserTransaction(); }
public Principal getCallerPrincipal() { AllowedMethodsInformation.checkAllowed(MethodType.GET_CALLER_PRINCIPLE); // per invocation return instance.getComponent().getCallerPrincipal(); }
/** * Asserts that the timer is <i>not</i> in any of the following states: * <ul> * <li>{@link TimerState#CANCELED}</li> * <li>{@link TimerState#EXPIRED}</li> * </ul> * * @throws javax.ejb.NoSuchObjectLocalException if the txtimer was canceled or has expired */ protected void assertTimerState() { if (timerState == TimerState.EXPIRED) throw EjbLogger.EJB3_TIMER_LOGGER.timerHasExpired(); if (timerState == TimerState.CANCELED) throw EjbLogger.EJB3_TIMER_LOGGER.timerWasCanceled(); AllowedMethodsInformation.checkAllowed(MethodType.TIMER_SERVICE_METHOD); }
@Override public TimerService getTimerService() throws IllegalStateException { AllowedMethodsInformation.checkAllowed(MethodType.GET_TIMER_SERVICE); if (stateful) { throw EjbLogger.ROOT_LOGGER.notAllowedFromStatefulBeans("getTimerService()"); } return super.getTimerService(); }
public UserTransaction getUserTransaction() throws IllegalStateException { AllowedMethodsInformation.checkAllowed(MethodType.GET_USER_TRANSACTION); return getComponent().getUserTransaction(); }
public boolean isCallerInRole(String roleName) { AllowedMethodsInformation.checkAllowed(MethodType.IS_CALLER_IN_ROLE); return instance.getComponent().isCallerInRole(roleName); }
private void assertTimerServiceState() { AllowedMethodsInformation.checkAllowed(MethodType.TIMER_SERVICE_METHOD); if (isLifecycleCallbackInvocation() && !this.isSingletonBeanInvocation()) { throw EJB3_TIMER_LOGGER.failToInvokeTimerServiceDoLifecycle(); } }