summaryrefslogtreecommitdiff
path: root/src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-03-20 17:07:26 -0700
committerJesse Morgan <jesse@jesterpm.net>2016-03-20 17:22:38 -0700
commit55cba1e0f3373fa69d3b9a66f455ad36ab4b82cf (patch)
treebed424a7c2989b8bbd5fb874ae23b9ef674ecd8b /src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java
parentcac52cf3a07fb4c032f352ec48b56640b246f04f (diff)
Adding support for Church Community Builder login.
Beginning with this change all of the Church Management System integration logic is moving into implementations of the new IntegrationDriver interface. The desired IntegrationDriver can be selected by setting the integrationDriver config to the appropriate class name. This commit is only moving login support. Progress reporting will move in a later commit.
Diffstat (limited to 'src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java')
-rw-r--r--src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java b/src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java
new file mode 100644
index 0000000..3aeca2c
--- /dev/null
+++ b/src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java
@@ -0,0 +1,50 @@
+package com.p4square.grow.ccb;
+
+import com.codahale.metrics.MetricRegistry;
+import com.p4square.ccbapi.CCBAPI;
+import com.p4square.ccbapi.CCBAPIClient;
+import com.p4square.grow.config.Config;
+import com.p4square.grow.frontend.IntegrationDriver;
+import org.restlet.Context;
+import org.restlet.security.Verifier;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * The ChurchCommunityBuilderIntegrationDriver is used to integrate Grow with Church Community Builder.
+ */
+public class ChurchCommunityBuilderIntegrationDriver implements IntegrationDriver {
+
+ private final Context mContext;
+ private final MetricRegistry mMetricRegistry;
+ private final Config mConfig;
+
+ private final CCBAPI mAPI;
+
+ public ChurchCommunityBuilderIntegrationDriver(final Context context) {
+ mContext = context;
+ mConfig = (Config) context.getAttributes().get("com.p4square.grow.config");
+ mMetricRegistry = (MetricRegistry) context.getAttributes().get("com.p4square.grow.metrics");
+
+ try {
+ CCBAPI api = new CCBAPIClient(new URI(mConfig.getString("CCBAPIURL", "")),
+ mConfig.getString("CCBAPIUser", ""),
+ mConfig.getString("CCBAPIPassword", ""));
+
+ if (mMetricRegistry != null) {
+ api = new MonitoredCCBAPI(api, mMetricRegistry);
+ }
+
+ mAPI = api;
+
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public Verifier newUserAuthenticationVerifier() {
+ return new CCBUserVerifier(mAPI);
+ }
+}