io.swagger.annotations.Authorization类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(18.0k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中io.swagger.annotations.Authorization类的一些代码示例,展示了Authorization类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authorization类的具体详情如下:
包路径:io.swagger.annotations.Authorization
类名称:Authorization

Authorization介绍

暂无

代码示例

代码示例来源:origin: apache/nifi

@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("revert-requests/{id}")
@ApiOperation(
    value = "Returns the Revert Request with the given ID",
    response = VersionedFlowUpdateRequestEntity.class,
    notes = "Returns the Revert Request with the given ID. Once a Revert Request has been created by performing a POST to /versions/revert-requests/process-groups/{id}, "
      + "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the "
      + "current state of the request, and any failures. "
      + NON_GUARANTEED_ENDPOINT,
    authorizations = {
      @Authorization(value = "Only the user that submitted the request can get it")
    })
@ApiResponses(value = {
  @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
  @ApiResponse(code = 401, message = "Client could not be authenticated."),
  @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
  @ApiResponse(code = 404, message = "The specified resource could not be found."),
  @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
})
public Response getRevertRequest(@ApiParam("The ID of the Revert Request") @PathParam("id") final String revertRequestId) {
  return retrieveRequest("revert-requests", revertRequestId);
}

代码示例来源:origin: wso2/msf4j

if (apiOperation.hidden()) {
  return null;
if (!"".equals(apiOperation.nickname())) {
  operationId = apiOperation.nickname();
  List<SecurityRequirement> securities = new ArrayList<>();
  for (Authorization auth : apiOperation.authorizations()) {
    if (auth.value() != null && !"".equals(auth.value())) {
      SecurityRequirement security = new SecurityRequirement();
      security.setName(auth.value());
      AuthorizationScope[] scopes = auth.scopes();
      for (AuthorizationScope scope : scopes) {
        if (scope.scope() != null && !"".equals(scope.scope())) {
final Consumes consumes = ReflectionUtils.getAnnotation(method, Consumes.class);
if (consumes != null) {
  for (String mediaType : ReaderUtils.splitContentValues(consumes.value())) {
    operation.consumes(mediaType);
apiResponses.addAll(Arrays.asList(responseAnnotation.value()));
ApiResponses exceptionResponses = ReflectionUtils.getAnnotation(exceptionType, ApiResponses.class);
if (exceptionResponses != null) {
  apiResponses.addAll(Arrays.asList(exceptionResponses.value()));

代码示例来源:origin: kongchen/swagger-maven-plugin

if (apiOperation.hidden()) {
  return null;
if (!apiOperation.nickname().isEmpty()) {
  operationId = apiOperation.nickname();
for (Authorization auth : apiOperation.authorizations()) {
  if (!auth.value().isEmpty()) {
    SecurityRequirement security = new SecurityRequirement();
    security.setName(auth.value());
    for (AuthorizationScope scope : auth.scopes()) {
      if (!scope.scope().isEmpty()) {
        security.addScope(scope.scope());
for (String mediaType : consumes.value()) {
  operation.consumes(mediaType);
for (String mediaType : produces.value()) {
  operation.produces(mediaType);

代码示例来源:origin: wso2/msf4j

if (auth.value() != null && !"".equals(auth.value())) {
      SecurityRequirement security = new SecurityRequirement();
      security.setName(auth.value());
      AuthorizationScope[] scopes = auth.scopes();
      for (AuthorizationScope scope : scopes) {
        if (scope.scope() != null && !"".equals(scope.scope())) {
  consumes = ReaderUtils.splitContentValues(cls.getAnnotation(Consumes.class).value());
  produces = ReaderUtils.splitContentValues(cls.getAnnotation(Produces.class).value());
List<ApiResponse> classApiResponses = new ArrayList<>();
if (classResponseAnnotation != null) {
  classApiResponses.addAll(Arrays.asList(classResponseAnnotation.value()));
      for (Scheme scheme : parseSchemes(apiOperation.protocols())) {
        operation.scheme(scheme);
    if (httpMethod != null) {
      if (apiOperation != null) {
        for (String tag : apiOperation.tags()) {
          if (!"".equals(tag)) {
            operation.tag(tag);
             .putAll(BaseReaderUtils.parseExtensions(apiOperation.extensions()));

代码示例来源:origin: kongchen/swagger-maven-plugin

if (apiOperation.hidden()) {
  return null;
if (!apiOperation.nickname().isEmpty()) {
  operationId = apiOperation.nickname();
for (Authorization auth : apiOperation.authorizations()) {
  if (!auth.value().isEmpty()) {
    SecurityRequirement security = new SecurityRequirement();
    security.setName(auth.value());
    for (AuthorizationScope scope : auth.scopes()) {
      if (!scope.scope().isEmpty()) {
        security.addScope(scope.scope());

代码示例来源:origin: kongchen/swagger-maven-plugin

protected List<SecurityRequirement> getSecurityRequirements(Api api) {
  List<SecurityRequirement> securities = new ArrayList<>();
  if(api == null) {
    return securities;
  }
  for (Authorization auth : api.authorizations()) {
    if (auth.value().isEmpty()) {
      continue;
    }
    SecurityRequirement security = new SecurityRequirement();
    security.setName(auth.value());
    for (AuthorizationScope scope : auth.scopes()) {
      if (!scope.scope().isEmpty()) {
        security.addScope(scope.scope());
      }
    }
    securities.add(security);
  }
  return securities;
}

代码示例来源:origin: io.springfox/springfox-swagger-common

@Override
 public boolean apply(Authorization input) {
  return !Strings.isNullOrEmpty(input.value());
 }
});

代码示例来源:origin: org.wso2.msf4j/msf4j-swagger

if (apiOperation.hidden()) {
  return null;
if (!"".equals(apiOperation.nickname())) {
  operationId = apiOperation.nickname();
  List<SecurityRequirement> securities = new ArrayList<>();
  for (Authorization auth : apiOperation.authorizations()) {
    if (auth.value() != null && !"".equals(auth.value())) {
      SecurityRequirement security = new SecurityRequirement();
      security.setName(auth.value());
      AuthorizationScope[] scopes = auth.scopes();
      for (AuthorizationScope scope : scopes) {
        if (scope.scope() != null && !"".equals(scope.scope())) {
final Consumes consumes = ReflectionUtils.getAnnotation(method, Consumes.class);
if (consumes != null) {
  for (String mediaType : ReaderUtils.splitContentValues(consumes.value())) {
    operation.consumes(mediaType);
apiResponses.addAll(Arrays.asList(responseAnnotation.value()));
ApiResponses exceptionResponses = ReflectionUtils.getAnnotation(exceptionType, ApiResponses.class);
if (exceptionResponses != null) {
  apiResponses.addAll(Arrays.asList(exceptionResponses.value()));

代码示例来源:origin: org.wso2.msf4j/msf4j-swagger

if (auth.value() != null && !"".equals(auth.value())) {
      SecurityRequirement security = new SecurityRequirement();
      security.setName(auth.value());
      AuthorizationScope[] scopes = auth.scopes();
      for (AuthorizationScope scope : scopes) {
        if (scope.scope() != null && !"".equals(scope.scope())) {
  consumes = ReaderUtils.splitContentValues(cls.getAnnotation(Consumes.class).value());
  produces = ReaderUtils.splitContentValues(cls.getAnnotation(Produces.class).value());
List<ApiResponse> classApiResponses = new ArrayList<>();
if (classResponseAnnotation != null) {
  classApiResponses.addAll(Arrays.asList(classResponseAnnotation.value()));
      for (Scheme scheme : parseSchemes(apiOperation.protocols())) {
        operation.scheme(scheme);
    if (httpMethod != null) {
      if (apiOperation != null) {
        for (String tag : apiOperation.tags()) {
          if (!"".equals(tag)) {
            operation.tag(tag);
             .putAll(BaseReaderUtils.parseExtensions(apiOperation.extensions()));

代码示例来源:origin: yangfuhai/jboot

private static List<SecurityRequirement> parseAuthorizations(Authorization[] authorizations) {
  final List<SecurityRequirement> result = new ArrayList<SecurityRequirement>();
  for (Authorization auth : authorizations) {
    if (StringUtils.isNotEmpty(auth.value())) {
      final SecurityRequirement security = new SecurityRequirement();
      security.setName(auth.value());
      for (AuthorizationScope scope : auth.scopes()) {
        if (StringUtils.isNotEmpty(scope.scope())) {
          security.addScope(scope.scope());
        }
      }
      result.add(security);
    }
  }
  return result;
}

代码示例来源:origin: apache/nifi

@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("update-requests/{id}")
@ApiOperation(
    value = "Returns the Update Request with the given ID",
    response = VersionedFlowUpdateRequestEntity.class,
    notes = "Returns the Update Request with the given ID. Once an Update Request has been created by performing a POST to /versions/update-requests/process-groups/{id}, "
      + "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the "
      + "current state of the request, and any failures. "
      + NON_GUARANTEED_ENDPOINT,
    authorizations = {
      @Authorization(value = "Only the user that submitted the request can get it")
    })
@ApiResponses(value = {
  @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
  @ApiResponse(code = 401, message = "Client could not be authenticated."),
  @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
  @ApiResponse(code = 404, message = "The specified resource could not be found."),
  @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
})
public Response getUpdateRequest(@ApiParam("The ID of the Update Request") @PathParam("id") final String updateRequestId) {
  return retrieveRequest("update-requests", updateRequestId);
}

代码示例来源:origin: io.swagger/swagger-jaxrs

if (apiOperation.hidden()) {
  return null;
if (apiOperation.ignoreJsonView()) {
  jsonViewAnnotation = null;
if (!apiOperation.nickname().isEmpty()) {
  operationId = apiOperation.nickname();
for (Authorization auth : apiOperation.authorizations()) {
  if (!auth.value().isEmpty()) {
    SecurityRequirement security = new SecurityRequirement();
    security.setName(auth.value());
    for (AuthorizationScope scope : auth.scopes()) {
      if (!scope.scope().isEmpty()) {
        security.addScope(scope.scope());
final Consumes consumes = ReflectionUtils.getAnnotation(method, Consumes.class);
if (consumes != null) {
  for (String mediaType : ReaderUtils.splitContentValues(consumes.value())) {
    operation.consumes(mediaType);
apiResponses.addAll(Arrays.asList(responseAnnotation.value()));
ApiResponses exceptionResponses = ReflectionUtils.getAnnotation(exceptionType, ApiResponses.class);
if (exceptionResponses != null) {
  apiResponses.addAll(Arrays.asList(exceptionResponses.value()));

代码示例来源:origin: io.swagger/swagger-jaxrs

if (auth.value() != null && !auth.value().isEmpty()) {
    SecurityRequirement security = new SecurityRequirement();
    security.setName(auth.value());
    for (AuthorizationScope scope : auth.scopes()) {
      if (scope.scope() != null && !scope.scope().isEmpty()) {
        security.addScope(scope.scope());
  consumes = ReaderUtils.splitContentValues(cls.getAnnotation(Consumes.class).value());
  produces = ReaderUtils.splitContentValues(cls.getAnnotation(Produces.class).value());
List<ApiResponse> classApiResponses = new ArrayList<ApiResponse>();
if (classResponseAnnotation != null) {
  classApiResponses.addAll(Arrays.asList(classResponseAnnotation.value()));
      for (Scheme scheme : parseSchemes(apiOperation.protocols())) {
        operation.scheme(scheme);
    if (httpMethod != null) {
      if (apiOperation != null) {
        for (String tag : apiOperation.tags()) {
          if (!"".equals(tag)) {
            operation.tag(tag);
        operation.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(apiOperation.extensions()));

代码示例来源:origin: io.springfox/springfox-swagger-common

String value = authorization.value();
AuthorizationScope[] scopes = authorization.scopes();
List<springfox.documentation.service.AuthorizationScope> authorizationScopeList = newArrayList();
for (AuthorizationScope authorizationScope : scopes) {

代码示例来源:origin: apache/nifi

@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("revert-requests/{id}")
@ApiOperation(
    value = "Deletes the Revert Request with the given ID",
    response = VersionedFlowUpdateRequestEntity.class,
    notes = "Deletes the Revert Request with the given ID. After a request is created via a POST to /versions/revert-requests/process-groups/{id}, it is expected "
      + "that the client will properly clean up the request by DELETE'ing it, once the Revert process has completed. If the request is deleted before the request "
      + "completes, then the Revert request will finish the step that it is currently performing and then will cancel any subsequent steps. "
      + NON_GUARANTEED_ENDPOINT,
    authorizations = {
      @Authorization(value = "Only the user that submitted the request can remove it")
    })
@ApiResponses(value = {
  @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
  @ApiResponse(code = 401, message = "Client could not be authenticated."),
  @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
  @ApiResponse(code = 404, message = "The specified resource could not be found."),
  @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
})
public Response deleteRevertRequest(
    @ApiParam(
        value = "Acknowledges that this node is disconnected to allow for mutable requests to proceed.",
        required = false
    )
    @QueryParam(DISCONNECTED_NODE_ACKNOWLEDGED) @DefaultValue("false") final Boolean disconnectedNodeAcknowledged,
    @ApiParam("The ID of the Revert Request") @PathParam("id") final String revertRequestId) {
  return deleteRequest("revert-requests", revertRequestId, disconnectedNodeAcknowledged.booleanValue());
}

代码示例来源:origin: apache/nifi

@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("update-requests/{id}")
@ApiOperation(
    value = "Deletes the Update Request with the given ID",
    response = VersionedFlowUpdateRequestEntity.class,
    notes = "Deletes the Update Request with the given ID. After a request is created via a POST to /versions/update-requests/process-groups/{id}, it is expected "
      + "that the client will properly clean up the request by DELETE'ing it, once the Update process has completed. If the request is deleted before the request "
      + "completes, then the Update request will finish the step that it is currently performing and then will cancel any subsequent steps. "
      + NON_GUARANTEED_ENDPOINT,
    authorizations = {
      @Authorization(value = "Only the user that submitted the request can remove it")
    })
@ApiResponses(value = {
  @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
  @ApiResponse(code = 401, message = "Client could not be authenticated."),
  @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
  @ApiResponse(code = 404, message = "The specified resource could not be found."),
  @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
})
public Response deleteUpdateRequest(
    @ApiParam(
        value = "Acknowledges that this node is disconnected to allow for mutable requests to proceed.",
        required = false
    )
    @QueryParam(DISCONNECTED_NODE_ACKNOWLEDGED) @DefaultValue("false") final Boolean disconnectedNodeAcknowledged,
    @ApiParam("The ID of the Update Request") @PathParam("id") final String updateRequestId) {
  return deleteRequest("update-requests", updateRequestId, disconnectedNodeAcknowledged.booleanValue());
}

代码示例来源:origin: apache/nifi

@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.TEXT_PLAIN)
@Path("client-id")
@ApiOperation(
    value = "Generates a client id.",
    response = String.class,
    authorizations = {
        @Authorization(value = "Read - /flow")
    }
)
@ApiResponses(
    value = {
        @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
        @ApiResponse(code = 401, message = "Client could not be authenticated."),
        @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
        @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
    }
)
public Response generateClientId() {
  authorizeFlow();
  return generateOkResponse(generateUuid()).build();
}

代码示例来源:origin: apache/nifi

@PUT
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("input-ports/{portId}/transactions/{transactionId}")
@ApiOperation(
    value = "Extend transaction TTL",
    response = TransactionResultEntity.class,
    authorizations = {
        @Authorization(value = "Write - /data-transfer/input-ports/{uuid}")
@ApiResponses(
    value = {
        @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
    @PathParam("portId") String portId,
    @PathParam("transactionId") String transactionId,
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,

代码示例来源:origin: apache/nifi

@PUT
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("output-ports/{portId}/transactions/{transactionId}")
@ApiOperation(
    value = "Extend transaction TTL",
    response = TransactionResultEntity.class,
    authorizations = {
        @Authorization(value = "Write - /data-transfer/output-ports/{uuid}")
@ApiResponses(
    value = {
        @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
    @PathParam("portId") String portId,
    @PathParam("transactionId") String transactionId,
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,

代码示例来源:origin: apache/nifi

@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("controller/bulletins")
@ApiOperation(
    value = "Retrieves Controller level bulletins",
    response = ControllerBulletinsEntity.class,
    authorizations = {
        @Authorization(value = "Read - /flow"),
        @Authorization(value = "Read - /controller - For controller bulletins"),
        @Authorization(value = "Read - /controller-services/{uuid} - For controller service bulletins"),
        @Authorization(value = "Read - /reporting-tasks/{uuid} - For reporting task bulletins")
@ApiResponses(
    value = {
        @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),

相关文章