Commit ba9efe93 authored by igoshin's avatar igoshin Committed by Matija Obreza
Browse files

Final version of user stories

#10392,#10393
parent 05ee4cdf
......@@ -53,11 +53,11 @@ public class OAuthAccessToken implements HibernateModel {
@Column(name = "refresh_token")
private String refreshToken;
@Column(name = "created_date")
private Date createdDate;
private DefaultOAuth2AccessToken defaultOAuth2AccessToken;
private synchronized DefaultOAuth2AccessToken getDefaultOAuth2AccessToken () {
if (this.defaultOAuth2AccessToken==null) {
this.defaultOAuth2AccessToken = SerializationUtils.deserialize(this.token);
......@@ -69,11 +69,13 @@ public class OAuthAccessToken implements HibernateModel {
return getDefaultOAuth2AccessToken().getExpiration();
}
public Date getIssuedDate() {
return new Date(getTokenExpiration().getTime()-432000000l);
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getTokenId() {
return tokenId;
......
......@@ -276,6 +276,7 @@ public class OAuth2JPATokenStoreImpl implements TokenStore {
persisted.setClientId(authentication.getAuthorizationRequest().getClientId());
persisted.setAuthentication(serializeAuthentication(authentication));
persisted.setRefreshToken(extractTokenKey(refreshToken));
persisted.setCreatedDate(new Date());
accessTokenPersistence.save(persisted);
}
......
package org.genesys2.server.servlet.controller;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.genesys2.server.model.oauth.OAuthAccessToken;
import org.genesys2.server.service.OAuth2ClientDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.DefaultAuthorizationRequest;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
......@@ -20,9 +15,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Controller
......@@ -90,19 +82,4 @@ public class OAuthManagementController extends BaseController {
tokenStore.removeAccessToken(new DefaultOAuth2AccessToken(tokenId));
return "redirect:/management/user/" + userName + "/tokens";
}
private void createDefaultTestToken() {
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(RandomStringUtils.randomAlphanumeric(5));
token.setExpiration(DateUtils.addDays(new Date(), 5));
Map<String, String> map = new HashMap<>();
map.put("scope", "scope");
DefaultAuthorizationRequest request = new DefaultAuthorizationRequest(map);
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("igoshin1991@gmail.com", "igoshin1991@gmail.com");
OAuth2Authentication authentication = new OAuth2Authentication(request, authenticationToken);
tokenStore.storeAccessToken(token, authentication);
}
}
......@@ -30,7 +30,7 @@
<a href="<c:url value="/management/${token.clientId}"/> ">${token.clientId}</a>
</td>
<td>
<fmt:formatDate value="${token.issuedDate}" pattern="MM-dd-yyyy hh:mm:ss"/>
<fmt:formatDate value="${token.createdDate}" pattern="MM-dd-yyyy hh:mm:ss"/>
</td>
<td>
<fmt:formatDate value="${token.tokenExpiration}" pattern="MM-dd-yyyy hh:mm:ss"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment