isCreationAuthorized(session, message, channelName, Promise.from(result -> { if (result instanceof Authorizer.Result.Denied) { String denyReason = ((Authorizer.Result.Denied)result).getReason(); error(reply, "403:" + denyReason + ":channel_create_denied"); promise.succeed(reply);
isCreationAuthorized(session, message, subscription, Promise.from(creationResult -> { if (creationResult instanceof Authorizer.Result.Denied) { String denyReason = ((Authorizer.Result.Denied)creationResult).getReason(); error(reply, "403:" + denyReason + ":create_denied"); loop.leave(false);
private void handleMetaSubscribe2(ServerSessionImpl session, Mutable message, ServerChannelImpl channel, Promise<Boolean> promise) { ServerMessage.Mutable reply = message.getAssociated(); isSubscribeAuthorized(channel, session, message, Promise.from(subscribeResult -> { if (subscribeResult instanceof Authorizer.Result.Denied) { String denyReason = ((Authorizer.Result.Denied)subscribeResult).getReason(); error(reply, "403:" + denyReason + ":subscribe_denied"); promise.succeed(false); } else { if (channel.subscribe(session, message)) { reply.setSuccessful(true); promise.succeed(true); } else { error(reply, "403::subscribe_failed"); promise.succeed(false); } } }, promise::fail)); }
private void handle3(ServerSessionImpl session, ServerMessage.Mutable message, ServerChannelImpl channel, Promise<ServerMessage.Mutable> promise) { ServerMessage.Mutable reply = message.getAssociated(); if (channel.isMeta()) { publish(session, channel, message, true, Promise.from(published -> promise.succeed(reply), promise::fail)); } else { isPublishAuthorized(channel, session, message, Promise.from(result -> { if (result instanceof Authorizer.Result.Denied) { String denyReason = ((Authorizer.Result.Denied)result).getReason(); error(reply, "403:" + denyReason + ":publish denied"); promise.succeed(reply); } else { reply.setSuccessful(true); publish(session, channel, message, true, Promise.from(published -> promise.succeed(reply), promise::fail)); } }, promise::fail)); } }
/** * @param reason the reason for which the authorization is denied * @return a result that denies the authorization */ public static Result deny(String reason) { return new Denied(reason); }