summaryrefslogtreecommitdiff
path: root/src/com/p4square/f1oauth
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/f1oauth
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/f1oauth')
-rw-r--r--src/com/p4square/f1oauth/FellowshipOneIntegrationDriver.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/com/p4square/f1oauth/FellowshipOneIntegrationDriver.java b/src/com/p4square/f1oauth/FellowshipOneIntegrationDriver.java
new file mode 100644
index 0000000..e72df5e
--- /dev/null
+++ b/src/com/p4square/f1oauth/FellowshipOneIntegrationDriver.java
@@ -0,0 +1,45 @@
+package com.p4square.f1oauth;
+
+import com.codahale.metrics.MetricRegistry;
+import com.p4square.grow.config.Config;
+import com.p4square.grow.frontend.IntegrationDriver;
+import org.restlet.Context;
+import org.restlet.security.Verifier;
+
+/**
+ * The FellowshipOneIntegrationDriver creates implementations of various
+ * objects to support integration with Fellowship One.
+ */
+public class FellowshipOneIntegrationDriver implements IntegrationDriver {
+
+ private final Context mContext;
+ private final MetricRegistry mMetricRegistry;
+ private final Config mConfig;
+ private final F1Access mAPI;
+
+ public FellowshipOneIntegrationDriver(final Context context) {
+ mContext = context;
+ mConfig = (Config) context.getAttributes().get("com.p4square.grow.config");
+ mMetricRegistry = (MetricRegistry) context.getAttributes().get("com.p4square.grow.metrics");
+
+ mAPI = new F1Access(context,
+ mConfig.getString("f1ConsumerKey", ""),
+ mConfig.getString("f1ConsumerSecret", ""),
+ mConfig.getString("f1BaseUrl", "staging.fellowshiponeapi.com"),
+ mConfig.getString("f1ChurchCode", "pfseawa"),
+ F1Access.UserType.WEBLINK);
+ mAPI.setMetricRegistry(mMetricRegistry);
+ }
+
+ /**
+ * @return An F1Access instance.
+ */
+ public F1Access getF1Access() {
+ return mAPI;
+ }
+
+ @Override
+ public Verifier newUserAuthenticationVerifier() {
+ return new SecondPartyVerifier(mContext, mAPI);
+ }
+}