Java Code Examples for io.swagger.models.auth.OAuth2Definition#addScope()
The following examples show how to use
io.swagger.models.auth.OAuth2Definition#addScope() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAS2Parser.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Update swagger with security definition * * @param swagger swagger object * @param swaggerData Swagger related data */ private void updateSwaggerSecurityDefinition(Swagger swagger, SwaggerData swaggerData, String authUrl) { OAuth2Definition oAuth2Definition = new OAuth2Definition().implicit(authUrl); Set<Scope> scopes = swaggerData.getScopes(); if (scopes != null && !scopes.isEmpty()) { Map<String, String> scopeBindings = new HashMap<>(); for (Scope scope : scopes) { oAuth2Definition.addScope(scope.getKey(), scope.getDescription()); scopeBindings.put(scope.getKey(), scope.getRoles()); } oAuth2Definition.setVendorExtension(APIConstants.SWAGGER_X_SCOPES_BINDINGS, scopeBindings); } swagger.addSecurityDefinition(APIConstants.SWAGGER_APIM_DEFAULT_SECURITY, oAuth2Definition); if (swagger.getSecurity() == null) { SecurityRequirement securityRequirement = new SecurityRequirement(); securityRequirement.setRequirements(APIConstants.SWAGGER_APIM_DEFAULT_SECURITY, new ArrayList<String>()); swagger.addSecurity(securityRequirement); } }
Example 2
Source File: SecurityDefinitionConfigurator.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
@Override public void afterScan(Reader reader, Swagger swagger) { OAuth2Definition tokenScheme = new OAuth2Definition(); tokenScheme.setType("oauth2"); tokenScheme.setFlow("application"); tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token"); tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize"); tokenScheme.addScope("write:everything", "Full access"); Map<String, SecuritySchemeDefinition> schemes = new HashMap<>(); schemes.put(TOKEN_AUTH_SCHEME, tokenScheme); swagger.setSecurityDefinitions(schemes); }
Example 3
Source File: SecurityDefinitionConfigurator.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
@Override public void afterScan(Reader reader, Swagger swagger) { OAuth2Definition tokenScheme = new OAuth2Definition(); tokenScheme.setType("oauth2"); tokenScheme.setFlow("application"); tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token"); tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize"); tokenScheme.addScope("write:everything", "Full access"); Map<String, SecuritySchemeDefinition> schemes = new HashMap<>(); schemes.put(TOKEN_AUTH_SCHEME, tokenScheme); swagger.setSecurityDefinitions(schemes); }
Example 4
Source File: SecurityDefinitionConfigurator.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
@Override public void afterScan(Reader reader, Swagger swagger) { OAuth2Definition tokenScheme = new OAuth2Definition(); tokenScheme.setType("oauth2"); tokenScheme.setFlow("application"); tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token"); tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize"); tokenScheme.addScope("write:everything", "Full access"); Map<String, SecuritySchemeDefinition> schemes = new HashMap<>(); schemes.put(TOKEN_AUTH_SCHEME, tokenScheme); swagger.setSecurityDefinitions(schemes); //TODO: Have to add wso2-scopes to swagger definition from here }
Example 5
Source File: SecurityDefinitionConfigurator.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
@Override public void afterScan(Reader reader, Swagger swagger) { OAuth2Definition tokenScheme = new OAuth2Definition(); tokenScheme.setType("oauth2"); tokenScheme.setFlow("application"); tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token"); tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize"); tokenScheme.addScope("write:everything", "Full access"); Map<String, SecuritySchemeDefinition> schemes = new HashMap<>(); schemes.put(TOKEN_AUTH_SCHEME, tokenScheme); swagger.setSecurityDefinitions(schemes); //TODO: Have to add wso2-scopes to swagger definition from here }