class OktaIdToken {

    public static OktaIdToken parseIdToken(@NonNull String token) throws IllegalArgumentException {
        String[] sections = token.split("\\.");
        if (sections.length < NUMBER_OF_SECTIONS) {
            throw new IllegalArgumentException("IdToken missing header, claims or" +
                    " signature section");
        }
        Gson gson = new GsonBuilder().registerTypeAdapterFactory(ArrayTypeAdapter.CREATE).create();
        //decode header
        String headerSection = new String(Base64.decode(sections[0], Base64.URL_SAFE));
        Header header = gson.fromJson(headerSection, Header.class);
        //decode claims
        String claimsSection = new String(Base64.decode(sections[1], Base64.URL_SAFE));
        Claims claims = gson.fromJson(claimsSection, Claims.class);
        String signature = new String(Base64.decode(sections[2], Base64.URL_SAFE));
        return new OktaIdToken(header, claims, signature);
    }

    private  OktaIdToken(Header header, Claims claims, String signature);

}