Skip to content

Instantly share code, notes, and snippets.

@ig0774
ig0774 / gist:1068598
Created July 6, 2011 23:35
Manage Windows Advanced Firewall with PowerShell
Set-StrictMode -Version Latest
# Constants
if (!(Test-Path variable:\NET_FW_DISABLED)) { Set-Variable NET_FW_DISABLED $False }
if (!(Test-Path variable:\NET_FW_ENABLED)) { Set-Variable NET_FW_ENABLED $True }
if (!(Test-Path variable:\NET_FW_IP_PROTOCOL_TCP)) { Set-Variable NET_FW_IP_PROTOCOL_TCP 6 }
if (!(Test-Path variable:\NET_FW_IP_PROTOCOL_UDP)) { Set-Variable NET_FW_IP_PROTOCOL_UDP 17 }
if (!(Test-Path variable:\NET_FW_PROFILE_DOMAIN)) { Set-Variable NET_FW_PROFILE_DOMAIN 0x1 }
if (!(Test-Path variable:\NET_FW_PROFILE_PRIVATE)) { Set-Variable NET_FW_PROFILE_PRIVATE 0x2 }
if (!(Test-Path variable:\NET_FW_PROFILE_PUBLIC)) { Set-Variable NET_FW_PROFILE_PUBLIC 0x2 }
@ig0774
ig0774 / windows_auth.py
Created March 25, 2011 19:52
WSGI middleware that provides SPNEGO authentication using the Win32 extensions
from base64 import b64decode, b64encode
from lru_dict import LruDict
import win32api
import win32security
import sspi, sspicon
__all__ = ['WindowsAuth']
def _get_user_name():
'''Uses the Windows API to retrieve the current user name'''
@ig0774
ig0774 / Guice - Shiro Example.java
Created March 14, 2011 14:28
An example of integrating Guice and Shiro
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeSet;
import javax.naming.NamingException;
import org.apache.shiro.authc.pam.AuthenticationStrategy;
import org.apache.shiro.authc.pam.FirstSuccessfulStrategy;
import org.apache.shiro.mgt.DefaultSecurityManager;