Search in sources :

Example 1 with FieldSet

use of org.xdi.model.passport.FieldSet in project oxTrust by GluuFederation.

the class PassportRestWebService method getPassportConfig.

@GET
@Produces({ MediaType.APPLICATION_JSON })
public Response getPassportConfig(@HeaderParam("Authorization") String authorization) {
    Response authorizationResponse = processAuthorization(authorization);
    if (authorizationResponse != null) {
        return authorizationResponse;
    }
    PassportConfigResponse passportConfigResponse = new PassportConfigResponse();
    Map<String, Map> strategies = new HashMap<String, Map>();
    LdapOxPassportConfiguration ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
    if (ldapOxPassportConfiguration != null) {
        for (org.xdi.model.passport.PassportConfiguration passportConfiguration : ldapOxPassportConfiguration.getPassportConfigurations()) {
            if (passportConfiguration != null) {
                Map<String, String> map = new HashMap();
                List<FieldSet> passList = passportConfiguration.getFieldset();
                for (FieldSet fieldset : passList) {
                    map.put(fieldset.getKey(), fieldset.getValue());
                }
                strategies.put(passportConfiguration.getStrategy(), map);
            }
        }
    }
    passportConfigResponse.setPassportStrategies(strategies);
    String passportConfigResponseJson;
    try {
        passportConfigResponseJson = jsonService.objectToPerttyJson(passportConfigResponse);
    } catch (IOException ex) {
        return getErrorResponse(Response.Status.FORBIDDEN, "Failed to prepare configuration");
    }
    return Response.status(Response.Status.OK).entity(passportConfigResponseJson).build();
}
Also used : LdapOxPassportConfiguration(org.xdi.config.oxtrust.LdapOxPassportConfiguration) HashMap(java.util.HashMap) IOException(java.io.IOException) PassportConfigResponse(org.gluu.oxtrust.model.passport.PassportConfigResponse) Response(javax.ws.rs.core.Response) FieldSet(org.xdi.model.passport.FieldSet) PassportConfigResponse(org.gluu.oxtrust.model.passport.PassportConfigResponse) HashMap(java.util.HashMap) Map(java.util.Map) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 PassportConfigResponse (org.gluu.oxtrust.model.passport.PassportConfigResponse)1 LdapOxPassportConfiguration (org.xdi.config.oxtrust.LdapOxPassportConfiguration)1 FieldSet (org.xdi.model.passport.FieldSet)1