Skip to content

Instantly share code, notes, and snippets.

View tristantarrant's full-sized avatar
🏠
Working from home

Tristan Tarrant tristantarrant

🏠
Working from home
  • IBM
  • Italy
View GitHub Profile
// mode=local,language=javascript
var cache = cacheManager.getCache();
cache.get("a");
@tristantarrant
tristantarrant / gist:880a120ee3f67758be30
Last active August 29, 2015 14:04
AuthenticatedHotRodClient.java
import java.util.Collections;
import javax.security.sasl.Sasl;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
public class AuthenticatedHotRodClient {
<server xmlns="urn:jboss:domain:2.1">
<management>
<security-realms>
<security-realm name="ApplicationRealm">
<authentication>
<local default-user="$local" allowed-users="*" skip-group-loading="true"/>
<properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization>
<properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
@tristantarrant
tristantarrant / gist:10459764
Created April 11, 2014 11:21
Infinispan cache security obtaining a secure cache (lambda edition)
String value = Subject.doAs(mySubject, PrivilegedAction<String>() -> cacheManager.getCache().get("key"));
@tristantarrant
tristantarrant / gist:10459383
Last active August 29, 2015 13:59
Infinispan cache security obtaining a secure cache
String value = Subject.doAs(mySubject, new PrivilegedAction<String>() {
@Override
public String run() {
return cacheManager.getCache().get("key");
}
});
@tristantarrant
tristantarrant / gist:10455430
Created April 11, 2014 10:06
Infinispan cache security configuration
<local-cache name="secured">
<security>
<authorization enabled="true" roles="admin reader writer" />
</security>
</local-cache>
@tristantarrant
tristantarrant / gist:10454630
Last active August 29, 2015 13:59
Infinispan cache container security configuration
<cache-container name="default" >
<security>
<authorization enabled="true" mapper="org.infinispan.security.impl.IdentityRoleMapper">
<role name="admin" permissions="ALL" />
<role name="reader" permissions="READ" />
<role name="writer" permissions="WRITE" />
<role name="supervisor" permissions="READ WRITE EXEC"/>
</authorization>
</security>
</cache-container>
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.4">
<extensions>
<extension module="org.infinispan.server.endpoint"/>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.clustering.jgroups"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.jdr"/>
<extension module="org.jboss.as.jmx"/>
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class IPvXTest {
static void match(String s) {
Pattern p = Pattern.compile("(\\[(?<v6host>[0-9A-Fa-f:]+)\\]|(?<v4host>[^:/?#]*))(?::(?<port>\\d*))?");
Matcher matcher = p.matcher(s);
if (matcher.matches()) {
String v6host = matcher.group("v6host");
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0">
<!-- *************************** -->
<!-- System-wide global settings -->
<!-- *************************** -->
<global>
<shutdown hookBehavior="DEFAULT" />