minor fixes
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/oauth@141979 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ff6c10ac46
commit
c0f720aa71
|
@ -39,7 +39,7 @@ public class OauthService {
|
|||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(OauthService.class);
|
||||
|
||||
/**
|
||||
* This map contains couples <code, {qualifier-token, insert time}>
|
||||
* This map contains couples <code, {qualifier-token, insert time, scope, redirect uri, client id}>
|
||||
*/
|
||||
private Map<String, CacheBean> entries;
|
||||
|
||||
|
@ -115,8 +115,25 @@ public class OauthService {
|
|||
return Response.status(status).entity("{\"error\"=\"Trying to access push-authentication-code method via a token different than USER is not allowed\"").build();
|
||||
}else{
|
||||
|
||||
logger.info("Saving entry defined by " + bean + " in cache, token is " + token.substring(0, 10));
|
||||
entries.put(bean.getCode(), new CacheBean(token, ScopeProvider.instance.get(), bean.getRedirectUri(), bean.getClientId(), System.currentTimeMillis()));
|
||||
// check parameters
|
||||
String code = bean.getCode();
|
||||
String clientId = bean.getClientId();
|
||||
String redirectUri = bean.getRedirectUri();
|
||||
|
||||
if(code == null || code.isEmpty())
|
||||
return Response.status(Status.BAD_REQUEST).
|
||||
entity("{\"error\"=\"'code' cannot be null or missing\"").build();
|
||||
|
||||
if(clientId == null || clientId.isEmpty())
|
||||
return Response.status(Status.BAD_REQUEST).
|
||||
entity("{\"error\"=\"'client_id' cannot be null or missing\"").build();
|
||||
|
||||
if(redirectUri == null || redirectUri.isEmpty())
|
||||
return Response.status(Status.BAD_REQUEST).
|
||||
entity("{\"error\"=\"'redirect_uri' cannot be null or missing\"").build();
|
||||
|
||||
logger.info("Saving entry defined by " + bean + " in cache, token is " + token.substring(0, 10) + "***************");
|
||||
entries.put(code, new CacheBean(token, ScopeProvider.instance.get(), redirectUri, clientId, System.currentTimeMillis()));
|
||||
return Response.status(status).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ public class CacheBean {
|
|||
this.scope = scope;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CacheCleaner extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
logger.info("Going to sleep . Number of removed entries is " + removedEntries + " [" + new Date() + "]");
|
||||
logger.info("Going to sleep. Number of removed entries is " + removedEntries + " [" + new Date() + "]");
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
logger.warn("Exception was " + e.getMessage());
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.gcube.portal.oauth.input;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
|
@ -11,17 +9,18 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
public class PushCodeBean {
|
||||
|
||||
@JsonProperty("code")
|
||||
@NotNull(message="code cannot be null")
|
||||
private String code;
|
||||
|
||||
|
||||
@JsonProperty("redirect_uri")
|
||||
@NotNull(message="redirect_uri cannot be null")
|
||||
private String redirectUri;
|
||||
|
||||
|
||||
@JsonProperty("client_id")
|
||||
@NotNull(message="client_id cannot be null")
|
||||
private String clientId;
|
||||
|
||||
public PushCodeBean() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code
|
||||
* @param redirectUri
|
||||
|
@ -41,7 +40,7 @@ public class PushCodeBean {
|
|||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
public String getRedirectUri() {
|
||||
return redirectUri;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue