Search in sources :

Example 46 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ScopesResource method createOpenidScope.

@POST
@ProtectedApi(scopes = { ApiAccessConstants.SCOPES_WRITE_ACCESS })
public Response createOpenidScope(@Valid Scope scope) {
    log.debug("SCOPE to be added - scope = " + scope);
    log.debug("SCOPE to be added - scope.getId() = " + scope.getId());
    checkNotNull(scope.getId(), AttributeNames.ID);
    if (scope.getDisplayName() == null) {
        scope.setDisplayName(scope.getId());
    }
    String inum = UUID.randomUUID().toString();
    scope.setInum(inum);
    scope.setDn(scopeService.getDnForScope(inum));
    if (scope.getScopeType() == null) {
        scope.setScopeType(ScopeType.OAUTH);
    }
    if (ScopeType.UMA.getValue().equalsIgnoreCase(scope.getScopeType().getValue())) {
        scope.setScopeType(ScopeType.OAUTH);
    }
    scopeService.addScope(scope);
    Scope result = scopeService.getScopeByInum(inum);
    log.debug("SCOPE added is - " + result.getId());
    return Response.status(Response.Status.CREATED).entity(result).build();
}
Also used : Scope(io.jans.as.persistence.model.Scope) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 47 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ScopesResource method updateScope.

@PUT
@ProtectedApi(scopes = { ApiAccessConstants.SCOPES_WRITE_ACCESS })
public Response updateScope(@Valid Scope scope) {
    log.debug("SCOPE to be updated - scope = " + scope.getId());
    String inum = scope.getInum();
    checkNotNull(inum, SCOPE);
    Scope existingScope = scopeService.getScopeByInum(inum);
    checkResourceNotNull(existingScope, SCOPE);
    if (scope.getScopeType() == null) {
        scope.setScopeType(ScopeType.OAUTH);
    }
    if (ScopeType.UMA.getValue().equalsIgnoreCase(scope.getScopeType().getValue())) {
        scope.setScopeType(ScopeType.OAUTH);
    }
    scope.setInum(existingScope.getInum());
    scope.setBaseDn(scopeService.getDnForScope(inum));
    scopeService.updateScope(scope);
    Scope result = scopeService.getScopeByInum(inum);
    log.debug("SCOPE updated is - " + result.getId());
    return Response.ok(result).build();
}
Also used : Scope(io.jans.as.persistence.model.Scope) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 48 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ScopesResource method getScopeById.

@GET
@ProtectedApi(scopes = { ApiAccessConstants.SCOPES_READ_ACCESS })
@Path(ApiConstants.INUM_PATH)
public Response getScopeById(@NotNull @PathParam(ApiConstants.INUM) String inum) {
    log.debug("SCOPES to be fetched - inum = " + inum);
    Scope scope = scopeService.getScopeByInum(inum);
    checkResourceNotNull(scope, SCOPE);
    return Response.ok(scope).build();
}
Also used : Scope(io.jans.as.persistence.model.Scope) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 49 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class CouchbaseConfigurationResource method test.

@POST
@Path(ApiConstants.TEST)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_COUCHBASE_READ_ACCESS })
public Response test(@Valid @NotNull CouchbaseConnectionConfiguration conf) {
    log.debug("COUCHBASE to be tested - conf = " + conf);
    Properties properties = new Properties();
    properties.put("couchbase.servers", Joiner.on(",").join(conf.getServers()));
    properties.put("couchbase.auth.userName", conf.getUserName());
    properties.put("couchbase.auth.userPassword", conf.getUserPassword());
    properties.put("couchbase.auth.buckets", Joiner.on(",").join(conf.getBuckets()));
    properties.put("couchbase.bucket.default", conf.getDefaultBucket());
    properties.put("couchbase.password.encryption.method", conf.getPasswordEncryptionMethod());
    CouchbaseConnectionProvider connectionProvider = new CouchbaseConnectionProvider(properties, DefaultCouchbaseEnvironment.create());
    return Response.ok(connectionProvider.isConnected()).build();
}
Also used : CouchbaseConnectionProvider(io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider) Properties(java.util.Properties) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 50 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class CouchbaseConfigurationResource method patch.

@PATCH
@Path(ApiConstants.NAME_PARAM_PATH)
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_COUCHBASE_WRITE_ACCESS })
public Response patch(@PathParam(ApiConstants.NAME) String name, @NotNull String requestString) throws Exception {
    log.debug("COUCHBASE to be patched - name = " + name + " , requestString = " + requestString);
    CouchbaseConnectionConfiguration conf = findByName(name);
    log.info("Patch configuration by name " + name);
    conf = Jackson.applyPatch(requestString, conf);
    couchbaseConfService.save(conf);
    return Response.ok(conf).build();
}
Also used : CouchbaseConnectionConfiguration(io.jans.orm.couchbase.model.CouchbaseConnectionConfiguration) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Aggregations

ProtectedApi (io.jans.configapi.core.rest.ProtectedApi)52 Client (io.jans.as.common.model.registration.Client)6 Conf (io.jans.as.model.config.Conf)6 Scope (io.jans.as.persistence.model.Scope)5 GluuConfiguration (io.jans.as.persistence.model.configuration.GluuConfiguration)5 GluuAttribute (io.jans.model.GluuAttribute)5 WebKeysConfiguration (io.jans.as.model.config.WebKeysConfiguration)4 UmaResource (io.jans.as.model.uma.persistence.UmaResource)3 SmtpConfiguration (io.jans.model.SmtpConfiguration)3 CustomScript (io.jans.model.custom.script.model.CustomScript)3 AppConfiguration (io.jans.as.model.configuration.AppConfiguration)2 JSONWebKey (io.jans.as.model.jwk.JSONWebKey)2 LicenseResponse (io.jans.ca.plugin.adminui.model.auth.LicenseResponse)2 ApplicationException (io.jans.ca.plugin.adminui.model.exception.ApplicationException)2 ScimAppConfiguration (io.jans.configapi.plugin.scim.model.config.ScimAppConfiguration)2 Properties (java.util.Properties)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 GluuOrganization (io.jans.as.persistence.model.GluuOrganization)1 OAuth2ConfigResponse (io.jans.ca.plugin.adminui.model.auth.OAuth2ConfigResponse)1 AUIConfiguration (io.jans.ca.plugin.adminui.model.config.AUIConfiguration)1