Search in sources :

Example 1 with EzyRequestAppRequest

use of com.tvd12.ezyfoxserver.request.EzyRequestAppRequest in project ezyfox-server by youngmonkeys.

the class EzyServerUserInterceptorTest method test.

@Test(expectedExceptions = { EzyNotAuthorizedException.class })
public void test() throws Exception {
    EzyServerContext context = newServerContext();
    EzyServerUserInterceptor interceptor = new EzyServerUserInterceptor();
    EzyRequestAppRequest request = new EzySimpleRequestAppRequest();
    interceptor.intercept(context, request);
}
Also used : EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzySimpleRequestAppRequest(com.tvd12.ezyfoxserver.request.EzySimpleRequestAppRequest) EzyRequestAppRequest(com.tvd12.ezyfoxserver.request.EzyRequestAppRequest) EzyServerUserInterceptor(com.tvd12.ezyfoxserver.interceptor.EzyServerUserInterceptor) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Example 2 with EzyRequestAppRequest

use of com.tvd12.ezyfoxserver.request.EzyRequestAppRequest in project ezyfox-server by youngmonkeys.

the class EzyRequestAppController method handle.

@Override
public void handle(EzyServerContext ctx, EzyRequestAppRequest request) {
    EzyRequestAppParams params = request.getParams();
    EzyAppContext appCtx = ctx.getAppContext(params.getAppId());
    EzyApplication app = appCtx.getApp();
    EzyAppRequestController requestController = app.getRequestController();
    // user manager for checking, user must be managed
    EzyUserManager userManger = appCtx.getApp().getUserManager();
    EzyUser user = request.getUser();
    // check user joined app or not to prevent spam request
    boolean hasAccessed = userManger.containsUser(user);
    if (hasAccessed) {
        // redirect handling to app
        EzyUserRequestAppEvent event = newRequestAppEvent(request);
        requestController.handle(appCtx, event);
    } else {
        EzySession session = request.getSession();
        responseRequestAppError(ctx, session);
    }
}
Also used : EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyRequestAppParams(com.tvd12.ezyfoxserver.request.EzyRequestAppParams) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyAppRequestController(com.tvd12.ezyfoxserver.app.EzyAppRequestController) EzyUserManager(com.tvd12.ezyfoxserver.wrapper.EzyUserManager) EzyUserRequestAppEvent(com.tvd12.ezyfoxserver.event.EzyUserRequestAppEvent) EzySession(com.tvd12.ezyfoxserver.entity.EzySession)

Aggregations

EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)1 EzyAppRequestController (com.tvd12.ezyfoxserver.app.EzyAppRequestController)1 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)1 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)1 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)1 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)1 EzyUserRequestAppEvent (com.tvd12.ezyfoxserver.event.EzyUserRequestAppEvent)1 EzyServerUserInterceptor (com.tvd12.ezyfoxserver.interceptor.EzyServerUserInterceptor)1 EzyRequestAppParams (com.tvd12.ezyfoxserver.request.EzyRequestAppParams)1 EzyRequestAppRequest (com.tvd12.ezyfoxserver.request.EzyRequestAppRequest)1 EzySimpleRequestAppRequest (com.tvd12.ezyfoxserver.request.EzySimpleRequestAppRequest)1 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)1 EzyUserManager (com.tvd12.ezyfoxserver.wrapper.EzyUserManager)1 Test (org.testng.annotations.Test)1