Search in sources :

Example 1 with ClientDetails

use of io.github.tesla.authz.domain.ClientDetails in project tesla by linking12.

the class OAuthHandler method createTokenResponse.

protected OAuthResponse createTokenResponse(AccessToken accessToken, boolean queryOrJson) throws OAuthSystemException {
    final ClientDetails tempClientDetails = clientDetails();
    final OAuthASResponse.OAuthTokenResponseBuilder builder = OAuthASResponse.tokenResponse(HttpServletResponse.SC_OK).location(tempClientDetails.getRedirectUri()).setAccessToken(accessToken.tokenId()).setExpiresIn(String.valueOf(accessToken.currentTokenExpiredSeconds())).setTokenType(accessToken.tokenType());
    final String refreshToken = accessToken.refreshToken();
    if (StringUtils.isNotEmpty(refreshToken)) {
        builder.setRefreshToken(refreshToken);
    }
    return queryOrJson ? builder.buildQueryMessage() : builder.buildJSONMessage();
}
Also used : ClientDetails(io.github.tesla.authz.domain.ClientDetails) OAuthASResponse(org.apache.oltu.oauth2.as.response.OAuthASResponse)

Example 2 with ClientDetails

use of io.github.tesla.authz.domain.ClientDetails in project tesla by linking12.

the class TokenAuthorizeHandler method expiredTokenResponse.

private void expiredTokenResponse(AccessToken accessToken) throws OAuthSystemException {
    final ClientDetails clientDetails = clientDetails();
    LOG.debug("AccessToken {} is expired", accessToken);
    final OAuthResponse oAuthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND).setError(OAuthError.ResourceResponse.EXPIRED_TOKEN).setErrorDescription("access_token '" + accessToken.tokenId() + "' expired").setErrorUri(clientDetails.getRedirectUri()).buildJSONMessage();
    WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
}
Also used : ClientDetails(io.github.tesla.authz.domain.ClientDetails) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse)

Example 3 with ClientDetails

use of io.github.tesla.authz.domain.ClientDetails in project tesla by linking12.

the class Oauth2Controller method listClients.

@ResponseBody
@GetMapping("/listClient")
@RequiresPermissions("sys:oauth2:listclient")
PageDO<ClientDetails> listClients(@RequestParam Map<String, Object> params) {
    Query query = new Query(params);
    PageDO<ClientDetails> page = oauth2Service.queryClientDetailsList(query);
    return page;
}
Also used : ClientDetails(io.github.tesla.authz.domain.ClientDetails) Query(io.github.tesla.ops.utils.Query) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with ClientDetails

use of io.github.tesla.authz.domain.ClientDetails in project tesla by linking12.

the class Oauth2Controller method edit.

@Log("编辑客户端")
@RequiresPermissions("sys:oauth2:edit")
@GetMapping("/edit/{id}")
String edit(@PathVariable("id") String id, Model model) {
    ClientDetails client = oauth2Service.get(id);
    model.addAttribute("client", client);
    return prefix + "/edit";
}
Also used : ClientDetails(io.github.tesla.authz.domain.ClientDetails) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping) Log(io.github.tesla.ops.common.Log)

Example 5 with ClientDetails

use of io.github.tesla.authz.domain.ClientDetails in project tesla by linking12.

the class CodeAuthorizeHandler method handleResponse.

@Override
protected void handleResponse() throws OAuthSystemException, IOException {
    final ClientDetails clientDetails = clientDetails();
    final String authCode = oauthService.retrieveAuthCode(clientDetails);
    final OAuthResponse oAuthResponse = OAuthASResponse.authorizationResponse(oauthRequest.request(), HttpServletResponse.SC_OK).location(clientDetails.getRedirectUri()).setCode(authCode).buildQueryMessage();
    LOG.debug(" 'code' response: {}", oAuthResponse);
    WebUtils.writeOAuthQueryResponse(response, oAuthResponse);
}
Also used : ClientDetails(io.github.tesla.authz.domain.ClientDetails) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse)

Aggregations

ClientDetails (io.github.tesla.authz.domain.ClientDetails)6 OAuthResponse (org.apache.oltu.oauth2.common.message.OAuthResponse)2 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 AccessToken (io.github.tesla.authz.domain.AccessToken)1 Log (io.github.tesla.ops.common.Log)1 Query (io.github.tesla.ops.utils.Query)1 OAuthASResponse (org.apache.oltu.oauth2.as.response.OAuthASResponse)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1