var table;
$(document).ready(function () {
$('#fmrel').on('submit', function (e) {
e.preventDefault();
var username = $('#username').val();
var password = $('#password').val();
var service = $('#service').val();
releaseAttributes(username, password, service);
});
$('#fm1').on('submit', function (e) {
e.preventDefault();
var uid = $('#uid').val();
table = $('#attributesTable').DataTable();
table.clear().draw();
var status = $('#status');
if (uid !== null && uid !== '') {
resolveAttributes(uid);
status.html('Resolved attributes for username ' + uid + '.');
status.removeClass('alert-danger');
status.addClass('alert-info');
status.show();
} else {
status.html('No username is provided.');
status.removeClass('alert-info');
status.addClass('alert-danger');
status.show();
}
});
if ($.fn.dataTable.isDataTable('#attributesTable')) {
table = $('#attributesTable').DataTable();
} else {
table = $('#attributesTable').DataTable({
paging: false,
searching: false
});
}
$('#status').hide();
});
function resolveAttributes(uid) {
$.ajax({
type: 'post',
url: urls.resolveAttributes,
data: {'uid': uid},
success: function (data) {
var table = $('#attributesTable').DataTable();
table.clear();
var attrs = data.attributes;
for (var property in attrs) {
if (attrs.hasOwnProperty(property)) {
table.row.add([
'' + property + '
', '' + attrs[property] + '
'
]).draw(false);
}
}
}
});
}
function releaseAttributes(uid, psw, service) {
$('validationresponse').empty();
$('cas1').empty();
$('cas2').empty();
$('cas3Xml').empty();
$('cas3Json').empty();
$('#submitRelease').attr('disabled', 'disabled');
$.ajax({
type: 'post',
url: urls.releaseAttributes,
data: {'username': uid, 'password': psw, 'service': service},
success: function (data) {
var html = '
' + data.registeredService.id + '
' + data.registeredService.serviceId + '
' + data.registeredService.name + '
' + JSON.stringify(data.registeredService, null, 4) + ''; $('#serviceJson').html(resp); resp = '
' + data.cas1Response + ''; $('#cas1').html(resp); resp = '
' + data.cas2Response + ''; $('#cas2').html(resp); resp = '
' + data.cas3XmlResponse + ''; $('#cas3Xml').html(resp); resp = '
' + data.cas3JsonResponse + ''; $('#cas3Json').html(resp); }, error: function (err) { var html = '
' + err.responseJSON.status + '
'
+ 'Exception: ' + err.responseJSON.exception + '
'
+ 'Message: ' + err.responseJSON.message + '
'
+ '