I am new to atmosphere infrastructure and websites.
I am developing a one-page application. As a first step, I want to implement basic authentication using third-party sites (third-party users) and Atmosphere websites (server-side).
For authentication, at the beginning I used regular servlets and saved the User bean in HttpSession. But later I realized that I cannot access the session attributes in the class (websocket service)
@AtmosphereService(broadcaster = JerseyBroadcaster.class)
So, I created another Login AtmosphereService in which the suspend method checks the user and, if the user exists, then saves the UserBean in ConcurrentMap with the uuid key, using the following method so that I can access in the future.
public void createSession(AtmosphereResource resource) {
logger.debug("Create session ({})", resource.uuid());
ConcurrentMap<String, Object> session = new ConcurrentHashMap<String, Object>();
ConcurrentMap<String, Object> prevSession = sessionsByUuid.putIfAbsent(resource.uuid(), session);
if (prevSession != null) {
logger.warn("Session already exists ({})", resource.uuid());
}
}
, . AngularJS , , - , .
$rootScope.$on("$routeChangeStart", function(event, next, current) {
aNext = next;
if (next.templateUrl != "./partials/login.html") {
if($rootScope.loggedUser !=null && $rootScope.loggedUser!=""){
$location.path(nextPage);
}else{
$rootScope.goLoginPage();
}
}
});
, , , $rootScope.loggedUser .
, , ajax , , , , $rootScope.loggedUser , .
, AtmosphereService , ( AtmosphereResource), AtmosphereService UserBean?