use of io.divide.shared.transitory.Credentials in project divide by HiddenStage.
the class AuthServerLogic method recieveUserData.
public void recieveUserData(String userId, Map<String, ?> data) throws DAOException {
Credentials user = getUserById(userId);
user.removeAll();
user.putAll(data);
dao.save(user);
}
use of io.divide.shared.transitory.Credentials in project divide by HiddenStage.
the class AuthenticationEndpoint method getUserFromToken.
@GET
@Path("/from/{token}")
@Produces(MediaType.APPLICATION_JSON)
public Response getUserFromToken(@Context ContainerRequestContext context, @PathParam("token") String token) {
try {
logger.warning("getUserFromToken");
Credentials user = authServerLogic.getUserFromAuthToken(token);
context.setSecurityContext(new UserContext(context.getUriInfo(), user));
return Response.ok(user).build();
} catch (ServerDAO.DAOException e) {
e.printStackTrace();
logger.severe(ExceptionUtils.getStackTrace(e));
return fromDAOExpection(e);
}
}
use of io.divide.shared.transitory.Credentials in project divide by HiddenStage.
the class AuthenticationEndpoint method userSignUp.
/*
* Saves user credentials
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response userSignUp(@Context ContainerRequestContext context, Credentials credentials) {
try {
Credentials toSave = authServerLogic.userSignUp(credentials);
context.setSecurityContext(new UserContext(context.getUriInfo(), toSave));
logger.info("SignUp Successful. Returning: " + toSave);
return ok(toSave);
} catch (ServerDAO.DAOException e) {
logger.severe(ExceptionUtils.getStackTrace(e));
return fromDAOExpection(e);
} catch (Exception e) {
logger.severe(ExceptionUtils.getStackTrace(e));
return Response.serverError().build();
}
}
use of io.divide.shared.transitory.Credentials in project divide by HiddenStage.
the class PushEndpoint method unregister.
@DELETE
public Response unregister(@Context Session session) {
try {
Credentials credentials = session.getUser();
credentials.setPushMessagingKey("");
dao.save(credentials);
} catch (ServerDAO.DAOException e) {
logger.severe(ExceptionUtils.getStackTrace(e));
return fromDAOExpection(e);
}
return Response.ok().build();
}
use of io.divide.shared.transitory.Credentials in project divide by HiddenStage.
the class PushEndpoint method sendMessageToDevice.
private String sendMessageToDevice(String email, String input) throws ServerDAO.DAOException, IOException {
Credentials user = getUserByEmail(dao, email);
Sender sender = new Sender(keyManager.getPushKey());
Message message = new Message.Builder().addData("body", input).build();
MulticastResult result = sender.send(message, Arrays.asList(user.getPushMessagingKey()), 5);
System.out.println("Result = " + result);
return result.toString();
}
Aggregations