00018 client_details list test client
parent
35de85649d
commit
3dc1894c76
|
@ -173,4 +173,27 @@ public class OauthClientDetailsDto implements Serializable {
|
|||
}
|
||||
return dtos;
|
||||
}
|
||||
|
||||
|
||||
public boolean isContainsAuthorizationCode() {
|
||||
return this.authorizedGrantTypes.contains("authorization_code");
|
||||
}
|
||||
|
||||
public boolean isContainsPassword() {
|
||||
return this.authorizedGrantTypes.contains("password");
|
||||
}
|
||||
|
||||
public boolean isContainsImplicit() {
|
||||
return this.authorizedGrantTypes.contains("implicit");
|
||||
}
|
||||
|
||||
public boolean isContainsClientCredentials() {
|
||||
return this.authorizedGrantTypes.contains("client_credentials");
|
||||
}
|
||||
|
||||
public boolean isContainsRefreshToken() {
|
||||
return this.authorizedGrantTypes.contains("refresh_token");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -16,4 +16,6 @@ public interface OauthService {
|
|||
List<OauthClientDetailsDto> loadAllOauthClientDetailsDtos();
|
||||
|
||||
void archiveOauthClientDetails(String clientId);
|
||||
|
||||
OauthClientDetailsDto loadOauthClientDetailsDto(String clientId);
|
||||
}
|
|
@ -33,4 +33,10 @@ public class OauthServiceImpl implements OauthService {
|
|||
public void archiveOauthClientDetails(String clientId) {
|
||||
oauthRepository.updateOauthClientDetailsArchive(clientId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OauthClientDetailsDto loadOauthClientDetailsDto(String clientId) {
|
||||
final OauthClientDetails oauthClientDetails = oauthRepository.findOauthClientDetails(clientId);
|
||||
return new OauthClientDetailsDto(oauthClientDetails);
|
||||
}
|
||||
}
|
|
@ -40,5 +40,15 @@ public class ClientDetailsController {
|
|||
return "redirect:../client_details";
|
||||
}
|
||||
|
||||
/*
|
||||
* Test client
|
||||
* */
|
||||
@RequestMapping("test_client/{clientId}")
|
||||
public String testClient(@PathVariable("clientId") String clientId, Model model) {
|
||||
OauthClientDetailsDto clientDetailsDto = oauthService.loadOauthClientDetailsDto(clientId);
|
||||
model.addAttribute("clientDetailsDto", clientDetailsDto);
|
||||
return "clientdetails/test_client";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test [${clientDetailsDto.clientId}]</title>
|
||||
|
||||
<script src="http://cdn.bootcss.com/angular.js/1.1.5/angular.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div ng-app>
|
||||
<a href="../">Home</a>
|
||||
|
||||
<h2>Test [${clientDetailsDto.clientId}]</h2>
|
||||
|
||||
<p>
|
||||
针对不同的<code>grant_type</code>提供不同的测试URL,
|
||||
完整的Oauth测试请访问<a href="http://git.oschina.net/mkk/spring-oauth-client" target="_blank">spring-oauth-client</a>项目.
|
||||
</p>
|
||||
|
||||
<div ng-controller="TestClientCtrl">
|
||||
<c:if test="${clientDetailsDto.containsAuthorizationCode}">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Test [authorization_code]</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
<p>
|
||||
<code>从 spring-oauth-server获取 'code'</code>
|
||||
<br/>
|
||||
redirect_uri: <input type="text" value="" ng-model="redirectUri" size="70"
|
||||
required="required"/>
|
||||
<br/>
|
||||
<a href="${contextPath}/oauth/authorize?client_id={{clientId}}&redirect_uri={{redirectUri}}&response_type=code&scope={{scope}}"
|
||||
target="_blank">
|
||||
/oauth/authorize?client_id={{clientId}}&redirect_uri={{redirectUri}}&response_type=code&scope={{scope}}</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
<code>用 'code' 换取 'access_token'</code>
|
||||
<br/>
|
||||
输入第一步获取的code: <input type="text" name="code" value="" ng-model="code"
|
||||
required="required"/>
|
||||
<br/>
|
||||
<a href="${contextPath}/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=authorization_code&code={{code}}&redirect_uri={{redirectUri}}"
|
||||
target="_blank">/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=authorization_code&code={{code}}&redirect_uri={{redirectUri}}</a>
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="${contextPath}/" class="btn btn-default">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var TestClientCtrl = ["$scope", function ($scope) {
|
||||
$scope.clientId = "${clientDetailsDto.clientId}";
|
||||
$scope.clientSecret = "${clientDetailsDto.clientSecret}";
|
||||
$scope.scope = "${clientDetailsDto.scope}";
|
||||
|
||||
$scope.redirectUri = "${empty clientDetailsDto.webServerRedirectUri?'http://localhost:8080/spring-oauth-server/unity/dashboard.htm':clientDetailsDto.webServerRedirectUri}";
|
||||
|
||||
}];
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue