Commit be3a7516 authored by Matija Obreza's avatar Matija Obreza

OAuth controllers

parent 2e165f50
......@@ -11,7 +11,7 @@
"jquery-flot": "~0.8.3",
"tinymce": "~4.1.9",
"jquery.tinymce": "*",
"bootstrap-sass": "~3.3.5",
"bootstrap-sass": "~3.3.6",
"jquery-ui": "~1.11.4",
"dyn-css": "~0.8.1",
"webfont-notosans": "~0.1.0",
......
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.servlet.controller.oauth;
import java.util.List;
import org.genesys2.server.model.oauth.OAuthClientDetails;
import org.genesys2.server.service.OAuth2ClientDetailsService;
import org.genesys2.server.servlet.controller.ProfileController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Manage OAuth2 clients
*
* @author mobreza
*/
@Controller
@RequestMapping("/admin/oauth")
public class ClientController extends ProfileController<ClientDetails, String> {
@Autowired
private OAuth2ClientDetailsService clientDetailsService;
@Autowired
private TokenStore tokenStore;
@Override
protected ClientDetails getDetails(String identifier) {
return clientDetailsService.loadClientByClientId(identifier);
}
@Override
public void addDetails(ModelMap model, ClientDetails item) {
super.addDetails(model, item);
model.addAttribute("tokens", tokenStore.findTokensByClientId(item.getClientId()));
}
@Override
protected List<OAuthClientDetails> list() {
return clientDetailsService.listClientDetails();
}
@Override
protected String getViewPrefix() {
return "/admin/oauth/client";
}
}
......@@ -56,7 +56,7 @@
<li><a href="<c:url value="/admin/" />"><spring:message code="user.pulldown.administration" /></a></li>
<li><a href="<c:url value="/profile/list" />"><spring:message code="user.pulldown.users" /></a></li>
<li><a href="<c:url value="/team" />"><spring:message code="user.pulldown.teams" /></a></li>
<li><a href="<c:url value="/management/" />"><spring:message code="user.pulldown.oauth-clients" /></a></li>
<li><a href="<c:url value="/admin/oauth-clients/" />"><spring:message code="user.pulldown.oauth-clients" /></a></li>
<li><a href="<c:url value="/content" />"><spring:message code="user.pulldown.manage-content" /></a></li>
<li><a href="<c:url value="/project" />"><spring:message code="project.page.list.title" /></a></li>
</security:authorize>
......
......@@ -12,7 +12,7 @@
</h1>
<security:authorize access="hasRole('ADMINISTRATOR') or hasRole('VETTEDUSER')">
<a href="<c:url value="/management/add-client" />" class="close"><spring:message code="add" /></a>
<a href="<c:url value="/admin/oauth-clients/add-client" />" class="close"><spring:message code="add" /></a>
</security:authorize>
<table class="accessions">
......@@ -20,7 +20,7 @@
<c:forEach items="${clientDetailsList}" var="clientDetail">
<tr>
<td>
<a href="<c:url value="/management/${clientDetail.clientId}/"/>"><c:out
<a href="<c:url value="/admin/oauth-clients/${clientDetail.clientId}/"/>"><c:out
value="${clientDetail.title}"/></a>
</td>
<td><c:out value="${clientDetail.clientId}" /></td>
......
......@@ -12,8 +12,8 @@
</h1>
<security:authorize access="hasRole('ADMINISTRATOR') or hasPermission(#clientDetails, 'ADMINISTRATION')">
<a href="<c:url value="/acl/${clientDetails.getClass().name}/${clientDetails.id}/permissions"><c:param name="back">/management/${clientDetails.clientId}/</c:param></c:url>" class="close"> <spring:message code="edit-acl" /></a>
<a href="<c:url value="/management/${clientDetails.id}/edit" />" class="close">
<a href="<c:url value="/acl/${clientDetails.getClass().name}/${clientDetails.id}/permissions"><c:param name="back">/admin/oauth-clients/${clientDetails.clientId}/</c:param></c:url>" class="close"> <spring:message code="edit-acl" /></a>
<a href="<c:url value="/admin/oauth-clients/${clientDetails.id}/edit" />" class="close">
<spring:message code="edit" />
</a>
</security:authorize>
......@@ -39,7 +39,7 @@
<security:authorize access="hasRole('ADMINISTRATOR')">
<h3><spring:message code="client.details.token.list"/></h3>
<a href="<c:url value="/management/${clientDetails.clientId}/removeall"/> "><spring:message
<a href="<c:url value="/admin/oauth-clients/${clientDetails.clientId}/removeall"/> "><spring:message
code="oauth-client.remove.all"/></a>
<table class="accessions">
<tbody>
......@@ -49,7 +49,7 @@
<td><c:out value="${jspHelper.userByUuid(accessToken.userUuid).email}"/></td>
<td><c:out value="${accessToken.redirectUri}"/></td>
<td>
<a href="<c:url value="/management/${clientDetails.clientId}/${accessToken.id}/remove"/> "><spring:message
<a href="<c:url value="/admin/oauth-clients/${clientDetails.clientId}/${accessToken.id}/remove"/> "><spring:message
code="oauth-client.remove"/></a>
</td>
</tr>
......@@ -59,7 +59,7 @@
<h3><spring:message code="client.details.refresh-token.list"/></h3>
<a href="<c:url value="/management/${clientDetails.clientId}/removeall-rt"/> "><spring:message
<a href="<c:url value="/admin/oauth-clients/${clientDetails.clientId}/removeall-rt"/> "><spring:message
code="oauth-client.remove.all"/></a>
<table class="accessions">
<tbody>
......@@ -69,7 +69,7 @@
<td><c:out value="${jspHelper.userByUuid(refreshToken.userUuid).email}"/></td>
<td><c:out value="${refreshToken.redirectUri}"/></td>
<td>
<a href="<c:url value="/management/${clientDetails.clientId}/${refreshToken.id}/remove-rt"/> "><spring:message
<a href="<c:url value="/admin/oauth-clients/${clientDetails.clientId}/${refreshToken.id}/remove-rt"/> "><spring:message
code="oauth-client.remove"/></a>
</td>
</tr>
......
......@@ -11,7 +11,7 @@
<spring:message code="oauth-client.page.profile.title" arguments="${clientDetails.clientId}" />
</h1>
<form role="form" class="form-horizontal validate" action="<c:url value="/management/save-client" />" method="post">
<form role="form" class="form-horizontal validate" action="<c:url value="/admin/oauth-clients/save-client" />" method="post">
<c:if test="${clientDetails != null}">
<input type="hidden" name="id" value="${clientDetails.id}" />
</c:if>
......@@ -76,7 +76,7 @@
<div class="col-lg-offset-2 col-lg-10">
<input type="submit" name="action-save" value="<spring:message code="save"/>" class="btn btn-primary" />
<input type="submit" name="action-delete" value="<spring:message code="delete"/>" class="btn btn-default" />
<a class="btn btn-default" href="<c:url value="/management/" />" class="btn"> <spring:message code="cancel" />
<a class="btn btn-default" href="<c:url value="/admin/oauth-clients/" />" class="btn"> <spring:message code="cancel" />
</a>
</div>
</div>
......
......@@ -27,7 +27,7 @@
<c:forEach items="${tokens}" var="token">
<tr class="${token.accessToken.expired ? 'expired' : ''}">
<td>
<a href="<c:url value="/management/${token.clientId}"/> ">${token.clientId}</a>
<a href="<c:url value="/admin/oauth-clients/${token.clientId}"/> ">${token.clientId}</a>
</td>
<td>
<fmt:formatDate value="${token.createdDate}" type="both" timeStyle="full" dateStyle="short" />
......@@ -37,7 +37,7 @@
</td>
<td>
<!-- FIXME Use POST -->
<a href="<c:url value="/management/user/${token.userName}/${token.tokenId}/remove"/>"><spring:message
<a href="<c:url value="/admin/oauth-clients/user/${token.userName}/${token.tokenId}/remove"/>"><spring:message
code="oauth-client.remove"/></a>
</td>
</tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment