Search in sources :

Example 6 with TokenLdap

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

the class AuthorizationGrant method asToken.

public TokenLdap asToken(AccessToken p_accessToken) {
    final TokenLdap result = asTokenLdap(p_accessToken);
    result.setTokenTypeEnum(org.gluu.oxauth.model.ldap.TokenType.ACCESS_TOKEN);
    return result;
}
Also used : TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap)

Example 7 with TokenLdap

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

the class AuthorizationGrant method saveImpl.

private void saveImpl() {
    String grantId = getGrantId();
    if (grantId != null && StringUtils.isNotBlank(grantId)) {
        final List<TokenLdap> grants = grantService.getGrantsByGrantId(grantId);
        if (grants != null && !grants.isEmpty()) {
            for (TokenLdap t : grants) {
                initTokenFromGrant(t);
                log.debug("Saving grant: " + grantId + ", code_challenge: " + getCodeChallenge());
                grantService.mergeSilently(t);
            }
        }
    }
}
Also used : TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap)

Example 8 with TokenLdap

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

the class AuthorizationGrant method createIdToken.

@Override
public IdToken createIdToken(String nonce, AuthorizationCode authorizationCode, AccessToken accessToken, RefreshToken refreshToken, String state, AuthorizationGrant authorizationGrant, boolean includeIdTokenClaims, Function<JsonWebResponse, Void> preProcessing, Function<JsonWebResponse, Void> postProcessing) {
    try {
        final IdToken idToken = createIdToken(this, nonce, authorizationCode, accessToken, refreshToken, state, getScopes(), includeIdTokenClaims, preProcessing, postProcessing);
        final String acrValues = authorizationGrant.getAcrValues();
        final String sessionDn = authorizationGrant.getSessionDn();
        if (idToken.getExpiresIn() > 0) {
            final TokenLdap tokenLdap = asToken(idToken);
            tokenLdap.setAuthMode(acrValues);
            tokenLdap.setSessionDn(sessionDn);
            persist(tokenLdap);
        }
        setAcrValues(acrValues);
        setSessionDn(sessionDn);
        statService.reportIdToken(getGrantType());
        metricService.incCounter(MetricType.OXAUTH_TOKEN_ID_TOKEN_COUNT);
        return idToken;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return null;
    }
}
Also used : TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap)

Example 9 with TokenLdap

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

the class AuthorizationGrant method asToken.

public TokenLdap asToken(IdToken p_token) {
    final TokenLdap result = asTokenLdap(p_token);
    result.setTokenTypeEnum(org.gluu.oxauth.model.ldap.TokenType.ID_TOKEN);
    return result;
}
Also used : TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap)

Example 10 with TokenLdap

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

the class AuthorizationGrantList method getAuthorizationGrant.

@Override
public List<AuthorizationGrant> getAuthorizationGrant(String clientId) {
    final List<AuthorizationGrant> result = new ArrayList<>();
    try {
        final List<TokenLdap> entries = new ArrayList<TokenLdap>();
        entries.addAll(grantService.getGrantsOfClient(clientId));
        entries.addAll(grantService.getCacheClientTokensEntries(clientId));
        for (TokenLdap t : entries) {
            final AuthorizationGrant grant = asGrant(t);
            if (grant != null) {
                result.add(grant);
            }
        }
    } catch (Exception e) {
        log.trace(e.getMessage(), e);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) TokenLdap(org.gluu.oxauth.model.ldap.TokenLdap)

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