Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,36 @@ public enum ErrorMessage {

INVALID_REQUEST("OAUTH-60001", "Invalid Request."),
Comment thread
RovinKYK marked this conversation as resolved.
ERROR_CONFLICT_REQUEST("41004", "Scope already exists."),
SCOPE_NOT_FOUND("41003", "Scope not found.");
SCOPE_NOT_FOUND("41003", "Scope not found."),

// Server Errors - 650xx
ERROR_CODE_ERROR_EXPORTING_SCOPE("65001",
"Unable to export the OIDC scope configurations.",
"Server Encountered an error while exporting the OIDC scope configurations."),
ERROR_CODE_ERROR_IMPORTING_SCOPE("65002",
"Unable to import the OIDC scope configurations.",
"Server Encountered an error while importing the OIDC scope configurations."),
ERROR_CODE_ERROR_UPDATING_SCOPE("65003",
"Unable to update the OIDC scope configurations.",
"Server Encountered an error while updating the OIDC scope configurations.");

private final String code;
private final String message;
private String description;

ErrorMessage(String code, String message) {

this.code = code;
this.message = message;
}

ErrorMessage(String code, String message, String description) {

this.code = code;
this.message = message;
this.description = description;
}
Comment thread
RovinKYK marked this conversation as resolved.

public String getCode() {

return code;
Expand All @@ -51,6 +70,11 @@ public String getMessage() {
return message;
}

public String getDescription() {

return description;
}

@Override
public String toString() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@

package org.wso2.carbon.identity.api.server.oidc.scope.management.v1;

import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.factories.OidcApiServiceFactory;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.InputStream;

import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.ErrorResponse;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.Scope;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.ScopeUpdateRequest;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.factories.OidcApiServiceFactory;

import javax.validation.Valid;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import io.swagger.annotations.*;

import javax.validation.constraints.*;

@Path("/oidc")
@Api(description = "The oidc API")

Expand Down Expand Up @@ -76,6 +82,25 @@ public Response deleteScope(@ApiParam(value = "scope name as the id",required=tr
return delegate.deleteScope(id );
}

@Valid
@GET
@Path("/scopes/{id}/export")

@Produces({ "application/json", "application/xml", "application/yaml" })
@ApiOperation(value = "Export an OIDC Scope in XML, YAML, or JSON format", notes = "", response = String.class, tags={ "OIDC Scope Endpoint", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful response", response = String.class),
@ApiResponse(code = 400, message = "Bad Request.", response = ErrorResponse.class),
@ApiResponse(code = 401, message = "Unauthorized.", response = ErrorResponse.class),
@ApiResponse(code = 403, message = "Resource Forbidden.", response = ErrorResponse.class),
@ApiResponse(code = 404, message = "Resource Not Found.", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "Internal Server Error.", response = ErrorResponse.class)
})
public Response exportScopeToFile(@ApiParam(value = "scope name as the id",required=true) @PathParam("id") String id, @Valid @ApiParam(value = "Content type of the file. " , allowableValues="application/json, application/xml, application/yaml, application/x-yaml, text/yaml, text/xml, text/json", defaultValue="application/yaml")@HeaderParam("Accept") String accept) {

return delegate.exportScopeToFile(id, accept );
}

@Valid
@GET
@Path("/scopes/{id}")
Expand Down Expand Up @@ -113,6 +138,25 @@ public Response getScopes() {
return delegate.getScopes();
}

@Valid
@POST
@Path("/scopes/import")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
@ApiOperation(value = "Import an OIDC Scope from XML, YAML, or JSON file", notes = "", response = Void.class, tags={ "OIDC Scope Endpoint", })
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Successfully imported", response = Void.class),
@ApiResponse(code = 400, message = "Invalid input request.", response = ErrorResponse.class),
@ApiResponse(code = 401, message = "Unauthorized.", response = ErrorResponse.class),
@ApiResponse(code = 403, message = "Resource Forbidden.", response = ErrorResponse.class),
@ApiResponse(code = 409, message = "Scope already Exists.", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "Internal Server Error.", response = ErrorResponse.class)
})
public Response importScopeFromFile(@Multipart(value = "file") InputStream fileInputStream,@Multipart(value = "file" ) Attachment fileDetail) {

return delegate.importScopeFromFile(fileInputStream, fileDetail );
}

@Valid
@PUT
@Path("/scopes/{id}")
Expand All @@ -132,4 +176,23 @@ public Response updateScope(@ApiParam(value = "scope name as the id",required=tr
return delegate.updateScope(id, scopeUpdateRequest );
}

@Valid
@PUT
@Path("/scopes/{id}/import")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
@ApiOperation(value = "Update an OIDC Scope from XML, YAML, or JSON file", notes = "", response = Void.class, tags={ "OIDC Scope Endpoint" })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully Updated.", response = Void.class),
@ApiResponse(code = 400, message = "Invalid input request.", response = ErrorResponse.class),
@ApiResponse(code = 401, message = "Unauthorized.", response = ErrorResponse.class),
@ApiResponse(code = 403, message = "Resource Forbidden.", response = ErrorResponse.class),
@ApiResponse(code = 404, message = "Resource Not Found.", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "Internal Server Error.", response = ErrorResponse.class)
})
public Response updateScopeFromFile(@ApiParam(value = "scope name as the ID",required=true) @PathParam("id") String id, @Multipart(value = "file") InputStream fileInputStream,@Multipart(value = "file" ) Attachment fileDetail) {

return delegate.updateScopeFromFile(id, fileInputStream, fileDetail );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.InputStream;
import java.util.List;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.ErrorResponse;
import java.io.File;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.Scope;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.ScopeUpdateRequest;
import javax.ws.rs.core.Response;
Expand All @@ -33,9 +35,15 @@ public interface OidcApiService {

public Response deleteScope(String id);

public Response exportScopeToFile(String id, String accept);

public Response getScope(String id);

public Response getScopes();

public Response importScopeFromFile(InputStream fileInputStream, Attachment fileDetail);

public Response updateScope(String id, ScopeUpdateRequest scopeUpdateRequest);

public Response updateScopeFromFile(String id, InputStream fileInputStream, Attachment fileDetail);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.File;
import javax.validation.constraints.*;


import io.swagger.annotations.*;
import java.util.Objects;
import javax.validation.Valid;
import javax.xml.bind.annotation.*;

public class FileUpload {

private File file;

/**
* File uploaded during import.
**/
public FileUpload file(File file) {

this.file = file;
return this;
}

@ApiModelProperty(required = true, value = "File uploaded during import.")
@JsonProperty("file")
@Valid
@NotNull(message = "Property file cannot be null.")

public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}



@Override
public boolean equals(java.lang.Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FileUpload fileUpload = (FileUpload) o;
return Objects.equals(this.file, fileUpload.file);
}

@Override
public int hashCode() {
return Objects.hash(file);
}

@Override
public String toString() {

StringBuilder sb = new StringBuilder();
sb.append("class FileUpload {\n");

sb.append(" file: ").append(toIndentedString(file)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {

if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
import io.swagger.annotations.*;
import java.util.Objects;
import javax.validation.Valid;
import javax.xml.bind.annotation.*;

public class Scope {

private String name;
private String displayName;
private String description;
Expand Down
Loading