use of com.github.openjson.JSONObject in project openmeetings by apache.
the class SignInPage method getToken.
private AuthInfo getToken(String code, OAuthServer server) throws IOException {
String requestTokenBaseUrl = server.getRequestTokenUrl();
// build url params to request auth token
String requestTokenParams = server.getRequestTokenAttributes();
requestTokenParams = prepareUrlParams(requestTokenParams, server.getClientId(), getRedirectUri(server), server.getClientSecret(), null, code);
// request auth token
HttpURLConnection urlConnection = (HttpURLConnection) new URL(requestTokenBaseUrl).openConnection();
prepareConnection(urlConnection);
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty("charset", UTF_8.name());
urlConnection.setRequestProperty("Content-Length", String.valueOf(requestTokenParams.length()));
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
DataOutputStream paramsOutputStream = new DataOutputStream(urlConnection.getOutputStream());
paramsOutputStream.writeBytes(requestTokenParams);
paramsOutputStream.flush();
String sourceResponse = IOUtils.toString(urlConnection.getInputStream(), UTF_8);
// parse json result
AuthInfo result = new AuthInfo();
JSONObject json = new JSONObject(sourceResponse);
if (json.has("access_token")) {
result.accessToken = json.getString("access_token");
}
if (json.has("refresh_token")) {
result.refreshToken = json.getString("refresh_token");
}
if (json.has("token_type")) {
result.tokenType = json.getString("token_type");
}
if (json.has("expires_in")) {
result.expiresIn = json.getLong("expires_in");
}
// access token must be specified
if (result.accessToken == null) {
log.error("Response doesn't contain access_token field:\n {}", sourceResponse);
return null;
}
return result;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class FileItemTree method onClick.
private void onClick(AjaxRequestTarget target, BaseFileItem f) {
String mod = getRequest().getRequestParameters().getParameterValue(PARAM_MOD).toOptionalString();
boolean shift = false, ctrl = false;
if (!Strings.isEmpty(mod)) {
JSONObject o = new JSONObject(mod);
shift = o.optBoolean(PARAM_SHIFT);
ctrl = o.optBoolean(PARAM_CTRL);
}
treePanel.select(f, target, shift, ctrl);
if (Type.Folder == f.getType() && getState(f) == State.COLLAPSED) {
this.expand(f);
} else {
treePanel.update(target, f);
}
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class WbConverter method processPath.
private static void processPath(Whiteboard wb, List<?> props) {
if (props.size() < 13) {
return;
}
String color = getColor(getInt(props, 4));
JSONObject o = setColor(init(wb, props), color, null).put(ATTR_TYPE, "path").put(ATTR_STROKE, props.get(3));
@SuppressWarnings("unchecked") List<List<?>> points = (List<List<?>>) props.get(1);
JSONArray path = new JSONArray();
for (List<?> point : points) {
if (path.length() == 0) {
path.put(new JSONArray(Arrays.asList("M", getInt(point, 1), getInt(point, 2))));
} else if (path.length() == points.size() - 1) {
path.put(new JSONArray(Arrays.asList("L", getInt(point, 3), getInt(point, 4))));
} else {
path.put(new JSONArray(Arrays.asList("Q", getInt(point, 1), getInt(point, 2), getInt(point, 3), getInt(point, 4))));
}
}
add(wb, o.put("path", path).put(ATTR_OPACITY, props.get(5)));
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class WbConverter method init.
private static JSONObject init(Whiteboard wb, List<?> props, boolean addDim) {
double left = ((Number) props.get(props.size() - 5)).doubleValue();
double top = ((Number) props.get(props.size() - 4)).doubleValue();
double w = ((Number) props.get(props.size() - 3)).doubleValue();
double h = ((Number) props.get(props.size() - 2)).doubleValue();
JSONObject o = new JSONObject().put(ATTR_SLIDE, 0);
if (addDim) {
o.put("left", left).put("top", top).put("width", w).put("height", h);
wb.setWidth((int) Math.max(wb.getWidth(), w + left));
wb.setHeight((int) Math.max(wb.getHeight(), h + top));
}
return o;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class WbConverter method processEllipse.
private static void processEllipse(Whiteboard wb, List<?> props) {
JSONObject o = processRect(wb, props);
if (o != null) {
o.put(ATTR_TYPE, "ellipse").put("rx", o.getDouble("width") / 2).put("ry", o.getDouble("height") / 2);
add(wb, o);
}
}
Aggregations