Author: keith
Date: Wed Jul  9 21:56:31 2008
New Revision: 19062
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19062

Log:
Adding the security Config JSP which I have forgotten to add


Added:
   trunk/mashup/java/modules/www/service_security_manager.jsp

Added: trunk/mashup/java/modules/www/service_security_manager.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/service_security_manager.jsp?pathrev=19062
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/www/service_security_manager.jsp  Wed Jul  9 
21:56:31 2008
@@ -0,0 +1,289 @@
+<%--
+ * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+--%>
+<%@ page errorPage="error.jsp" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ page import="java.util.ResourceBundle" %>
+<%@ page import="org.wso2.wsas.admin.service.util.CertData" %>
+<%@ page import="java.util.Arrays" %>
+<%@ page import="java.util.Comparator" %>
+<%@ page import="org.wso2.wsas.admin.service.SecurityScenarioConfigAdmin" %>
+<%@ page import="org.wso2.wsas.persistence.dataobject.SecurityScenarioDO" %>
+<%@ page import="org.wso2.registry.exceptions.RegistryException" %>
+<%@ page import="java.net.URLDecoder" %>
+
+<!--Required to keep a user logged in if 'Remember Me' option is selected-->
+<%@ include file="validate_login.jsp" %>
+
+<%
+    ResourceBundle bundle = ResourceBundle.getBundle("UI");
+    String mashupOwner = request.getParameter("author");
+    if (mashupOwner == null) {
+        throw new RegistryException("Must specify the Author");
+    }
+
+    String mashup = request.getParameter("mashup");
+    if (mashup == null) {
+        throw new RegistryException("Must specify a Mashup");
+    }
+    String bounceback = request.getParameter("bounceback");
+    if (bounceback == null) {
+        bounceback = "index.jsp";
+    } else {
+        bounceback = URLDecoder.decode(bounceback, "UTF-8");
+    }
+    String thisPage = "service_security_manager.jsp?author=" + mashupOwner + 
"&mashup=" + mashup;
+    MashupUtils.isValidMashup(mashupOwner, mashup);
+    String serviceName = mashupOwner + MashupConstants.SEPARATOR_CHAR + mashup;
+%>
+
+<html>
+<head>
+<title><%= bundle.getString("main.title")%> - Scecurity Configuration 
Manager</title>
+
+<!-- Required CSS -->
+<link href="css/styles.css" rel="stylesheet" type="text/css"/>
+
+<!--Required JavaScript-->
+<script language="javascript" src="js/common.js" 
type="text/javascript"></script>
+<script language="javascript" src="js/prototype.js" 
type="text/javascript"></script>
+<script language="javascript" src="js/utils.js" 
type="text/javascript"></script>
+
+<!--YUI Dependencies-->
+<script language="javascript" src="js/yui/yahoo-dom-event/yahoo-dom-event.js" 
type="text/javascript"></script>
+<script language="javascript" src="js/yui/connection/connection.js" 
type="text/javascript"></script>
+
+<!--WSO2 Dependencies-->
+<script type="text/javascript" src="js/global_params.js"></script>
+<script type="text/javascript" src="js/main.js"></script>
+<script type="text/javascript" src="js/wso2/WSRequest.js"></script>
+<script type="text/javascript" src="js/mashup-main.js"></script>
+<script type="text/javascript" src="js/services.js"></script>
+<script type="text/javascript" src="js/mashup.js"></script>
+<script type="text/javascript" src="js/mashup-utils.js"></script>
+    <script type="text/javascript">
+
+        function getSecurityAssignmentCallback(){
+        var response, roles, users, selected, name, htmlStr;
+
+            var returnElementList = 
this.req.responseXML.getElementsByTagName("ns:return");
+            // Older browsers might not recognize namespaces (e.g. FF2)
+            if (returnElementList.length == 0) {
+                response = 
this.req.responseXML.getElementsByTagName("return")[0];
+                roles = response.getElementsByTagName("roles");
+                users = response.getElementsByTagName("users");
+            } else {
+                response = returnElementList[0];
+                roles = response.getElementsByTagName("ns:roles");
+                users = response.getElementsByTagName("ns:users");
+            }
+
+            htmlStr = '<table width="100%"  border="0" cellspacing="0" 
cellpadding="0">' +
+                      '<th>Assign Roles</th>';
+            var checked;
+
+            for(var i=0;i<roles.length;i++)
+            {
+                selected = roles[i].firstChild.firstChild.nodeValue;
+                name = roles[i].lastChild.firstChild.nodeValue;
+                if ("everyone" == name || "user" == name) {
+                    continue;
+                }
+                checked = ''
+                if ("true" == selected) {
+                    checked ='checked="true"';
+                }
+                htmlStr = htmlStr + '<tr><td nowrap height="25"><input 
type="checkbox" name="assignRoleToServiceName" value="' + name + '"' + checked 
+ '/>' + name + '</td></tr>';
+            }
+            htmlStr = htmlStr + '</table>';
+
+            htmlStr = htmlStr + '<br><table width="100%"  border="0" 
cellspacing="0" cellpadding="0">' +
+                      '<th>Assign Users</th>';
+
+            for(i=0;i<users.length;i++)
+            {
+                selected = users[i].firstChild.firstChild.nodeValue;
+                name = users[i].lastChild.firstChild.nodeValue;
+                checked = '';
+                if ("true" == selected) {
+                    checked ='checked="true"';
+                }
+                htmlStr = htmlStr + '<tr><td nowrap height="25"><input 
type="checkbox" name="assignUserToServiceName" value="' + name + '"' + checked 
+ '/>' + name + '</td></tr>';
+            }
+            htmlStr = htmlStr + '<tr height="25" colspan="2"/><tr height="25" 
colspan="2"><td><input type="button" id="ok" value="OK" 
onclick="assignSecurityScenario(false);"/></td></tr></table>';
+
+            // Instantiate the Dialog
+            WSO2.MashupUtils.dialog("Assign Users and Roles", htmlStr, 500, 
100, null);
+    }
+
+    function getSecurityAssignment(){
+         wso2.mashup.services.getSecurityAssignment('<%=serviceName%>', 
getSecurityAssignmentCallback);
+    }
+
+        function assignSecurityScenario(validate) {
+
+            var objs = 
document.getElementsByName("configurationScenarioGroup");
+            var isChecked = false;
+            var value;
+            if (objs != null) {
+                var objsLength = objs.length;
+                for (var i = 0; i < objsLength; i++) {
+                    if (objs[i].checked) {
+                        isChecked = true;
+                        value = objs[i].value;
+                        break;
+                    }
+                }
+
+            } else {
+                wso2.wsf.Util.alertWarning("Problem encountered in 
javascript");
+                return;
+            }
+
+            if (!isChecked) {
+                wso2.wsf.Util.alertMessage("Please select a scenario");
+                return;
+            }
+
+            var index = value.indexOf("-");
+            var scenarioID = value.substring(0, index);
+            var category = value.substring(index + 1);
+
+            var users = "";
+            var roles = "";
+            var usersChecked = false;
+            var rolesChecked = false;
+
+            if ("ut.keystore.related" == category || "ut.related" == category) 
{
+                if (validate) {
+                    getSecurityAssignment();
+                    return;
+                }
+                var usersObjects = 
document.getElementsByName('assignUserToServiceName');
+                var rolesObjects = 
document.getElementsByName('assignRoleToServiceName');
+                for (var i = 0; i < usersObjects.length; i++) {
+                    if (usersObjects[i].checked) {
+                        users +=
+                        '<users><![CDATA[' + usersObjects[i].value +
+                        ']]></users>';
+                        usersChecked = true;
+                    }
+                }
+
+                for (var i = 0; i < rolesObjects.length; i++) {
+                    if (rolesObjects[i].checked) {
+                        roles +=
+                        '<roles><![CDATA[' + rolesObjects[i].value +
+                        ']]></roles>';
+                        rolesChecked = true;
+                    }
+                }
+
+                if (!usersChecked && !rolesChecked) {
+                    wso2.wsf.Util.alertMessage("Please select at least one 
user or a role");
+                    return false;
+                }
+                if (usersChecked && !rolesChecked) {
+                    roles = "<roles nillable=\"true\"></roles>";
+
+                }
+                if (!usersChecked && rolesChecked) {
+                    users = "<users nillable=\"true\"></users>";
+                }
+            } else {
+                roles = "<roles nillable=\"true\"></roles>";
+                users = "<users nillable=\"true\"></users>";
+            }
+
+            wso2.mashup.services.assignSecurityScenario('<%=serviceName%>', 
scenarioID, category, roles, users, assignSecurityScenarioCallback)
+        }
+
+        function assignSecurityScenarioCallback() {
+            location.reload();
+        }
+    </script>
+</head>
+<body>
+<div id="page">
+<%@ include file="header.jsp" %>
+<%@ include file="searchbox.jsp" %>
+
+<div id="simple-content">
+<%
+    if (!RegistryUtils.isLoggedIn(userRegistry)) {
+%>
+You need to <a href="signin.jsp?bounceback=<%=URLEncoder.encode(thisPage, 
"UTF-8")%>">sign in</a> to perform this
+operation.
+<%
+} else {
+%>
+<div class="page_title">Manage scecurity configuration of <%=mashup%> 
Service</div>
+<fieldset>
+    <legend><font color="#000000"><strong>Available Security 
Scenarios</strong></font></legend>
+    <br/>
+    <table id="certificates">
+        <thead>
+            <tr class="mashup_label">
+                <th style="text-align: center;">Option</th>
+                <th style="text-align: center;"/>
+                <th style="text-align: center;">Summary</th>
+                <th style="text-align: center;">Description</th>
+            </tr>
+        </thead>
+        <tbody>
+
+            <%
+                SecurityScenarioDO[] securityScenarioDOs = 
MashupUtils.getSecurityScenarios(
+                        serviceName, request.getSession().getId(), 
request.getContextPath());
+                for (int x = 0; x < securityScenarioDOs.length; x++) {
+                    SecurityScenarioDO scenarioDO = securityScenarioDOs[x];
+                    if (x % 2 == 0) {
+            %>
+            <tr style="background-color: gainsboro;">
+                <%
+                    }
+                    String category = scenarioDO.getCategory();
+                    String checked = "";
+                        if (scenarioDO.getIsCurrentScenario()) {
+                           checked ="\"checked=true\"";
+                    }
+                    %>
+                <td><%=(x+1)%>
+                </td>
+                <td><input type="radio" name="configurationScenarioGroup"
+                           value="<%=scenarioDO.getScenarioId() + "-" + 
category%>" <%=checked%>/>
+                </td>
+                <td><%=scenarioDO.getSummary()%></td>
+                <td><%=scenarioDO.getDescription()%></td>
+            </tr>
+            <%
+                }
+            %>
+            <tr>
+                <td colspan="4"><input type="button" value="Submit" 
onclick="assignSecurityScenario(true);"/><input type="button" value="Cancel" 
onclick="document.location = '<%=bounceback%>';"></td>
+            </tr>
+
+        </tbody>
+    </table>
+</fieldset>
+<%
+    }
+%>
+</div>
+
+<%@ include file="footer.jsp" %>
+</div>
+</body>
+</html>
\ No newline at end of file

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to