Skip to content

Commit

Permalink
Merge pull request #277 from malithie/master
Browse files Browse the repository at this point in the history
Fixed state changing gets, jsp compilation errors, and restricted gets to ajax processors in server.manager.ui
  • Loading branch information
malithie authored Jun 12, 2016
2 parents ca37376 + 6517ba3 commit 26670f9
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
-->

<%@page import="org.apache.axis2.context.ConfigurationContext"%>
<%@ page import="org.apache.commons.collections.CollectionUtils"%>
<%@ page import="org.owasp.encoder.Encode"%>
<%@ page import="org.wso2.carbon.CarbonConstants"%>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider"%>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig"%>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.ProvisioningConnectorConfig"%>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.RequestPathAuthenticatorConfig"%>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig"%>
<%@ page
import="org.wso2.carbon.identity.application.mgt.ui.ApplicationBean"%>
<%@ page import="org.wso2.carbon.identity.application.mgt.ui.client.ApplicationManagementServiceClient"%>
<%@ page import="org.wso2.carbon.identity.application.mgt.ui.util.ApplicationMgtUIUtil"%>
<%@page import="org.wso2.carbon.ui.CarbonUIMessage"%>
import="org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig"%>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.Property"%>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.ProvisioningConnectorConfig"%>
<%@page import="org.wso2.carbon.identity.application.common.model.xsd.RequestPathAuthenticatorConfig"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="carbon" uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar"%>
<%@ page import="org.wso2.carbon.identity.application.mgt.ui.ApplicationBean" %>
<%@ page import="org.wso2.carbon.identity.application.mgt.ui.client.ApplicationManagementServiceClient" %>
<%@page import="org.wso2.carbon.identity.application.mgt.ui.util.ApplicationMgtUIUtil"%>
<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %>
<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
<%@page import="java.util.HashMap"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig" %>
<%@ page import="org.wso2.carbon.identity.application.common.model.xsd.Property" %>
<%@ page import="org.apache.commons.collections.CollectionUtils" %>
<%@ page import="java.util.ArrayList" %>

