floralvikings / jenjin-io Goto Github PK
View Code? Open in Web Editor NEWIO Utilities for Client/Server Connections
Home Page: http://floralvikings.github.io/jenjin-io/
License: MIT License
IO Utilities for Client/Server Connections
Home Page: http://floralvikings.github.io/jenjin-io/
License: MIT License
It would be excellent to have an (optional) way of making a contextual task conditional; I'm thinking something like a Predicate<Message>
that can be passed along with each contextual task, and the task will only execute if the predicate evaluates to true.
I'm thinking this could really help #6 because it would allow for completely ignoring deauthentication requests when not already authenticated and whatnot, and also because it would give a pretty convenient way to inject the Authenticator
into the execution thread:
connectionBuilder.withContextualTask( (context) -> {
if(!context.isAuthenticated) {
authenticator.authenticate(context);
}
}, (message) -> message instanceof AuthenticationRequest);
Given the following:
ExecutionContext
It seems reasonable to have an interface for authentication, something like the following
public interface Authenticator<T extends ExecutionContext>
{
/**
* Authenticate the user with the given credentials, populating the given ExecutionContext
* IF AND ONLY IF the authentication is successful.
*
* @param context The context that will be populated with user data IF the authentication
* is successful. If the authentication is not successful, the context should remain
* unmodified.
*
* @param credentials One or more Strings identifying the user.
*
* @return true if the authentication was a success and the context was populated with user
* data, false if the authentication was a failure and the context was not modified.
*
* @throws AuthenticationException If there is an unexpected exception when handling the
* authentication.
*/
bool authenticate(T context, String... credentials) throws AuthenticationException;
/**
* Deauthenticate the user with the given credentials, depopulating the given
* ExecutionContext IF AND ONLY IF the authentication is successful.
*
* @param context The context that will be depopulated with user data IF the
* deauthentication is successful. If the deauthentication is not successful,
* the context should remain unmodified.
* (Maybe not, just a rough draft)
*
* @param credentials One or more Strings identifying the user.
*
* @throws AuthenticationException If there is an unexpected exception when handling the
* authentication.
*/
void deauthenticate(T context, String... credentials) throws AuthenticationException;
/**
* Update the user with the given credentials from the given
* ExecutionContext.
*
* @param context The context that will be used to update user data.
* The context should remain unmodified.
*
* @param credentials One or more Strings identifying the user.
*
* @throws AuthenticationException If there is an unexpected exception when handling the
* update.
*/
void update(T context, String... credentials) throws AuthenticationException;
}
Since the generic type of Server
is also <T extends ExecutionContext>
it should be an enormous pain drop right in without causing problems.
There'd have to be a way to access it (preferably from a Message
containing the credentials); maybe a new interface like AuthenticationRequest
or something that has a method returning credentials? That way a Message
implementation could implement both interfaces.
That would result in some gross casting, though, so maybe it should be implemented as a part of the ExecutionContext?
Anyway, definitely an idea worth exploring.
Only seen in CI builds, likely due to the fact that the test contains a large number of threads and blocking. Would be better to use timeouts instead.
We can adapt message from a different type of message; why not to a different type of message?
Obviously this can be default empty, and the existing adaptFrom
argument could be made optional as well.
Currently the Message
and Connection
classes make decent use of generics; both of the (.*)ConnectionBuilder
classes, the ServerBuilder
class, and the Server
class could use a boost in this department, mainly to avoid ugly casting of ExecutionContext
arguments in Lambdas.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.