Skip to content

Instantly share code, notes, and snippets.

@mbarkley
mbarkley / log4j.java
Created August 27, 2023 19:03
Log4J Interpolation
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.apache.logging.log4j:log4j-core:2.14.0
//DEPS org.apache.logging.log4j:log4j-api:2.14.0
//RUNTIME_OPTIONS -Dlog4j2.enableJndiLookup=true -Dtest.system.property=the-test-value
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.builder.api.*;
@mbarkley
mbarkley / screenshare-audio.sh
Last active April 2, 2020 13:30
Script for sharing application audio and mic input over Zoom on Linux
#!/usr/bin/env bash
# Copyright 2020 Max Barkley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@mbarkley
mbarkley / index.html
Created February 12, 2018 16:59
Event Firing POC
<!DOCTYPE>
<html>
<head>
<script>
function doClick() {
// May need cross-browser support
//var evt = document.createEvent("HTMLEvents");
var evt = new Event("change");
var element = document.getElementById("id-2");
evt.initEvent("change", false, true);
@mbarkley
mbarkley / LoginForm.java
Last active August 29, 2015 14:01
An example of logging in with Errai Security via the AuthenticationService Caller
@Templated
@Page(role = LoginPage.class)
public class LoginForm extends Composite {
@Inject @DataField
private TextBox username;
@Inject @DataField
private TextBox password;
@mbarkley
mbarkley / RestService.java
Last active August 29, 2015 14:01
An example of securing a JAX-RS Endpoint using Errai Security
@Path("/services")
public interface RestService {
@GET
@Path("/name-lookup")
@RestrictedAccess
public String getMyName();
}
@mbarkley
mbarkley / SecureService.java
Last active August 29, 2015 14:01
An example of securing an Errai Messaging @service with Errai Security
@Service
@RestrictedAccess
public class SecureService implements MessageCallback {
public void calback(Message message) {
// ...
}
}
@mbarkley
mbarkley / RemoteService.java
Last active August 29, 2015 14:01
An example of securing Errai Bus RPCs with Errai Security
@Remote
@RestrictedAccess(roles = "user")
public interface RemoteService {
public void authenticatedUserService();
/*
* Because this method and its enclosing class are both restricted,
* a user must have both roles to access this.
*/
@mbarkley
mbarkley / NavBar.html
Last active August 29, 2015 14:01
An example for using Errai Security to hide @datafields based on a user's login-status and roles.
<div>
<a id="admin">Admin Only Link</a>
<a id="logout">Logout Link</a>
</div>
@mbarkley
mbarkley / Login.java
Created May 5, 2014 21:21
An sample Errai Navigation page with the LoginPage and SecurityError page roles.
@Page(role = { LoginPage.class, SecurityError.class })
public class Login extends SimplePanel {
// Add widgets for login form here...
}
@mbarkley
mbarkley / AdminPage.java
Created May 5, 2014 21:14
An example of using Errai Security to secure an Errai Navigation page
@Page
@RestrictedAccess(roles = "admin")
public class AdminPage extends SimplePanel {
// Nothing to see here... move it along...
}