Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in aad-starter-sample #22109

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;

public class JsonMapper {
private static final Logger LOGGER = LoggerFactory.getLogger(JsonMapper.class);
private static final ObjectMapper MAPPER = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
static {
MAPPER.registerModule(new JavaTimeModule());
}

public static final String toJsonString(OAuth2AuthorizedClient authorizedClient) {
String clientJsonString = "Json String for OAuth2AuthorizedClient";

public static String toJsonString(OAuth2AuthorizedClient authorizedClient) {
String clientJsonString;
try {
clientJsonString = MAPPER.writeValueAsString(authorizedClient);
} catch (JsonProcessingException e) {
LOGGER.warn("Error with transfer OAuth2AuthorizedClient to Json");
LOGGER.warn("Error when transfer OAuth2AuthorizedClient to Json", e);
clientJsonString = "Fail to generate Json String of current OAuth2AuthorizedClient";
}

LOGGER.info(clientJsonString);
return clientJsonString;
}
Expand Down