Skip to content

Instantly share code, notes, and snippets.

@coheigea
Created September 19, 2016 10:37
Show Gist options
  • Save coheigea/209aea0dceef7fdc01e5f7b8b01b0bd9 to your computer and use it in GitHub Desktop.
Save coheigea/209aea0dceef7fdc01e5f7b8b01b0bd9 to your computer and use it in GitHub Desktop.
@Override
public boolean authorize(Session arg0, Operation arg1, Resource arg2) {
if (arg0.principal() == null) {
return false;
}
String principal = arg0.principal().getName();
if (principal.startsWith("CN=Client")
&& ("Read".equals(arg1.name()) || "Describe".equals(arg1.name()))
&& arg2.name().startsWith("test")) {
return true;
} else if (principal.startsWith("CN=Service") && ("Read".equals(arg1.name()) || "Describe".equals(arg1.name())
|| "Write".equals(arg1.name()) || "Create".equals(arg1.name()))) {
return true;
} else if (principal.startsWith("CN=Broker")) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment