Example usage for com.google.gson.stream JsonReader nextBoolean

List of usage examples for com.google.gson.stream JsonReader nextBoolean

Introduction

In this page you can find the example usage for com.google.gson.stream JsonReader nextBoolean.

Prototype

public boolean nextBoolean() throws IOException 

Source Link

Document

Returns the com.google.gson.stream.JsonToken#BOOLEAN boolean value of the next token, consuming it.

Usage

From source file:org.mitre.openid.connect.service.impl.AbstractMITREidDataService.java

License:Apache License

protected static Map readMap(JsonReader reader) throws IOException {
    Map map = new HashMap<String, Object>();
    reader.beginObject();//from  ww  w  .j a  v a 2  s .  com
    while (reader.hasNext()) {
        String name = reader.nextName();
        Object value = null;
        switch (reader.peek()) {
        case STRING:
            value = reader.nextString();
            break;
        case BOOLEAN:
            value = reader.nextBoolean();
            break;
        case NUMBER:
            value = reader.nextLong();
            break;
        }
        map.put(name, value);
    }
    reader.endObject();
    return map;
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_0.java

License:Apache License

private OAuth2Request readAuthorizationRequest(JsonReader reader) throws IOException {
    Set<String> scope = new LinkedHashSet<>();
    Set<String> resourceIds = new HashSet<>();
    boolean approved = false;
    Collection<GrantedAuthority> authorities = new HashSet<>();
    Map<String, String> authorizationParameters = new HashMap<>();
    Set<String> responseTypes = new HashSet<>();
    String redirectUri = null;//from  ww  w .j  a  v a  2  s .  com
    String clientId = null;
    reader.beginObject();
    while (reader.hasNext()) {
        switch (reader.peek()) {
        case END_OBJECT:
            continue;
        case NAME:
            String name = reader.nextName();
            if (reader.peek() == JsonToken.NULL) {
                reader.skipValue();
            } else if (name.equals("authorizationParameters")) {
                authorizationParameters = readMap(reader);
            } else if (name.equals("approvalParameters")) {
                reader.skipValue();
            } else if (name.equals("clientId")) {
                clientId = reader.nextString();
            } else if (name.equals("scope")) {
                scope = readSet(reader);
            } else if (name.equals("resourceIds")) {
                resourceIds = readSet(reader);
            } else if (name.equals("authorities")) {
                Set<String> authorityStrs = readSet(reader);
                authorities = new HashSet<>();
                for (String s : authorityStrs) {
                    GrantedAuthority ga = new SimpleGrantedAuthority(s);
                    authorities.add(ga);
                }
            } else if (name.equals("approved")) {
                approved = reader.nextBoolean();
            } else if (name.equals("denied")) {
                if (approved == false) {
                    approved = !reader.nextBoolean();
                }
            } else if (name.equals("redirectUri")) {
                redirectUri = reader.nextString();
            } else if (name.equals("responseTypes")) {
                responseTypes = readSet(reader);
            } else {
                reader.skipValue();
            }
            break;
        default:
            logger.debug("Found unexpected entry");
            reader.skipValue();
            continue;
        }
    }
    reader.endObject();
    return new OAuth2Request(authorizationParameters, clientId, authorities, approved, scope, resourceIds,
            redirectUri, responseTypes, null);
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_0.java

License:Apache License

/**
 * @param reader//ww w  . j a  v a2 s .com
 * @return
 * @throws IOException
 */
private SavedUserAuthentication readSavedUserAuthentication(JsonReader reader) throws IOException {
    SavedUserAuthentication savedUserAuth = new SavedUserAuthentication();
    reader.beginObject();

    while (reader.hasNext()) {
        switch (reader.peek()) {
        case END_OBJECT:
            continue;
        case NAME:
            String name = reader.nextName();
            if (reader.peek() == JsonToken.NULL) {
                reader.skipValue();
            } else if (name.equals("name")) {
                savedUserAuth.setName(reader.nextString());
            } else if (name.equals("sourceClass")) {
                savedUserAuth.setSourceClass(reader.nextString());
            } else if (name.equals("authenticated")) {
                savedUserAuth.setAuthenticated(reader.nextBoolean());
            } else if (name.equals("authorities")) {
                Set<String> authorityStrs = readSet(reader);
                Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
                for (String s : authorityStrs) {
                    GrantedAuthority ga = new SimpleGrantedAuthority(s);
                    authorities.add(ga);
                }
                savedUserAuth.setAuthorities(authorities);
            } else {
                logger.debug("Found unexpected entry");
                reader.skipValue();
            }
            break;
        default:
            logger.debug("Found unexpected entry");
            reader.skipValue();
            continue;
        }
    }

    reader.endObject();
    return savedUserAuth;
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_0.java

License:Apache License

/**
 * @param reader//from   w  w w .  j a va  2s .c  o m
 * @throws IOException
 */
private void readClients(JsonReader reader) throws IOException {
    reader.beginArray();
    while (reader.hasNext()) {
        ClientDetailsEntity client = new ClientDetailsEntity();
        reader.beginObject();
        while (reader.hasNext()) {
            switch (reader.peek()) {
            case END_OBJECT:
                continue;
            case NAME:
                String name = reader.nextName();
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                } else if (name.equals("clientId")) {
                    client.setClientId(reader.nextString());
                } else if (name.equals("resourceIds")) {
                    Set<String> resourceIds = readSet(reader);
                    client.setResourceIds(resourceIds);
                } else if (name.equals("secret")) {
                    client.setClientSecret(reader.nextString());
                } else if (name.equals("scope")) {
                    Set<String> scope = readSet(reader);
                    client.setScope(scope);
                } else if (name.equals("authorities")) {
                    Set<String> authorityStrs = readSet(reader);
                    Set<GrantedAuthority> authorities = new HashSet<>();
                    for (String s : authorityStrs) {
                        GrantedAuthority ga = new SimpleGrantedAuthority(s);
                        authorities.add(ga);
                    }
                    client.setAuthorities(authorities);
                } else if (name.equals("accessTokenValiditySeconds")) {
                    client.setAccessTokenValiditySeconds(reader.nextInt());
                } else if (name.equals("refreshTokenValiditySeconds")) {
                    client.setRefreshTokenValiditySeconds(reader.nextInt());
                } else if (name.equals("redirectUris")) {
                    Set<String> redirectUris = readSet(reader);
                    client.setRedirectUris(redirectUris);
                } else if (name.equals("name")) {
                    client.setClientName(reader.nextString());
                } else if (name.equals("uri")) {
                    client.setClientUri(reader.nextString());
                } else if (name.equals("logoUri")) {
                    client.setLogoUri(reader.nextString());
                } else if (name.equals("contacts")) {
                    Set<String> contacts = readSet(reader);
                    client.setContacts(contacts);
                } else if (name.equals("tosUri")) {
                    client.setTosUri(reader.nextString());
                } else if (name.equals("tokenEndpointAuthMethod")) {
                    AuthMethod am = AuthMethod.getByValue(reader.nextString());
                    client.setTokenEndpointAuthMethod(am);
                } else if (name.equals("grantTypes")) {
                    Set<String> grantTypes = readSet(reader);
                    client.setGrantTypes(grantTypes);
                } else if (name.equals("responseTypes")) {
                    Set<String> responseTypes = readSet(reader);
                    client.setResponseTypes(responseTypes);
                } else if (name.equals("policyUri")) {
                    client.setPolicyUri(reader.nextString());
                } else if (name.equals("applicationType")) {
                    AppType appType = AppType.getByValue(reader.nextString());
                    client.setApplicationType(appType);
                } else if (name.equals("sectorIdentifierUri")) {
                    client.setSectorIdentifierUri(reader.nextString());
                } else if (name.equals("subjectType")) {
                    SubjectType st = SubjectType.getByValue(reader.nextString());
                    client.setSubjectType(st);
                } else if (name.equals("jwks_uri")) {
                    client.setJwksUri(reader.nextString());
                } else if (name.equals("requestObjectSigningAlg")) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setRequestObjectSigningAlg(alg);
                } else if (name.equals("userInfoEncryptedResponseAlg")) {
                    JWEAlgorithm alg = JWEAlgorithm.parse(reader.nextString());
                    client.setUserInfoEncryptedResponseAlg(alg);
                } else if (name.equals("userInfoEncryptedResponseEnc")) {
                    EncryptionMethod alg = EncryptionMethod.parse(reader.nextString());
                    client.setUserInfoEncryptedResponseEnc(alg);
                } else if (name.equals("userInfoSignedResponseAlg")) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setUserInfoSignedResponseAlg(alg);
                } else if (name.equals("idTokenSignedResonseAlg")) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setIdTokenSignedResponseAlg(alg);
                } else if (name.equals("idTokenEncryptedResponseAlg")) {
                    JWEAlgorithm alg = JWEAlgorithm.parse(reader.nextString());
                    client.setIdTokenEncryptedResponseAlg(alg);
                } else if (name.equals("idTokenEncryptedResponseEnc")) {
                    EncryptionMethod alg = EncryptionMethod.parse(reader.nextString());
                    client.setIdTokenEncryptedResponseEnc(alg);
                } else if (name.equals("tokenEndpointAuthSigningAlg")) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setTokenEndpointAuthSigningAlg(alg);
                } else if (name.equals("defaultMaxAge")) {
                    client.setDefaultMaxAge(reader.nextInt());
                } else if (name.equals("requireAuthTime")) {
                    client.setRequireAuthTime(reader.nextBoolean());
                } else if (name.equals("defaultACRValues")) {
                    Set<String> defaultACRvalues = readSet(reader);
                    client.setDefaultACRvalues(defaultACRvalues);
                } else if (name.equals("initiateLoginUri")) {
                    client.setInitiateLoginUri(reader.nextString());
                } else if (name.equals("postLogoutRedirectUri")) {
                    HashSet<String> postLogoutUris = Sets.newHashSet(reader.nextString());
                    client.setPostLogoutRedirectUris(postLogoutUris);
                } else if (name.equals("requestUris")) {
                    Set<String> requestUris = readSet(reader);
                    client.setRequestUris(requestUris);
                } else if (name.equals("description")) {
                    client.setClientDescription(reader.nextString());
                } else if (name.equals("allowIntrospection")) {
                    client.setAllowIntrospection(reader.nextBoolean());
                } else if (name.equals("reuseRefreshToken")) {
                    client.setReuseRefreshToken(reader.nextBoolean());
                } else if (name.equals("dynamicallyRegistered")) {
                    client.setDynamicallyRegistered(reader.nextBoolean());
                } else {
                    logger.debug("Found unexpected entry");
                    reader.skipValue();
                }
                break;
            default:
                logger.debug("Found unexpected entry");
                reader.skipValue();
                continue;
            }
        }
        reader.endObject();
        clientRepository.saveClient(client);
    }
    reader.endArray();
    logger.info("Done reading clients");
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_0.java

