Created
September 3, 2012 11:39
-
-
Save amr/3608720 to your computer and use it in GitHub Desktop.
SS2 Security Permissions Defs to SS3 intercept-url tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def is_comment(line): | |
return line.startswith('<!--') | |
def is_empty(line): | |
return len(line) == 0 | |
if __name__ == '__main__': | |
f = open('/tmp/definitions.txt', 'r') | |
definitions = f.readlines() | |
f.close() | |
# <sec:intercept-url pattern="/services/dashboard/login*" access="ROLE_ANONYMOUS" /> | |
intercept_url_pattern = '<sec:intercept-url pattern="{pattern}" access="{access}" />' | |
result = [] | |
for definition in definitions: | |
definition = definition.strip() | |
if is_comment(definition) or is_empty(definition): | |
result.append(definition) | |
continue | |
definition = definition.split('=') | |
intercept_url = intercept_url_pattern.format(pattern=definition[0], access=definition[1]) | |
result.append(intercept_url) | |
print "\n".join(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment