Script for Security in Weblogic Server
Authenticator
#operations with the Security Authenticator MBean
auth = Security:/typeless/myrealmDefaultAuthenticator
invoke $auth/createUser spongebob password "Spongebob Squarepants"
invoke $auth/userExists spongebob
invoke $auth/createGroup cartoons "cartoons group"
Security:
cd $auth
invoke addMemberToGroup cartoons spongebob
invoke isMember cartoons spongebob true
List Users
Note: the syntax used in the script requires wlshell version 2.0.2 or latter.
# This script lists users in a realm, two versions are provided
# the pattern to use for searches
pattern="*"
prompt "listing users version 1, press enter to continue..."
Security:
cd typeless/myrealmDefaultAuthenticator
# the second parameter is the maximum number of users to return
cursor = invoke listUsers $pattern 0
hasMore = invoke haveCurrent $cursor
while $hasMore
invoke getCurrentName $cursor
invoke advance $cursor
hasMore = invoke haveCurrent $cursor
end
invoke close $cursor
prompt "listing users version 2, press enter to continue..."
output off
users = new java.util.ArrayList
Security:
cd typeless/myrealmDefaultAuthenticator
# search for users starting with 'w'
cursor = invoke listUsers "w*" 0
hasMore = invoke haveCurrent $cursor
while $hasMore
user = invoke getCurrentName $cursor
$users add $user
invoke advance $cursor
hasMore = invoke haveCurrent $cursor
end
invoke close $cursor
output on
print "current users are:" $users
#operations with the Security Authenticator MBean
auth = Security:/typeless/myrealmDefaultAuthenticator
invoke $auth/createUser spongebob password "Spongebob Squarepants"
invoke $auth/userExists spongebob
invoke $auth/createGroup cartoons "cartoons group"
Security:
cd $auth
invoke addMemberToGroup cartoons spongebob
invoke isMember cartoons spongebob true
List Users
Note: the syntax used in the script requires wlshell version 2.0.2 or latter.
# This script lists users in a realm, two versions are provided
# the pattern to use for searches
pattern="*"
prompt "listing users version 1, press enter to continue..."
Security:
cd typeless/myrealmDefaultAuthenticator
# the second parameter is the maximum number of users to return
cursor = invoke listUsers $pattern 0
hasMore = invoke haveCurrent $cursor
while $hasMore
invoke getCurrentName $cursor
invoke advance $cursor
hasMore = invoke haveCurrent $cursor
end
invoke close $cursor
prompt "listing users version 2, press enter to continue..."
output off
users = new java.util.ArrayList
Security:
cd typeless/myrealmDefaultAuthenticator
# search for users starting with 'w'
cursor = invoke listUsers "w*" 0
hasMore = invoke haveCurrent $cursor
while $hasMore
user = invoke getCurrentName $cursor
$users add $user
invoke advance $cursor
hasMore = invoke haveCurrent $cursor
end
invoke close $cursor
output on
print "current users are:" $users
0 Response to "Script for Security in Weblogic Server"
Post a Comment