Search in sources :

Example 11 with TokenLdap

use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.

the class GrantService method logout.

public void logout(String sessionDn) {
    final List<TokenLdap> tokens = getGrantsBySessionDn(sessionDn);
    if (!appConfiguration.getRemoveRefreshTokensForClientOnLogout()) {
        List<TokenLdap> refreshTokens = Lists.newArrayList();
        for (TokenLdap token : tokens) {
            if (token.getTokenTypeEnum() == TokenType.REFRESH_TOKEN) {
                refreshTokens.add(token);
            }
        }
        if (!refreshTokens.isEmpty()) {
            log.trace("Refresh tokens are not removed on logout (because removeRefreshTokensForClientOnLogout configuration property is false)");
            tokens.removeAll(refreshTokens);
        }
    }
    removeSilently(tokens);
}
Also used : TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap)

Example 12 with TokenLdap

use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.

the class GrantService method getCacheTokensEntries.

public List<TokenLdap> getCacheTokensEntries(Set<String> tokenHashes) {
    List<TokenLdap> tokens = new ArrayList<>();
    for (String tokenHash : tokenHashes) {
        Object o1 = cacheService.get(tokenHash);
        if (o1 instanceof TokenLdap) {
            TokenLdap token = (TokenLdap) o1;
            token.setIsFromCache(true);
            tokens.add(token);
        }
    }
    return tokens;
}
Also used : TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap)

Example 13 with TokenLdap

use of org.gluu.oxauth.model.ldap.TokenLdap in project oxAuth by GluuFederation.

the class GrantServiceTest method createTestToken.

private TokenLdap createTestToken() {
    final String grantId = GrantService.generateGrantId();
    final String dn = grantService.buildDn(TokenHashUtil.hash(TEST_TOKEN_CODE));
    final TokenLdap t = new TokenLdap();
    t.setDn(dn);
    t.setGrantId(grantId);
    t.setClientId(m_clientId);
    t.setTokenCode(TokenHashUtil.hash(TEST_TOKEN_CODE));
    t.setTokenType(TokenType.ACCESS_TOKEN.getValue());
    t.setCreationDate(new Date());
    t.setExpirationDate(new Date());
    return t;
}
Also used : TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap) Date(java.util.Date)

Aggregations

TokenLdap (org.gluu.oxauth.model.ldap.TokenLdap)13 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 BaseComponentTest (org.gluu.oxauth.BaseComponentTest)1 Client (org.gluu.oxauth.model.registration.Client)1 Test (org.testng.annotations.Test)1