License:Apache License

/**
 * Read the list of system scopes from the reader and insert them into the
 * scope repository.//from   w ww .  ja  v  a2  s  .  co m
 *
 * @param reader
 * @throws IOException
 */
private void readSystemScopes(JsonReader reader) throws IOException {
    reader.beginArray();
    while (reader.hasNext()) {
        SystemScope scope = new SystemScope();
        reader.beginObject();
        while (reader.hasNext()) {
            switch (reader.peek()) {
            case END_OBJECT:
                continue;
            case NAME:
                String name = reader.nextName();
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                } else if (name.equals("value")) {
                    scope.setValue(reader.nextString());
                } else if (name.equals("description")) {
                    scope.setDescription(reader.nextString());
                } else if (name.equals("allowDynReg")) {
                    // previously "allowDynReg" scopes are now tagged as "not restricted" and vice versa
                    scope.setRestricted(!reader.nextBoolean());
                } else if (name.equals("defaultScope")) {
                    scope.setDefaultScope(reader.nextBoolean());
                } else if (name.equals("icon")) {
                    scope.setIcon(reader.nextString());
                } else {
                    logger.debug("found unexpected entry");
                    reader.skipValue();
                }
                break;
            default:
                logger.debug("Found unexpected entry");
                reader.skipValue();
                continue;
            }
        }
        reader.endObject();
        sysScopeRepository.save(scope);
    }
    reader.endArray();
    logger.info("Done reading system scopes");
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_1.java

