Search in sources :

Example 1 with PassportConfigResponse

use of org.gluu.oxtrust.model.passport.PassportConfigResponse 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)

Example 2 with PassportConfigResponse

use of org.gluu.oxtrust.model.passport.PassportConfigResponse in project oxTrust by GluuFederation.

the class PassportRestWebService method getPassportConfig.

@GET
@Produces({ MediaType.APPLICATION_JSON })
@ProtectedApi
public Response getPassportConfig() {
    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<String, String>();
                List<SimpleExtendedCustomProperty> passList = passportConfiguration.getFieldset();
                if (passList != null) {
                    for (SimpleExtendedCustomProperty fieldset : passList) {
                        map.put(fieldset.getValue1(), fieldset.getValue2());
                    }
                }
                strategies.put(passportConfiguration.getStrategy(), map);
            }
        }
    }
    passportConfigResponse.setPassportStrategies(strategies);
    String passportConfigResponseJson;
    try {
        passportConfigResponseJson = jsonService.objectToPerttyJson(passportConfigResponse);
    } catch (IOException ex) {
        return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "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) SimpleExtendedCustomProperty(org.xdi.model.SimpleExtendedCustomProperty) 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) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi)

Aggregations

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