Skip to content

Instantly share code, notes, and snippets.

View aaronanderson's full-sized avatar

Aaron Anderson aaronanderson

  • Dallas, Texas, USA
View GitHub Profile
@aaronanderson
aaronanderson / ContainerSecurityFilter.java
Last active March 10, 2018 15:05
JAX-RS 2.0 ContainerRequestFilter that performs the LinkedIn Exchange of JSAPI Tokens for REST API OAuth Tokens
import java.io.IOException;
import java.io.StringReader;
import java.net.URLDecoder;
import java.security.Principal;
import java.util.Base64;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Priority;
@aaronanderson
aaronanderson / Application.java
Last active August 14, 2016 08:04
E(FX)clipse Eclipse access secure P2 update site with custom certificate and oauth2/oidc authentication
public class Application {
@Inject
IEclipseContext econtext;
// @Override
@PostConstruct
protected void jfxStart(IApplicationContext context, javafx.application.Application jfxApplication, Stage primaryStage) {
performUpdateCheck();
@aaronanderson
aaronanderson / MultiList.java
Last active September 17, 2016 15:23
MultiList - Java FX SelectListView
package com.mercer.cpsg.workspace.app.uicomponents;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXButton.ButtonType;
import javafx.collections.FXCollections;
@aaronanderson
aaronanderson / usage
Last active May 6, 2017 15:55
match-passwords-validator.html
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../iron-validator-behavior/iron-validator-behavior.html">
<script>
class MatchPasswordsValidator extends Polymer.mixinBehaviors([Polymer.IronValidatorBehavior], Polymer.Element) {
static get is() {
return 'match-passwords-validator';
}
@aaronanderson
aaronanderson / intworkspace-multi-listbox.html
Last active May 29, 2017 23:26
A Polymer 2.0 multiselection list component consisting of two adjacent lists, one with available items (source) and one with selected items (target).
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-button/paper-button.html" />
<link rel="import" href="../paper-input/paper-input.html">
<dom-module id="intworkspace-multi-listbox">
<template>
@aaronanderson
aaronanderson / intworkspace-tree.html
Last active May 22, 2017 00:57
A simple Polymer 2.0 collapsible tree
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../iron-collapse/iron-collapse.html">
<link rel="import" href="../paper-item/paper-icon-item.html">
<link rel="import" href="../paper-item/paper-item-body.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../iron-icon/iron-icon.html">
<dom-module id="intworkspace-tree">
@aaronanderson
aaronanderson / intworkspace-tree.html
Last active May 29, 2017 23:28
A Polymer 2.0 collapsible tree using a caller provided template
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../iron-collapse/iron-collapse.html">
<link rel="import" href="../paper-item/paper-icon-item.html">
<link rel="import" href="../paper-item/paper-item-body.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../iron-icon/iron-icon.html">
<dom-module id="intworkspace-tree">
@aaronanderson
aaronanderson / S3Util.java
Last active February 6, 2024 10:52
Workaround to create presigned S3 URL using the new aws-sdk-java-v2 library preview
//updated for 2.0.0-preview-11
import java.io.ByteArrayInputStream;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import software.amazon.awssdk.auth.signer.AwsS3V4Signer;
import software.amazon.awssdk.auth.signer.internal.AwsSignerExecutionAttribute;
@aaronanderson
aaronanderson / OIDCClient.java
Last active November 7, 2017 13:51
Sample code for OAuth2 password authentication with only JAX-RS
@ApplicationScoped
public class OIDCClient {
private final AtomicReference<String> refreshRef = new AtomicReference<>();
private final ReadWriteLock tokenLock = new ReentrantReadWriteLock();
private OIDCToken oidcToken;
private String refreshToken;
@aaronanderson
aaronanderson / RepositoryHandler.java
Last active December 22, 2017 19:45
Amazon AWS Lambda using Java SDK V2 and DynamoDB conditional updates to implement simple timestamp locking
//This code has been edited to remove sensative information
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;