License:Apache License

private OAuth2Request readAuthorizationRequest(JsonReader reader) throws IOException {
    Set<String> scope = new LinkedHashSet<>();
    Set<String> resourceIds = new HashSet<>();
    boolean approved = false;
    Collection<GrantedAuthority> authorities = new HashSet<>();
    Map<String, String> requestParameters = new HashMap<>();
    Set<String> responseTypes = new HashSet<>();
    Map<String, Serializable> extensions = new HashMap<>();
    String redirectUri = null;//from w  w w . j a  va 2  s.  c  o  m
    String clientId = null;
    reader.beginObject();
    while (reader.hasNext()) {
        switch (reader.peek()) {
        case END_OBJECT:
            continue;
        case NAME:
            String name = reader.nextName();
            if (reader.peek() == JsonToken.NULL) {
                reader.skipValue();
            } else if (name.equals("requestParameters")) {
                requestParameters = readMap(reader);
            } else if (name.equals("clientId")) {
                clientId = reader.nextString();
            } else if (name.equals("scope")) {
                scope = readSet(reader);
            } else if (name.equals("resourceIds")) {
                resourceIds = readSet(reader);
            } else if (name.equals("authorities")) {
                Set<String> authorityStrs = readSet(reader);
                authorities = new HashSet<>();
                for (String s : authorityStrs) {
                    GrantedAuthority ga = new SimpleGrantedAuthority(s);
                    authorities.add(ga);
                }
            } else if (name.equals("approved")) {
                approved = reader.nextBoolean();
            } else if (name.equals("denied")) {
                if (approved == false) {
                    approved = !reader.nextBoolean();
                }
            } else if (name.equals("redirectUri")) {
                redirectUri = reader.nextString();
            } else if (name.equals("responseTypes")) {
                responseTypes = readSet(reader);
            } else if (name.equals("extensions")) {
                // skip the binary encoded version
                reader.skipValue();
            } else if (name.equals("extensionStrings")) {
                Map<String, String> extEnc = readMap(reader);
                for (Entry<String, String> entry : extEnc.entrySet()) {
                    extensions.put(entry.getKey(), entry.getValue());
                }
            } else {
                reader.skipValue();
            }
            break;
        default:
            logger.debug("Found unexpected entry");
            reader.skipValue();
            continue;
        }
    }
    reader.endObject();
    return new OAuth2Request(requestParameters, clientId, authorities, approved, scope, resourceIds,
            redirectUri, responseTypes, extensions);
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_1.java

License:Apache License

/**
 * Read the list of system scopes from the reader and insert them into the
 * scope repository./*from   ww  w  . j  a va  2s .co  m*/
 *
 * @param reader
 * @throws IOException
 */
private void readSystemScopes(JsonReader reader) throws IOException {
    reader.beginArray();
    while (reader.hasNext()) {
        SystemScope scope = new SystemScope();
        reader.beginObject();
        while (reader.hasNext()) {
            switch (reader.peek()) {
            case END_OBJECT:
                continue;
            case NAME:
                String name = reader.nextName();
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                } else if (name.equals("value")) {
                    scope.setValue(reader.nextString());
                } else if (name.equals("description")) {
                    scope.setDescription(reader.nextString());
                } else if (name.equals("allowDynReg")) {
                    // previously "allowDynReg" scopes are now tagged as "not restricted" and vice versa
                    scope.setRestricted(!reader.nextBoolean());
                } else if (name.equals("defaultScope")) {
                    scope.setDefaultScope(reader.nextBoolean());
                } else if (name.equals("structured")) {
                    logger.warn("Found a structured scope, ignoring structure");
                } else if (name.equals("structuredParameter")) {
                    logger.warn("Found a structured scope, ignoring structure");
                } else if (name.equals("icon")) {
                    scope.setIcon(reader.nextString());
                } else {
                    logger.debug("found unexpected entry");
                    reader.skipValue();
                }
                break;
            default:
                logger.debug("Found unexpected entry");
                reader.skipValue();
                continue;
            }
        }
        reader.endObject();
        sysScopeRepository.save(scope);
    }
    reader.endArray();
    logger.info("Done reading system scopes");
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_2.java

License:Apache License

/**
 * @param reader// w w  w . j a v  a 2 s .c o  m
 * @throws IOException
 */
private void readAuthenticationHolders(JsonReader reader) throws IOException {
    reader.beginArray();
    while (reader.hasNext()) {
        AuthenticationHolderEntity ahe = new AuthenticationHolderEntity();
        reader.beginObject();
        Long currentId = null;
        while (reader.hasNext()) {
            switch (reader.peek()) {
            case END_OBJECT:
                continue;
            case NAME:
                String name = reader.nextName();
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                } else if (name.equals(ID)) {
                    currentId = reader.nextLong();
                } else if (name.equals(REQUEST_PARAMETERS)) {
                    ahe.setRequestParameters(readMap(reader));
                } else if (name.equals(CLIENT_ID)) {
                    ahe.setClientId(reader.nextString());
                } else if (name.equals(SCOPE)) {
                    ahe.setScope(readSet(reader));
                } else if (name.equals(RESOURCE_IDS)) {
                    ahe.setResourceIds(readSet(reader));
                } else if (name.equals(AUTHORITIES)) {
                    Set<String> authorityStrs = readSet(reader);
                    Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
                    for (String s : authorityStrs) {
                        GrantedAuthority ga = new SimpleGrantedAuthority(s);
                        authorities.add(ga);
                    }
                    ahe.setAuthorities(authorities);
                } else if (name.equals(APPROVED)) {
                    ahe.setApproved(reader.nextBoolean());
                } else if (name.equals(REDIRECT_URI)) {
                    ahe.setRedirectUri(reader.nextString());
                } else if (name.equals(RESPONSE_TYPES)) {
                    ahe.setResponseTypes(readSet(reader));
                } else if (name.equals(EXTENSIONS)) {
                    ahe.setExtensions(readMap(reader));
                } else if (name.equals(SAVED_USER_AUTHENTICATION)) {
                    ahe.setUserAuth(readSavedUserAuthentication(reader));
                } else {
                    logger.debug("Found unexpected entry");
                    reader.skipValue();
                }
                break;
            default:
                logger.debug("Found unexpected entry");
                reader.skipValue();
                continue;
            }
        }
        reader.endObject();
        Long newId = authHolderRepository.save(ahe).getId();
        maps.getAuthHolderOldToNewIdMap().put(currentId, newId);
        logger.debug("Read authentication holder {}", currentId);
    }
    reader.endArray();
    logger.info("Done reading authentication holders");
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_2.java

License:Apache License

/**
 * @param reader/*from w ww. j a v a2 s.c  o m*/
 * @return
 * @throws IOException
 */
private SavedUserAuthentication readSavedUserAuthentication(JsonReader reader) throws IOException {
    SavedUserAuthentication savedUserAuth = new SavedUserAuthentication();
    reader.beginObject();

    while (reader.hasNext()) {
        switch (reader.peek()) {
        case END_OBJECT:
            continue;
        case NAME:
            String name = reader.nextName();
            if (reader.peek() == JsonToken.NULL) {
                reader.skipValue();
            } else if (name.equals(NAME)) {
                savedUserAuth.setName(reader.nextString());
            } else if (name.equals(SOURCE_CLASS)) {
                savedUserAuth.setSourceClass(reader.nextString());
            } else if (name.equals(AUTHENTICATED)) {
                savedUserAuth.setAuthenticated(reader.nextBoolean());
            } else if (name.equals(AUTHORITIES)) {
                Set<String> authorityStrs = readSet(reader);
                Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
                for (String s : authorityStrs) {
                    GrantedAuthority ga = new SimpleGrantedAuthority(s);
                    authorities.add(ga);
                }
                savedUserAuth.setAuthorities(authorities);
            } else {
                logger.debug("Found unexpected entry");
                reader.skipValue();
            }
            break;
        default:
            logger.debug("Found unexpected entry");
            reader.skipValue();
            continue;
        }
    }

    reader.endObject();
    return savedUserAuth;
}

From source file:org.mitre.openid.connect.service.impl.MITREidDataService_1_2.java

License:Apache License

/**
 * @param reader//w  ww .ja v a 2s .  com
 * @throws IOException
 */
private void readClients(JsonReader reader) throws IOException {
    reader.beginArray();
    while (reader.hasNext()) {
        ClientDetailsEntity client = new ClientDetailsEntity();
        reader.beginObject();
        while (reader.hasNext()) {
            switch (reader.peek()) {
            case END_OBJECT:
                continue;
            case NAME:
                String name = reader.nextName();
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                } else if (name.equals(CLIENT_ID)) {
                    client.setClientId(reader.nextString());
                } else if (name.equals(RESOURCE_IDS)) {
                    Set<String> resourceIds = readSet(reader);
                    client.setResourceIds(resourceIds);
                } else if (name.equals(SECRET)) {
                    client.setClientSecret(reader.nextString());
                } else if (name.equals(SCOPE)) {
                    Set<String> scope = readSet(reader);
                    client.setScope(scope);
                } else if (name.equals(AUTHORITIES)) {
                    Set<String> authorityStrs = readSet(reader);
                    Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
                    for (String s : authorityStrs) {
                        GrantedAuthority ga = new SimpleGrantedAuthority(s);
                        authorities.add(ga);
                    }
                    client.setAuthorities(authorities);
                } else if (name.equals(ACCESS_TOKEN_VALIDITY_SECONDS)) {
                    client.setAccessTokenValiditySeconds(reader.nextInt());
                } else if (name.equals(REFRESH_TOKEN_VALIDITY_SECONDS)) {
                    client.setRefreshTokenValiditySeconds(reader.nextInt());
                } else if (name.equals(REDIRECT_URIS)) {
                    Set<String> redirectUris = readSet(reader);
                    client.setRedirectUris(redirectUris);
                } else if (name.equals(CLAIMS_REDIRECT_URIS)) {
                    Set<String> claimsRedirectUris = readSet(reader);
                    client.setClaimsRedirectUris(claimsRedirectUris);
                } else if (name.equals(NAME)) {
                    client.setClientName(reader.nextString());
                } else if (name.equals(URI)) {
                    client.setClientUri(reader.nextString());
                } else if (name.equals(LOGO_URI)) {
                    client.setLogoUri(reader.nextString());
                } else if (name.equals(CONTACTS)) {
                    Set<String> contacts = readSet(reader);
                    client.setContacts(contacts);
                } else if (name.equals(TOS_URI)) {
                    client.setTosUri(reader.nextString());
                } else if (name.equals(TOKEN_ENDPOINT_AUTH_METHOD)) {
                    AuthMethod am = AuthMethod.getByValue(reader.nextString());
                    client.setTokenEndpointAuthMethod(am);
                } else if (name.equals(GRANT_TYPES)) {
                    Set<String> grantTypes = readSet(reader);
                    client.setGrantTypes(grantTypes);
                } else if (name.equals(RESPONSE_TYPES)) {
                    Set<String> responseTypes = readSet(reader);
                    client.setResponseTypes(responseTypes);
                } else if (name.equals(POLICY_URI)) {
                    client.setPolicyUri(reader.nextString());
                } else if (name.equals(APPLICATION_TYPE)) {
                    AppType appType = AppType.getByValue(reader.nextString());
                    client.setApplicationType(appType);
                } else if (name.equals(SECTOR_IDENTIFIER_URI)) {
                    client.setSectorIdentifierUri(reader.nextString());
                } else if (name.equals(SUBJECT_TYPE)) {
                    SubjectType st = SubjectType.getByValue(reader.nextString());
                    client.setSubjectType(st);
                } else if (name.equals(JWKS_URI)) {
                    client.setJwksUri(reader.nextString());
                } else if (name.equals(JWKS)) {
                    try {
                        client.setJwks(JWKSet.parse(reader.nextString()));
                    } catch (ParseException e) {
                        logger.error("Couldn't parse JWK Set", e);
                    }
                } else if (name.equals(REQUEST_OBJECT_SIGNING_ALG)) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setRequestObjectSigningAlg(alg);
                } else if (name.equals(USER_INFO_ENCRYPTED_RESPONSE_ALG)) {
                    JWEAlgorithm alg = JWEAlgorithm.parse(reader.nextString());
                    client.setUserInfoEncryptedResponseAlg(alg);
                } else if (name.equals(USER_INFO_ENCRYPTED_RESPONSE_ENC)) {
                    EncryptionMethod alg = EncryptionMethod.parse(reader.nextString());
                    client.setUserInfoEncryptedResponseEnc(alg);
                } else if (name.equals(USER_INFO_SIGNED_RESPONSE_ALG)) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setUserInfoSignedResponseAlg(alg);
                } else if (name.equals(ID_TOKEN_SIGNED_RESPONSE_ALG)) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setIdTokenSignedResponseAlg(alg);
                } else if (name.equals(ID_TOKEN_ENCRYPTED_RESPONSE_ALG)) {
                    JWEAlgorithm alg = JWEAlgorithm.parse(reader.nextString());
                    client.setIdTokenEncryptedResponseAlg(alg);
                } else if (name.equals(ID_TOKEN_ENCRYPTED_RESPONSE_ENC)) {
                    EncryptionMethod alg = EncryptionMethod.parse(reader.nextString());
                    client.setIdTokenEncryptedResponseEnc(alg);
                } else if (name.equals(TOKEN_ENDPOINT_AUTH_SIGNING_ALG)) {
                    JWSAlgorithm alg = JWSAlgorithm.parse(reader.nextString());
                    client.setTokenEndpointAuthSigningAlg(alg);
                } else if (name.equals(DEFAULT_MAX_AGE)) {
                    client.setDefaultMaxAge(reader.nextInt());
                } else if (name.equals(REQUIRE_AUTH_TIME)) {
                    client.setRequireAuthTime(reader.nextBoolean());
                } else if (name.equals(DEFAULT_ACR_VALUES)) {
                    Set<String> defaultACRvalues = readSet(reader);
                    client.setDefaultACRvalues(defaultACRvalues);
                } else if (name.equals("initiateLoginUri")) {
                    client.setInitiateLoginUri(reader.nextString());
                } else if (name.equals(POST_LOGOUT_REDIRECT_URI)) {
                    Set<String> postLogoutUris = readSet(reader);
                    client.setPostLogoutRedirectUris(postLogoutUris);
                } else if (name.equals(REQUEST_URIS)) {
                    Set<String> requestUris = readSet(reader);
                    client.setRequestUris(requestUris);
                } else if (name.equals(DESCRIPTION)) {
                    client.setClientDescription(reader.nextString());
                } else if (name.equals(ALLOW_INTROSPECTION)) {
                    client.setAllowIntrospection(reader.nextBoolean());
                } else if (name.equals(REUSE_REFRESH_TOKEN)) {
                    client.setReuseRefreshToken(reader.nextBoolean());
                } else if (name.equals(CLEAR_ACCESS_TOKENS_ON_REFRESH)) {
                    client.setClearAccessTokensOnRefresh(reader.nextBoolean());
                } else if (name.equals(DYNAMICALLY_REGISTERED)) {
                    client.setDynamicallyRegistered(reader.nextBoolean());
                } else {
                    logger.debug("Found unexpected entry");
                    reader.skipValue();
                }
                break;
            default:
                logger.debug("Found unexpected entry");
                reader.skipValue();
                continue;
            }
        }
        reader.endObject();
        clientRepository.saveClient(client);
    }
    reader.endArray();
    logger.info("Done reading clients");
}