Skip to content
Snippets Groups Projects
Commit 417a5fd2 authored by Rick Herrick's avatar Rick Herrick
Browse files

XNAT-4356 XNAT-4477 Added expiration time to alias token. Fixed logic in user...

XNAT-4356 XNAT-4477 Added expiration time to alias token. Fixed logic in user enabling and verifying routines.
parent d6540791
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ import org.restlet.resource.StringRepresentation; ...@@ -30,6 +30,7 @@ import org.restlet.resource.StringRepresentation;
import org.restlet.resource.Variant; import org.restlet.resource.Variant;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -93,13 +94,14 @@ public class AliasTokenRestlet extends SecureResource { ...@@ -93,13 +94,14 @@ public class AliasTokenRestlet extends SecureResource {
Map<String, String> map = Maps.newHashMap(); Map<String, String> map = Maps.newHashMap();
map.put("alias", token.getAlias()); map.put("alias", token.getAlias());
map.put("secret", token.getSecret()); map.put("secret", token.getSecret());
String value = ""; if (token.getEstimatedExpirationTime() != null) {
map.put("estimatedExpirationTime", FORMATTER.format(token.getEstimatedExpirationTime()));
}
try { try {
value = _serializer.toJson(map); return _serializer.toJson(map);
} catch (IOException e) { } catch (IOException ignored) {
// return "";
} }
return value;
} }
@Override @Override
...@@ -114,7 +116,8 @@ public class AliasTokenRestlet extends SecureResource { ...@@ -114,7 +116,8 @@ public class AliasTokenRestlet extends SecureResource {
return _service; return _service;
} }
private static final int INVALID = -1; private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("yyyyMMdd_HHmmss");
private final SerializerService _serializer; private final SerializerService _serializer;
private AliasTokenService _service; private AliasTokenService _service;
private String _operation; private String _operation;
......
...@@ -120,7 +120,7 @@ public class XnatAuthenticationFilter extends UsernamePasswordAuthenticationFilt ...@@ -120,7 +120,7 @@ public class XnatAuthenticationFilter extends UsernamePasswordAuthenticationFilt
try { try {
AccessLogger.LogServiceAccess(username, AccessLogger.GetRequestIp(request), "Authentication", "SUCCESS"); AccessLogger.LogServiceAccess(username, AccessLogger.GetRequestIp(request), "Authentication", "SUCCESS");
Authentication auth = getAuthenticationManager().authenticate(authRequest); Authentication auth = getAuthenticationManager().authenticate(authRequest);
//Fixed XNAT-4409 by adding a check for a par parameter on login. If a PAR is present and valid, then grant the user that just logged in the appropriate project permissions. //Fixed XNAT-4409 by adding a check for a par parameter on login. If a PAR is present and valid, then grant the user that just logged in the appropriate project permissions.
if(StringUtils.isNotBlank(request.getParameter("par"))){ if(StringUtils.isNotBlank(request.getParameter("par"))){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment