use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.
the class AuthorizationGrant method asToken.
public TokenLdap asToken(RefreshToken p_token) {
final TokenLdap result = asTokenLdap(p_token);
result.setTokenTypeEnum(org.gluu.oxauth.model.ldap.TokenType.REFRESH_TOKEN);
return result;
}
use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.
the class AuthorizationGrant method asToken.
public TokenLdap asToken(AuthorizationCode p_authorizationCode) {
final TokenLdap result = asTokenLdap(p_authorizationCode);
result.setTokenTypeEnum(org.gluu.oxauth.model.ldap.TokenType.AUTHORIZATION_CODE);
return result;
}
use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.
the class AuthorizationGrant method asTokenLdap.
public TokenLdap asTokenLdap(AbstractToken p_token) {
final TokenLdap result = new TokenLdap();
final String hashedCode = TokenHashUtil.hash(p_token.getCode());
result.setDn(grantService.buildDn(hashedCode));
result.setGrantId(getGrantId());
result.setCreationDate(p_token.getCreationDate());
result.setExpirationDate(p_token.getExpirationDate());
result.setTtl(p_token.getTtl());
result.setTokenCode(hashedCode);
result.setUserId(getUserId());
result.setClientId(getClientId());
result.getAttributes().setX5cs256(p_token.getX5ts256());
final AuthorizationGrantType grantType = getAuthorizationGrantType();
if (grantType != null) {
result.setGrantType(grantType.getParamName());
}
final AuthorizationCode authorizationCode = getAuthorizationCode();
if (authorizationCode != null) {
result.setAuthorizationCode(TokenHashUtil.hash(authorizationCode.getCode()));
}
initTokenFromGrant(result);
return result;
}
use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.
the class CleanerTimerTest method token_whichIsExpiredAndDeletable_MustBeRemoved.
@Test
public void token_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
clientService.persist(client);
// 1. create token
final ClientCredentialsGrant grant = authorizationGrantList.createClientCredentialsGrant(new User(), client);
final AccessToken accessToken = grant.createAccessToken(null, new ExecutionContext(null, null));
// 2. token exists
assertNotNull(grantService.getGrantByCode(accessToken.getCode()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. token exists
final TokenLdap grantLdap = grantService.getGrantByCode(accessToken.getCode());
assertNotNull(grantLdap);
final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -10);
grantLdap.setExpirationDate(calendar.getTime());
grantService.merge(grantLdap);
// 5. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 6. no token in persistence
assertNull(grantService.getGrantByCode(accessToken.getCode()));
}
use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.
the class GrantService method removeByCode.
/**
* Removes grant with particular code.
*
* @param p_code code
*/
public void removeByCode(String p_code) {
final TokenLdap t = getGrantByCode(p_code);
if (t != null) {
removeSilently(t);
}
cacheService.remove(CacheGrant.cacheKey(p_code, null));
}