80 lines
2.3 KiB
Plaintext
80 lines
2.3 KiB
Plaintext
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
|
<%@include file="../init.jsp"%>
|
|
<%@ page import="org.gcube.vomanagement.usermanagement.model.GCubeGroup"%>
|
|
<portlet:defineObjects />
|
|
<portlet:resourceURL var="resourceURL">
|
|
</portlet:resourceURL>
|
|
<%
|
|
List<GCubeGroup> userGroups = (List<GCubeGroup>) request.getAttribute("userGroups");
|
|
pageContext.setAttribute("userGroups", userGroups);
|
|
|
|
List<String> userContexts = (List<String>) request.getAttribute("userContexts");
|
|
pageContext.setAttribute("userContexts", userContexts);
|
|
%>
|
|
<script type="text/javascript">
|
|
function getUMAToken(endpoint) {
|
|
console.log("getUMAToken:" + endpoint);
|
|
$('#umaButton').attr("disabled", true);
|
|
$('#buttonCopy').hide();
|
|
var selectedContext = $("#myselect").val();
|
|
$('#tokenResult').text('');
|
|
$.ajax({
|
|
url : endpoint,
|
|
type : 'POST',
|
|
datatype : 'json',
|
|
data : {
|
|
context : selectedContext
|
|
},
|
|
success : function(data) {
|
|
var resultObject = JSON.parse(JSON.stringify(data));
|
|
if (resultObject.success) {
|
|
$('#tokenResult').text(resultObject.comment);
|
|
$('#buttonCopy').show();
|
|
} else {
|
|
$('#tokenResult').text(resultObject.comment);
|
|
$('#tokenResult').css('color', 'red');
|
|
}
|
|
$('#umaButton').attr("disabled", false);
|
|
}
|
|
});
|
|
}
|
|
|
|
function copyFunction() {
|
|
/* Get the text field */
|
|
var copyText = document.getElementById("tokenResult");
|
|
|
|
/* Select the text field */
|
|
copyText.select();
|
|
copyText.setSelectionRange(0, 99999); /* For mobile devices */
|
|
|
|
/* Copy the text inside the text field */
|
|
document.execCommand("copy");
|
|
}
|
|
</script>
|
|
<p>Select the context:</p>
|
|
<div>
|
|
<select style="width: 100%;" name="contexts" id="myselect">
|
|
<c:forEach var="context" items="${userContexts}">
|
|
<option value="${context}">${context}</option>
|
|
</c:forEach>
|
|
</select>
|
|
</div>
|
|
<div style="margin-bottom: 15px;">
|
|
<button name="umaButton" id="umaButton" type="button"
|
|
class="btn btn-primary" onClick="getUMAToken('${resourceURL}')">Get
|
|
Token</button>
|
|
</div>
|
|
<div>
|
|
<button id="buttonCopy" class="btn btn-mini" onclick="copyFunction()">
|
|
<i class="icon-copy"></i> Copy
|
|
</button>
|
|
<textarea style="width: 90%;" 300px; margin: 10px;" id="tokenResult"></textarea>
|
|
</div>
|
|
<div>
|
|
You can use <a href="https://jwt.io/" target="blank">https://jwt.io/</a>
|
|
to decode the tokens, if needed.
|
|
</div>
|
|
<script>
|
|
$('#buttonCopy').hide();
|
|
</script>
|