Search in sources :

Example 6 with OauthServer

use of net.geoprism.account.OauthServer in project geoprism-registry by terraframe.

the class RegistryService method oauthGetAll.

@Request(RequestType.SESSION)
public String oauthGetAll(String sessionId, String id) {
    final JsonArray ja = new JsonArray();
    if (id == null || id.length() == 0) {
        OauthServer[] servers = OauthServer.getAll();
        for (OauthServer server : servers) {
            Gson gson2 = new GsonBuilder().registerTypeAdapter(OauthServer.class, new RunwayJsonAdapters.RunwayDeserializer()).create();
            JsonObject json = (JsonObject) gson2.toJsonTree(server);
            json.addProperty("url", buildOauthServerUrl(server));
            ja.add(json);
        }
    } else {
        OauthServer server = OauthServer.get(id);
        Gson gson2 = new GsonBuilder().registerTypeAdapter(OauthServer.class, new RunwayJsonAdapters.RunwayDeserializer()).create();
        JsonObject json = (JsonObject) gson2.toJsonTree(server);
        json.addProperty("url", buildOauthServerUrl(server));
        ja.add(json);
    }
    return ja.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) OauthServer(net.geoprism.account.OauthServer) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 7 with OauthServer

use of net.geoprism.account.OauthServer in project geoprism-registry by terraframe.

the class RegistryService method oauthGetPublic.

@Request(RequestType.SESSION)
public String oauthGetPublic(String sessionId, String id) {
    final JsonArray ja = new JsonArray();
    if (id == null || id.length() == 0) {
        OauthServer[] servers = OauthServer.getAll();
        for (OauthServer server : servers) {
            if (!FhirExternalSystem.isFhirOauth(server)) {
                JsonObject json = new JsonObject();
                json.add("label", LocalizedValueConverter.convert(server.getDisplayLabel()).toJSON());
                json.addProperty("url", buildOauthServerUrl(server));
                ja.add(json);
            }
        }
    } else {
        OauthServer server = OauthServer.get(id);
        JsonObject json = new JsonObject();
        json.add("label", LocalizedValueConverter.convert(server.getDisplayLabel()).toJSON());
        json.addProperty("url", buildOauthServerUrl(server));
        ja.add(json);
    }
    return ja.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) OauthServer(net.geoprism.account.OauthServer) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 8 with OauthServer

use of net.geoprism.account.OauthServer in project geoprism-registry by terraframe.

the class JsonSerializationTest method getOauthServer.

@Request
private OauthServer getOauthServer() {
    OauthServer oauth = new OauthServer();
    oauth.setSecretKey("1e6db50c-0fee-11e5-98d0-3c15c2c6caf6");
    oauth.setClientId("geoprism");
    oauth.setProfileLocation("http://test-profile.example.net/profile");
    oauth.setAuthorizationLocation("http://test-profile.example.net/authorization");
    oauth.setTokenLocation("http://test-profile.example.net/token");
    oauth.setServerType("DHIS2");
    oauth.apply();
    return oauth;
}
Also used : OauthServer(net.geoprism.account.OauthServer) Request(com.runwaysdk.session.Request)

Aggregations

OauthServer (net.geoprism.account.OauthServer)8 Request (com.runwaysdk.session.Request)4 JsonObject (com.google.gson.JsonObject)3 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 JsonArray (com.google.gson.JsonArray)2 Authenticate (com.runwaysdk.business.rbac.Authenticate)1 SingleActorDAOIF (com.runwaysdk.business.rbac.SingleActorDAOIF)1 InvalidLoginException (com.runwaysdk.session.InvalidLoginException)1 Organization (net.geoprism.registry.Organization)1 OauthExternalSystem (net.geoprism.registry.etl.OauthExternalSystem)1 DHIS2ExternalSystem (net.geoprism.registry.graph.DHIS2ExternalSystem)1 ExternalSystem (net.geoprism.registry.graph.ExternalSystem)1 FhirExternalSystem (net.geoprism.registry.graph.FhirExternalSystem)1 OAuthClient (org.apache.oltu.oauth2.client.OAuthClient)1 URLConnectionClient (org.apache.oltu.oauth2.client.URLConnectionClient)1 OAuthBearerClientRequest (org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest)1 TokenRequestBuilder (org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder)1 OAuthJSONAccessTokenResponse (org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse)1