forked from loafle/openapi-generator-original
JAXRS server :: Inject SecurityContext into every operation
This commit is contained in:
parent
76de987cd2
commit
f9185c3f6f
@ -19,7 +19,9 @@ import java.io.InputStream;
|
|||||||
import com.sun.jersey.core.header.FormDataContentDisposition;
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.SecurityContext;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
|
|
||||||
@Path("/{{baseName}}")
|
@Path("/{{baseName}}")
|
||||||
@ -47,12 +49,10 @@ public class {{classname}} {
|
|||||||
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},
|
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},
|
||||||
{{/hasMore}}{{/responses}} })
|
{{/hasMore}}{{/responses}} })
|
||||||
|
|
||||||
public Response {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext)
|
||||||
{{/hasMore}}{{/allParams}})
|
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
return delegate.{{operationId}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}});
|
return delegate.{{nickname}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
|
||||||
|
@ -17,12 +17,13 @@ import com.sun.jersey.core.header.FormDataContentDisposition;
|
|||||||
import com.sun.jersey.multipart.FormDataParam;
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public abstract class {{classname}}Service {
|
public abstract class {{classname}}Service {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
public abstract Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}},{{/hasMore}}{{/allParams}})
|
public abstract Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}},{{/allParams}}SecurityContext securityContext)
|
||||||
throws NotFoundException;
|
throws NotFoundException;
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,14 @@ import com.sun.jersey.core.header.FormDataContentDisposition;
|
|||||||
import com.sun.jersey.multipart.FormDataParam;
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}}ServiceImpl extends {{classname}}Service {
|
public class {{classname}}ServiceImpl extends {{classname}}Service {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
@Override
|
@Override
|
||||||
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}},{{/hasMore}}{{/allParams}})
|
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}},{{/allParams}}SecurityContext securityContext)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user