Skip to content

Instantly share code, notes, and snippets.

@wendelicious
wendelicious / guice-injector-with-security.java
Last active February 11, 2019 18:44
Create Guice Injector using a Security Builder
@Override
protected Injector getInjector() {
return PancakesGuiceInjector.builder()
.addModule(new SuccessCenterApiModule())
.addModule(new LocalSuccessCenterApiModule(), DeploymentEnvironment.DEV)
.addModule(new GoogleCloudSuccessCenterApiModule(), DeploymentEnvironment.excludingEnvironments(DeploymentEnvironment.DEV))
.addModule(new SuccessCenterPolicyServletModule())
@wendelicious
wendelicious / authTokenConfiguration.java
Created September 14, 2016 17:41
Auth token fluent configuration
public static ServletModule infusionsoftIdApplication(String... anonymousPaths) {
final String[] antPaths;
if (null == anonymousPaths) {
antPaths = new String[0];
} else {
antPaths = anonymousPaths;
}
final InfusionsoftIdCasAuthenticator casAuthenticator = new InfusionsoftIdCasAuthenticator();
authBuilder
.verifiesClaimsBy(
c -> firebaseApplicationName.equals(c.getAudience())
)
.verifiesClaimsBy(
c -> (ISSUER_PREFIX + firebaseApplicationName).equals(c.getIssuer())
)
.verifiesClaimsBy(
c -> {
// we may not need this once we have our own signin provider proxied by Firebase
PancakesAppSecurity.module()
.anonymousByDefault()
.authenticate("/profile", "/account")
.and()
.domainAuthentication()
.usingJsonWebTokens()
.usingFirebase(keyCache)
.forAppId("url-shortening-app")
public Contact createContact(){
Model.Builder<Contact> contactBuilder = new Model.Builder<Contact>()
.setFieldValue(Contact.Field.FirstName, "first name")
.setCustomFieldValue("FavoriteDessert", "lemon cake")
.setFieldValue(Contact.Field.LastName, "last name");
return contactBuilder.build();
}
package com.infusionsoft.personalization;
/**
* This represents the valid date formats Infusionsoft will accept and render.
*/
public class StyleGuide {
public enum Date {
ReadableDowMonthDdYear("formats.readable.dow-month-dd-year"),
ReadableMonthDdYear("formats.readable.month-dd-year"),
ReadableMonDdYearTime("formats.readable.mon-dd-year-time"),
package com.infusionsoft.metrics.spring;
import com.infusion.crm.log.Log;
import com.infusion.util.data.filter.DataFilter;
import com.infusionsoft.util.AnnotationMethodFilter;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
package com.infusionsoft.metrics.aspect;
import com.infusion.util.ListFactory;
import com.infusionsoft.metrics.annotations.MetricsAware;
import org.springframework.aop.TargetSource;
import org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator;
import org.springframework.beans.BeansException;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
@wendelicious
wendelicious / gist:3408bc199c9342522f53
Last active September 10, 2015 16:32
Create a Pancake Service Interactively
Do this: https://github.com/infusionsoft/pancakesw/blob/master/pankacesw