Search in sources :

Example 6 with TokenLdap

use of org.xdi.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.xdi.oxauth.model.ldap.TokenType.REFRESH_TOKEN);
    return result;
}
Also used : TokenLdap(org.xdi.oxauth.model.ldap.TokenLdap)

Example 7 with TokenLdap

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

the class AuthorizationGrant method createIdToken.

@Override
public IdToken createIdToken(String nonce, AuthorizationCode authorizationCode, AccessToken accessToken, AuthorizationGrant authorizationGrant, boolean includeIdTokenClaims) throws SignatureException, StringEncrypter.EncryptionException, InvalidJwtException, InvalidJweException {
    try {
        final IdToken idToken = createIdToken(this, nonce, authorizationCode, accessToken, getScopes(), includeIdTokenClaims);
        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);
        }
        // is it really neccessary to propagate to all tokens?
        setAcrValues(acrValues);
        setSessionDn(sessionDn);
        // asynchronous save
        save();
        return idToken;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return null;
    }
}
Also used : TokenLdap(org.xdi.oxauth.model.ldap.TokenLdap) SignatureException(java.security.SignatureException) InvalidJwtException(org.xdi.oxauth.model.exception.InvalidJwtException) InvalidJweException(org.xdi.oxauth.model.exception.InvalidJweException)

Example 8 with TokenLdap

use of org.xdi.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.xdi.oxauth.model.ldap.TokenType.AUTHORIZATION_CODE);
    return result;
}
Also used : TokenLdap(org.xdi.oxauth.model.ldap.TokenLdap)

Example 9 with TokenLdap

use of org.xdi.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()) {
            final String nonce = getNonce();
            final String scopes = getScopesAsString();
            for (TokenLdap t : grants) {
                t.setNonce(nonce);
                t.setScope(scopes);
                t.setAuthMode(getAcrValues());
                t.setSessionDn(getSessionDn());
                t.setAuthenticationTime(getAuthenticationTime());
                t.setCodeChallenge(getCodeChallenge());
                t.setCodeChallengeMethod(getCodeChallengeMethod());
                final JwtAuthorizationRequest jwtRequest = getJwtAuthorizationRequest();
                if (jwtRequest != null && StringUtils.isNotBlank(jwtRequest.getEncodedJwt())) {
                    t.setJwtRequest(jwtRequest.getEncodedJwt());
                }
                log.debug("Saving grant: " + grantId + ", code_challenge: " + getCodeChallenge());
                grantService.mergeSilently(t);
            }
        }
    }
}
Also used : JwtAuthorizationRequest(org.xdi.oxauth.model.authorize.JwtAuthorizationRequest) TokenLdap(org.xdi.oxauth.model.ldap.TokenLdap)

Example 10 with TokenLdap

use of org.xdi.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.xdi.oxauth.model.ldap.TokenType.ACCESS_TOKEN);
    return result;
}
Also used : TokenLdap(org.xdi.oxauth.model.ldap.TokenLdap)

Aggregations

TokenLdap (org.xdi.oxauth.model.ldap.TokenLdap)12 Date (java.util.Date)2 JwtAuthorizationRequest (org.xdi.oxauth.model.authorize.JwtAuthorizationRequest)2 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 SignatureException (java.security.SignatureException)1 Calendar (java.util.Calendar)1 List (java.util.List)1 BatchOperation (org.gluu.site.ldap.persistence.BatchOperation)1 Test (org.testng.annotations.Test)1 BaseComponentTest (org.xdi.oxauth.BaseComponentTest)1 OAuth2AuditLog (org.xdi.oxauth.model.audit.OAuth2AuditLog)1 AuthorizationGrant (org.xdi.oxauth.model.common.AuthorizationGrant)1 MemcachedGrant (org.xdi.oxauth.model.common.MemcachedGrant)1 InvalidJweException (org.xdi.oxauth.model.exception.InvalidJweException)1 InvalidJwtException (org.xdi.oxauth.model.exception.InvalidJwtException)1 Grant (org.xdi.oxauth.model.ldap.Grant)1