1 <html>
2 <body>
3 <%@page import="org.wso2.carbon.user.api.UserRealm" %>
4 <%@page import="org.wso2.carbon.context.CarbonContext" %>
5 <h2>WSO2 Carbon User Manage Usage Demo</h2>
6
7 <%
8 String username = request.getParameter("username");
9 String pass = request.getParameter("password");
10 if (username != null && username.trim().length() > 0) {
11 CarbonContext context = CarbonContext.getCurrentContext();
12 UserRealm realm = context.getUserRealm();
13 realm.getUserStoreManager().addUser(username, pass, null, null, null);
14 }
15 %>
16
17 <form action="index.jsp">
18 <p>User Name <input type="text" name="username"/></p>
19
20 <p>Password <input type="text" name="password"/></p>
21 <input type="submit" value="submit"/>
22 </form>
23
24 <p><b>The user list</b></p>
25 <%
26 CarbonContext context = CarbonContext.getCurrentContext();
27 UserRealm realm = context.getUserRealm();
28 String[] names = realm.getUserStoreManager().listUsers("*", 100);
29 for (String name : names) {
30 %><%=name%><br/><%
31 }
32 %>
33 </body>
34 </html>