/** * Return true if given refreshToken represents offline token * * @param refreshToken * @return */ public static boolean isOfflineToken(String refreshToken) throws JWSInputException { RefreshToken token = getRefreshToken(refreshToken); return token.getType().equals(TOKEN_TYPE_OFFLINE); }
public static boolean isOfflineTokenRequested(String scopeParam) { return hasScope(scopeParam, OAuth2Constants.OFFLINE_ACCESS); }
public Response redirect(UriInfo uriInfo, String redirectUri) { String state = getStateCode(); String scopeParam = TokenUtil.attachOIDCScope(scope); UriBuilder uriBuilder = UriBuilder.fromUri(authUrl) .queryParam(OAuth2Constants.CLIENT_ID, clientId) .queryParam(OAuth2Constants.REDIRECT_URI, redirectUri) .queryParam(OAuth2Constants.STATE, state) .queryParam(OAuth2Constants.SCOPE, scopeParam); URI url = uriBuilder.build(); NewCookie cookie = new NewCookie(getStateCookieName(), state, getStateCookiePath(uriInfo), null, null, -1, isSecure, true); logger.fine("NewCookie: " + cookie.toString()); logger.fine("Oauth Redirect to: " + url); return Response.status(302) .location(url) .cookie(cookie).build(); }
KeycloakDeployment resolvedDeployment = resolveDeployment(getDeployment(), request); String authUrl = resolvedDeployment.getAuthUrl().clone().build().toString(); String scopeParam = TokenUtil.attachOIDCScope(scope);
scope = TokenUtil.attachOIDCScope(scope); redirectUriBuilder.queryParam(OAuth2Constants.SCOPE, scope);
public static boolean isOIDCRequest(String scopeParam) { return hasScope(scopeParam, OAuth2Constants.SCOPE_OPENID); }
public static RefreshToken getRefreshToken(String refreshToken) throws JWSInputException { byte[] encodedContent = new JWSInput(refreshToken).getContent(); return getRefreshToken(encodedContent); }
public static String attachOIDCScope(String scopeParam) { if (scopeParam == null || scopeParam.isEmpty()) { return OAuth2Constants.SCOPE_OPENID; } else if (hasScope(scopeParam, OAuth2Constants.SCOPE_OPENID)) { return scopeParam; } else { return OAuth2Constants.SCOPE_OPENID + " " + scopeParam; } }