Search in sources :

Example 1 with JSONBuilder

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();
}
Also used : Jenkins(jenkins.model.Jenkins) AuthorizationStrategy(hudson.security.AuthorizationStrategy) FullControlOnceLoggedInAuthorizationStrategy(hudson.security.FullControlOnceLoggedInAuthorizationStrategy) FullControlOnceLoggedInAuthorizationStrategy(hudson.security.FullControlOnceLoggedInAuthorizationStrategy) JSONBuilder(net.sf.json.util.JSONBuilder) StringWriter(java.io.StringWriter)

Aggregations

AuthorizationStrategy (hudson.security.AuthorizationStrategy)1 FullControlOnceLoggedInAuthorizationStrategy (hudson.security.FullControlOnceLoggedInAuthorizationStrategy)1 StringWriter (java.io.StringWriter)1 Jenkins (jenkins.model.Jenkins)1 JSONBuilder (net.sf.json.util.JSONBuilder)1