@Test void testResolveOIDCTokenFromAuthConfigShouldReturnOldTokenWhenRefreshNotSupported() { Map<String, String> currentAuthProviderConfig = new HashMap<>(); currentAuthProviderConfig.put(CLIENT_ID_KUBECONFIG, "client-id"); currentAuthProviderConfig.put(CLIENT_SECRET_KUBECONFIG, "client-secret"); currentAuthProviderConfig.put(ID_TOKEN_KUBECONFIG, "id-token"); String token = OpenIDConnectionUtils.resolveOIDCTokenFromAuthConfig(currentAuthProviderConfig); assertEquals("id-token", token); }
public static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig) { String accessToken = currentAuthProviderConfig.get(ID_TOKEN_KUBECONFIG); String issuer = currentAuthProviderConfig.get(ISSUER_KUBECONFIG); String clientId = currentAuthProviderConfig.get(CLIENT_ID_KUBECONFIG); String refreshToken = currentAuthProviderConfig.get(REFRESH_TOKEN_KUBECONFIG); String clientSecret = currentAuthProviderConfig.getOrDefault(CLIENT_SECRET_KUBECONFIG, ""); String idpCert = currentAuthProviderConfig.get(IDP_CERT_DATA); if (isTokenRefreshSupported(currentAuthProviderConfig)) { return getOIDCProviderTokenEndpointAndRefreshToken(issuer, clientId, refreshToken, clientSecret, accessToken, idpCert); } return accessToken; }
OpenIDConnectionUtils { public static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig) { String accessToken = currentAuthProviderConfig.get(ID_TOKEN_KUBECONFIG); String issuer = currentAuthProviderConfig.get(ISSUER_KUBECONFIG); String clientId = currentAuthProviderConfig.get(CLIENT_ID_KUBECONFIG); String refreshToken = currentAuthProviderConfig.get(REFRESH_TOKEN_KUBECONFIG); String clientSecret = currentAuthProviderConfig.getOrDefault(CLIENT_SECRET_KUBECONFIG, ""); String idpCert = currentAuthProviderConfig.get(IDP_CERT_DATA); if (isTokenRefreshSupported(currentAuthProviderConfig)) { return getOIDCProviderTokenEndpointAndRefreshToken(issuer, clientId, refreshToken, clientSecret, accessToken, idpCert); } return accessToken; } }
OpenIDConnectionUtils { public static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig) { String accessToken = currentAuthProviderConfig.get(ID_TOKEN_KUBECONFIG); String issuer = currentAuthProviderConfig.get(ISSUER_KUBECONFIG); String clientId = currentAuthProviderConfig.get(CLIENT_ID_KUBECONFIG); String refreshToken = currentAuthProviderConfig.get(REFRESH_TOKEN_KUBECONFIG); String clientSecret = currentAuthProviderConfig.getOrDefault(CLIENT_SECRET_KUBECONFIG, ""); String idpCert = currentAuthProviderConfig.get(IDP_CERT_DATA); if (isTokenRefreshSupported(currentAuthProviderConfig)) { return getOIDCProviderTokenEndpointAndRefreshToken(issuer, clientId, refreshToken, clientSecret, accessToken, idpCert); } return accessToken; } private  OpenIDConnectionUtils(); }
OpenIDConnectionUtils { public static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig) { String accessToken = currentAuthProviderConfig.get(ID_TOKEN_KUBECONFIG); String issuer = currentAuthProviderConfig.get(ISSUER_KUBECONFIG); String clientId = currentAuthProviderConfig.get(CLIENT_ID_KUBECONFIG); String refreshToken = currentAuthProviderConfig.get(REFRESH_TOKEN_KUBECONFIG); String clientSecret = currentAuthProviderConfig.getOrDefault(CLIENT_SECRET_KUBECONFIG, ""); String idpCert = currentAuthProviderConfig.get(IDP_CERT_DATA); if (isTokenRefreshSupported(currentAuthProviderConfig)) { return getOIDCProviderTokenEndpointAndRefreshToken(issuer, clientId, refreshToken, clientSecret, accessToken, idpCert); } return accessToken; } private  OpenIDConnectionUtils(); static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig); }
OpenIDConnectionUtils { public static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig) { String accessToken = currentAuthProviderConfig.get(ID_TOKEN_KUBECONFIG); String issuer = currentAuthProviderConfig.get(ISSUER_KUBECONFIG); String clientId = currentAuthProviderConfig.get(CLIENT_ID_KUBECONFIG); String refreshToken = currentAuthProviderConfig.get(REFRESH_TOKEN_KUBECONFIG); String clientSecret = currentAuthProviderConfig.getOrDefault(CLIENT_SECRET_KUBECONFIG, ""); String idpCert = currentAuthProviderConfig.get(IDP_CERT_DATA); if (isTokenRefreshSupported(currentAuthProviderConfig)) { return getOIDCProviderTokenEndpointAndRefreshToken(issuer, clientId, refreshToken, clientSecret, accessToken, idpCert); } return accessToken; } private  OpenIDConnectionUtils(); static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig); static final String ID_TOKEN_KUBECONFIG; static final String ISSUER_KUBECONFIG; static final String REFRESH_TOKEN_KUBECONFIG; static final String REFRESH_TOKEN_PARAM; static final String GRANT_TYPE_PARAM; static final String CLIENT_ID_PARAM; static final String CLIENT_SECRET_PARAM; static final String ID_TOKEN_PARAM; static final String ACCESS_TOKEN_PARAM; static final String CLIENT_ID_KUBECONFIG; static final String CLIENT_SECRET_KUBECONFIG; static final String IDP_CERT_DATA; static final String TOKEN_ENDPOINT_PARAM; static final String WELL_KNOWN_OPENID_CONFIGURATION; static final String GRANT_TYPE_REFRESH_TOKEN; }