require redirect

This commit is contained in:
Bill Burke 2014-05-19 14:44:36 -04:00
parent 3be4579204
commit 11c23a7945
6 changed files with 35 additions and 13 deletions

View file

@ -14,6 +14,7 @@ public class UserSessionRepresentation {
private String user;
private String ipAddress;
private long start;
private long lastAccess;
private Set<String> applications = new HashSet<String>();
private Map<String, String> clients = new HashMap<String, String>();
@ -49,6 +50,14 @@ public class UserSessionRepresentation {
this.start = start;
}
public long getLastAccess() {
return lastAccess;
}
public void setLastAccess(long lastAccess) {
this.lastAccess = lastAccess;
}
public Set<String> getApplications() {
return applications;
}

View file

@ -49,6 +49,10 @@ public class SessionsBean {
return Time.toDate(session.getStarted());
}
public Date getLastAccess() {
return Time.toDate(session.getLastSessionRefresh());
}
public Date getExpires() {
int max = session.getStarted() + realm.getSsoSessionMaxLifespan();
return Time.toDate(max);

View file

@ -12,6 +12,7 @@
<tr>
<td>IP</td>
<td>Started</td>
<td>Last Access</td>
<td>Expires</td>
<td>Applications</td>
<td>Clients</td>
@ -23,6 +24,7 @@
<tr>
<td>${session.ipAddress}</td>
<td>${session.started?datetime}</td>
<td>${session.lastAccess?datetime}</td>
<td>${session.expires?datetime}</td>
<td>
<ul style="list-style: none; ">

View file

@ -264,16 +264,20 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application,
$scope.save = function() {
if ($scope.create) {
Application.save({
realm: realm.realm,
application: ''
}, $scope.application, function (data, headers) {
$scope.changed = false;
var l = headers().location;
var id = l.substring(l.lastIndexOf("/") + 1);
$location.url("/realms/" + realm.realm + "/applications/" + id);
Notifications.success("The application has been created.");
});
if (!$scope.application.redirectUris || $scope.application.redirectUris.length == 0) {
Notifications.error("You must specify at least one redirect uri");
} else {
Application.save({
realm: realm.realm,
application: ''
}, $scope.application, function (data, headers) {
$scope.changed = false;
var l = headers().location;
var id = l.substring(l.lastIndexOf("/") + 1);
$location.url("/realms/" + realm.realm + "/applications/" + id);
Notifications.success("The application has been created.");
});
}
} else {
Application.update({
realm : realm.realm,

View file

@ -18,7 +18,7 @@
<table class="table table-striped table-bordered">
<thead>
<tr>
<th class="kc-table-actions" colspan="5">
<th class="kc-table-actions" colspan="6">
<div class="pull-right">
<a class="btn btn-primary" ng-click="logoutAll()">Logout All Sessions</a>
</div>
@ -26,7 +26,8 @@
</tr>
<tr>
<th>IP Address</th>
<th>Login Time</th>
<th>Started</th>
<th>Last Access</th>
<th>Applications</th>
<th>OAuth Clients</th>
<th>Action</th>
@ -36,6 +37,7 @@
<tr data-ng-repeat="session in sessions">
<td>{{session.ipAddress}}</td>
<td>{{session.start | date:'medium'}}</td>
<td>{{session.lastAccess | date:'medium'}}</td>
<td><ul style="list-style: none; ">
<li data-ng-repeat="app in session.applications">
<a href="#/realms/{{realm.realm}}/applications/{{app}}/sessions">{{app}}</a>

View file

@ -186,7 +186,8 @@ public class ModelToRepresentation {
public static UserSessionRepresentation toRepresentation(UserSessionModel session) {
UserSessionRepresentation rep = new UserSessionRepresentation();
rep.setId(session.getId());
rep.setStart(((long)session.getStarted()) * 1000);
rep.setStart(((long)session.getStarted()) * 1000L);
rep.setLastAccess(((long)session.getLastSessionRefresh())* 1000L);
rep.setUser(session.getUser().getLoginName());
rep.setIpAddress(session.getIpAddress());
for (ClientModel client : session.getClientAssociations()) {