Search in sources :

Example 11 with DocOAuth20Sub

use of info.xiancloud.core.apidoc.annotation.DocOAuth20Sub in project xian by happyyangyuan.

the class OAuth20Handler method handleDeleteScope.

@DocOAuth20Sub(name = "handleDeleteScope", dec = "删除单个scope", method = "DELETE", url = "/oauth2.0/scopes/{scopeName}", args = { @DocOAuth20SubIn(name = "scope", dec = "scope name", require = true, type = String.class) })
FullHttpResponse handleDeleteScope(FullHttpRequest req) {
    FullHttpResponse response;
    Matcher m = OAUTH_CLIENT_SCOPE_PATTERN.matcher(req.uri());
    if (m.find()) {
        String scopeName = m.group(1);
        ScopeService scopeService = getScopeService();
        try {
            String responseMsg = scopeService.deleteScope(scopeName);
            response = ResponseBuilder.createOkResponse(responseMsg);
        } catch (OAuthException e) {
            invokeExceptionHandler(e, req);
            response = ResponseBuilder.createResponse(e.getHttpStatus(), e.getMessage());
        }
    } else {
        response = ResponseBuilder.createNotFoundResponse();
    }
    return response;
}
Also used : Matcher(java.util.regex.Matcher) OAuthException(com.apifest.oauth20.bean.OAuthException) DocOAuth20Sub(info.xiancloud.core.apidoc.annotation.DocOAuth20Sub)

Aggregations

DocOAuth20Sub (info.xiancloud.core.apidoc.annotation.DocOAuth20Sub)11 OAuthException (com.apifest.oauth20.bean.OAuthException)7 Matcher (java.util.regex.Matcher)5 AccessToken (info.xiancloud.core.support.authen.AccessToken)2 JSONObject (com.alibaba.fastjson.JSONObject)1 ExceptionEventHandler (com.apifest.oauth20.api.ExceptionEventHandler)1 ApplicationInfo (com.apifest.oauth20.bean.ApplicationInfo)1 ClientCredentials (com.apifest.oauth20.bean.ClientCredentials)1 DocOAuth20SubIn (info.xiancloud.core.apidoc.annotation.DocOAuth20SubIn)1 BufferedWriter (java.io.BufferedWriter)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 Method (java.lang.reflect.Method)1 URISyntaxException (java.net.URISyntaxException)1