use of net.sf.json.util.JSONBuilder in project blueocean-plugin by jenkinsci.
the class BlueOceanConfigStatePreloader method getStateJson.
/**
* {@inheritDoc}
*/
@Override
public String getStateJson() {
StringWriter writer = new StringWriter();
Jenkins jenkins = Jenkins.getInstance();
String version = Jenkins.getVersion() != null ? Jenkins.getVersion().toString() : Jenkins.VERSION;
AuthorizationStrategy authorizationStrategy = jenkins.getAuthorizationStrategy();
boolean allowAnonymousRead = true;
if (authorizationStrategy instanceof FullControlOnceLoggedInAuthorizationStrategy) {
allowAnonymousRead = ((FullControlOnceLoggedInAuthorizationStrategy) authorizationStrategy).isAllowAnonymousRead();
}
new JSONBuilder(writer).object().key("version").value(getBlueOceanPluginVersion()).key("jenkinsConfig").object().key("version").value(version).key("security").object().key("enabled").value(jenkins.isUseSecurity()).key("loginUrl").value(jenkins.getSecurityRealm() == SecurityRealm.NO_AUTHENTICATION ? null : jenkins.getSecurityRealm().getLoginUrl()).key("authorizationStrategy").object().key("allowAnonymousRead").value(allowAnonymousRead).endObject().key("enableJWT").value(BlueOceanConfigProperties.BLUEOCEAN_FEATURE_JWT_AUTHENTICATION).endObject().endObject().key("features").object().key("organizations.enabled").value(Boolean.getBoolean("blueocean.features.organizations.enabled")).endObject().endObject();
return writer.toString();
}
Aggregations