<link href="css/idpmgt.css" rel="stylesheet" type="text/css" media="all"/>
<carbon:breadcrumb label="breadcrumb.service.provider" resourceBundle="org.wso2.carbon.identity.application.mgt.ui.i18n.Resources"
Expand Down Expand Up @@ -376,6 +376,39 @@ var roleMappinRowID = -1;
});
}
function updateBeanAndPost(postURL, data, redirectURLOnSuccess) {
var numberOfClaimMappings = document.getElementById("claimMappingAddTable").rows.length;
document.getElementById('number_of_claimmappings').value = numberOfClaimMappings;
var numberOfPermissions = document.getElementById("permissionAddTable").rows.length;
document.getElementById('number_of_permissions').value = numberOfPermissions;
var numberOfRoleMappings = document.getElementById("roleMappingAddTable").rows.length;
document.getElementById('number_of_rolemappings').value = numberOfRoleMappings;
$.ajax({
type: "POST",
url: 'update-application-bean.jsp?spName=<%=Encode.forUriComponent(spName)%>',
data: $("#configure-sp-form").serialize(),
success: function () {
$.ajax({
type: 'POST',
url: postURL,
headers: {
Accept: "text/html"
},
data: data,
async: false,
success: function (responseText, status) {
if (status == "success") {
location.assign(redirectURLOnSuccess);
}
}
});
}
});
}
function onSamlSsoClick() {
var spName = document.getElementById("oldSPName").value;
if( spName != '') {
Expand Down Expand Up @@ -1319,7 +1352,9 @@ var roleMappinRowID = -1;
class="icon-link"
style="background-image: url(../admin/images/edit.gif)">Change Password</a>
<a title="Delete"
onclick="updateBeanAndRedirect('../servicestore/delete-finish.jsp?SPAction=delete&spnName=<%=Encode.forUriComponent(appBean.getKerberosServiceName())%>&spName=<%=Encode.forUriComponent(spName)%>');"
onclick="updateBeanAndPost('../servicestore/delete-finish-ajaxprocessor.jsp',
'SPAction=delete&spnName=<%=Encode.forUriComponent(appBean.getKerberosServiceName())%>&spName=<%=Encode.forUriComponent(spName)%>',
'configure-service-provider.jsp?action=delete&spName=<%=Encode.forUriComponent(spName)%>&kerberos=<%=Encode.forUriComponent(appBean.getKerberosServiceName())%>');"
class="icon-link" style="background-image: url(images/delete.gif)">
Delete </a>
</td>
Expand All @@ -1344,6 +1379,7 @@ var roleMappinRowID = -1;
standardInboundAuthTypes.add("samlsso");
standardInboundAuthTypes.add("openid");
standardInboundAuthTypes.add("passivests");
standardInboundAuthTypes.add("kerberos");
if (!CollectionUtils.isEmpty(appBean.getInboundAuthenticators())) {
List<InboundAuthenticationRequestConfig> customAuthenticators = appBean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ui</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.directory.server.manager.stub</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<%@ page import="org.owasp.encoder.Encode" %>

<%
String httpMethod = request.getMethod();
if (!"post".equalsIgnoreCase(httpMethod)) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
String servicePrincipleName = request.getParameter("serviceName");
String description = request.getParameter("serviceDescription");
String password = request.getParameter("password");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
function doFinish() {
document.dataForm.action = "add-finish.jsp";
document.dataForm.action = "add-finish-ajaxprocessor.jsp";
if (doValidation() == true) {
document.dataForm.submit();
}
Expand All @@ -148,7 +148,7 @@

<div id="workArea">

<form method="post" action="add-finish.jsp" name="dataForm">
<form method="post" action="add-finish-ajaxprocessor.jsp" name="dataForm">
<table class="styledLeft" id="userAdd" width="60%">
<thead>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<%@ page import="org.owasp.encoder.Encode" %>

<%
String httpMethod = request.getMethod();
if (!"post".equalsIgnoreCase(httpMethod)) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
String servicePrincipleName = request.getParameter("spnName");
String oldPassword = request.getParameter("currentPassword");
String newPassword = request.getParameter("newPassword");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@
</script>
<div id="middle">
<h2><fmt:message key="change.password.spn"/> <%=Encode.forHml(spnName)%></h2>
<h2><fmt:message key="change.password.spn"/> <%=Encode.forHtml(spnName)%></h2>

<div id="workArea">
<form name="chgPassWdForm" method="post"
onsubmit="return doValidation();" action="change-passwd-finish.jsp">
onsubmit="return doValidation();" action="change-passwd-finish-ajaxprocessor.jsp">
<input type="hidden" name="spnName" value="<%=Encode.forHtmlAttribute(spnName)%>"/>

<table class="styledLeft" id="changePassword" width="60%">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<%@ page import="org.owasp.encoder.Encode" %>

<%
String httpMethod = request.getMethod();
if (!"post".equalsIgnoreCase(httpMethod)) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
String spName = request.getParameter("spName");
String servicePrincipleName = request.getParameter("spnName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
<%@page import="org.apache.axis2.context.ConfigurationContext" %>
<%@page import="org.owasp.encoder.Encode" %>
<%@page import="org.wso2.carbon.CarbonConstants" %>
<%@page import="org.wso2.carbon.directory.common.stub.types.ServerPrinciple" %>
<%@page import="org.wso2.carbon.directory.server.manager.ui.DirectoryServerManagerClient" %>

<%@page import="org.wso2.carbon.ui.CarbonUIMessage"%>
<%@page import="org.wso2.carbon.directory.server.manager.ui.DirectoryServerManagerClient"%>
<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %>
<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
<%@ page import="org.owasp.encoder.Encode" %>

<script type="text/javascript" src="../admin/js/main.js"></script>

<jsp:include page="../dialog/display_messages.jsp"/>
<script type="text/javascript" src="../carbon/admin/js/main.js"></script>
<script type="text/javascript" src="../carbon/admin/js/breadcrumbs.js"></script>
<script type="text/javascript" src="../carbon/admin/js/cookies.js"></script>

<fmt:bundle basename="org.wso2.carbon.directory.server.manager.ui.i18n.Resources">

Expand All @@ -47,11 +47,25 @@
function deleteServicePrinciple(spn) {
function doDelete(){
var spnName = spn;
location.href = 'delete-finish.jsp?spnName=' + spnName;
function doDelete() {
$.ajax({
type: 'POST',
url: 'delete-finish-ajaxprocessor.jsp',
headers: {
Accept: "text/html"
},
data: 'spnName=' + spn,
async: false,
success: function (responseText, status) {
if (status == "success") {
location.assign("index.jsp");
}
}
});
}
CARBON.showConfirmationDialog("<fmt:message key="confirm.delete.spn"/> \'"+ spn + "\'?", doDelete, null);
CARBON.showConfirmationDialog('<fmt:message key="confirm.delete.spn"/>' + spn + '?', doDelete, null);
}
function changeSpnPassword(spn) {
Expand Down Expand Up @@ -155,9 +169,15 @@
<td><%=Encode.forHtml(principle.getServerName())%></td>
<td><%=Encode.forHtml(principle.getServerDescription())%></td>
<td>
<a href="#" onclick="changeSpnPassword('<%=Encode.forJavascriptAttribute(principle.getServerName())%>')" class="icon-link" style="background-image:url(images/edit.gif);"><fmt:message key="edit"/></a>
<a href="#"
onclick="changeSpnPassword('<%=Encode.forJavaScriptAttribute(principle.getServerName())%>')"
class="icon-link" style="background-image:url(images/edit.gif);"><fmt:message
key="edit"/></a>
&nbsp;
<a href="#" onclick="deleteServicePrinciple('<%=Encode.forJavascriptAttribute(principle.getServerName())%>')" class="icon-link" style="background-image:url(images/delete.gif);"><fmt:message key="delete"/></a>
<a href="#"
onclick="deleteServicePrinciple('<%=Encode.forJavaScriptAttribute(principle.getServerName())%>')"
class="icon-link" style="background-image:url(images/delete.gif);"><fmt:message
key="delete"/></a>
</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class LDAPServerManagerConstants {

public static final String SERVICE_PASSWORD_REGEX_PROPERTY = "ServicePasswordJavaRegEx";
public static final String SERVICE_PRINCIPLE_NAME_REGEX_PROPERTY = "ServiceNameJavaRegEx";
public static final String DEFAULT_PASSWORD_REGULAR_EXPRESSION = "[\\\\S]{5,30}";
public static final String DEFAULT_PASSWORD_REGULAR_EXPRESSION = "[\\S]{5,30}";
public static final String DEFAULT_SERVICE_NAME_REGULAR_EXPRESSION = "[a-zA-Z\\d]{2,10}/[a-zA-Z]{2,30}";
public static final String SERVER_PRINCIPAL_ATTRIBUTE_VALUE = "Service";
public static final String SERVER_PRINCIPAL_ATTRIBUTE_NAME = "sn";
Expand Down

0 comments on commit 26670f9

Please sign in to comment.