use of io.kamax.mxisd.http.io.identity.SessionPhoneTokenRequestJson in project mxisd by kamax-io.
the class SessionStartHandler method handleRequest.
@Override
public void handleRequest(HttpServerExchange exchange) {
String medium = getPathVariable(exchange, "medium");
if (ThreePidMedium.Email.is(medium)) {
SessionEmailTokenRequestJson req = parseJsonTo(exchange, SessionEmailTokenRequestJson.class);
ThreePid threepid = new ThreePid(req.getMedium(), req.getValue());
respondJson(exchange, new RequestTokenResponse(mgr.create(getRemoteHostAddress(exchange), threepid, req.getSecret(), req.getAttempt(), req.getNextLink())));
} else if (ThreePidMedium.PhoneNumber.is(medium)) {
SessionPhoneTokenRequestJson req = parseJsonTo(exchange, SessionPhoneTokenRequestJson.class);
ThreePid threepid = new ThreePid(req.getMedium(), req.getValue());
String sessionId = mgr.create(getRemoteHostAddress(exchange), threepid, req.getSecret(), req.getAttempt(), req.getNextLink());
JsonObject res = new JsonObject();
res.addProperty("sid", sessionId);
res.addProperty(threepid.getMedium(), threepid.getAddress());
respond(exchange, res);
} else {
JsonObject obj = new JsonObject();
obj.addProperty("errcode", "M_INVALID_3PID_TYPE");
obj.addProperty("error", medium + " is not supported as a 3PID type");
respond(exchange, HttpStatus.SC_BAD_REQUEST, obj);
}
}
Aggregations