use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzyZoneContextsTest method test.
@Test
public void test() {
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
EzySimpleZone zone = new EzySimpleZone();
when(zoneContext.getZone()).thenReturn(zone);
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
zone.setSetting(zoneSetting);
assert EzyZoneContexts.getUserManagementSetting(zoneContext) == zoneSetting.getUserManagement();
}
use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzyLoginController method handle.
@Override
public void handle(EzyServerContext ctx, EzyLoginRequest request) {
try {
EzySession session = request.getSession();
EzyLoginParams params = request.getParams();
EzyZoneContext zoneContext = ctx.getZoneContext(params.getZoneName());
EzyUserLoginEvent loginEvent = newLoginEvent(session, params);
try {
control(ctx, zoneContext, loginEvent);
} finally {
loginEvent.release();
}
} catch (EzyLoginErrorException e) {
processException(ctx, request.getSession(), e);
throw e;
} catch (EzyMaxUserException e) {
processException(ctx, request.getSession(), maximumUsers(e));
throw e;
} catch (EzyZoneNotFoundException e) {
processException(ctx, request.getSession(), zoneNotFound(e));
throw e;
} catch (Exception e) {
processException(ctx, request.getSession(), serverError(e));
throw e;
}
}
use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzyLoginProcessor method newLoginResponse.
protected EzyResponse newLoginResponse(EzyZoneContext zoneContext, EzyUser user, EzyData loginOutputData) {
EzyZoneSetting zoneSetting = getZoneSetting(zoneContext);
EzyLoginParams params = new EzyLoginParams();
params.setData(loginOutputData);
params.setUserId(user.getId());
params.setUsername(user.getName());
params.setZoneId(zoneSetting.getId());
params.setZoneName(zoneSetting.getName());
return new EzyLoginResponse(params);
}
use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzyRequestPluginController method handle.
@Override
public void handle(EzyServerContext ctx, EzyRequestPluginRequest request) {
EzyRequestPluginParams params = request.getParams();
EzyUser user = request.getUser();
EzyZoneContext zoneCtx = ctx.getZoneContext(user.getZoneId());
EzyPluginContext pluginCtx = getPluginContext(zoneCtx, params);
EzyPlugin plugin = pluginCtx.getPlugin();
EzyPluginRequestController requestController = plugin.getRequestController();
EzyUserRequestPluginEvent event = newRequestPluginEvent(request);
requestController.handle(pluginCtx, event);
}
use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzyAccessAppController method doHandle.
protected void doHandle(EzyServerContext ctx, EzyAccessAppRequest request) {
EzyUser user = request.getUser();
int zoneId = user.getZoneId();
EzyAccessAppParams params = request.getParams();
EzyZoneContext zoneContext = ctx.getZoneContext(zoneId);
EzyAppContext appContext = zoneContext.getAppContext(params.getAppName());
EzyApplication app = appContext.getApp();
EzyAppSetting appSetting = app.getSetting();
EzyAppUserManager appUserManger = app.getUserManager();
EzySession session = request.getSession();
String username = user.getName();
Lock lock = appUserManger.getLock(username);
lock.lock();
try {
boolean hasNotAccessed = !appUserManger.containsUser(user);
if (hasNotAccessed) {
checkAppUserMangerAvailable(appUserManger);
}
EzyUserAccessAppEvent accessAppEvent = new EzySimpleUserAccessAppEvent(user);
appContext.handleEvent(EzyEventType.USER_ACCESS_APP, accessAppEvent);
if (hasNotAccessed) {
addUser(appUserManger, user, appSetting);
EzyUserAccessedAppEvent accessedAppEvent = new EzySimpleUserAccessedAppEvent(user);
appContext.handleEvent(EzyEventType.USER_ACCESSED_APP, accessedAppEvent);
}
EzyArray output = accessAppEvent.getOutput();
EzyResponse accessAppResponse = newAccessAppResponse(appSetting, output);
ctx.send(accessAppResponse, session, false);
} finally {
lock.unlock();
appUserManger.removeLock(username);
}
}
Aggregations