diff --git a/mifosng-data/src/main/java/org/mifosng/data/AuthenticatedUserData.java b/mifosng-data/src/main/java/org/mifosng/data/AuthenticatedUserData.java index 021d531fd..783d24191 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/AuthenticatedUserData.java +++ b/mifosng-data/src/main/java/org/mifosng/data/AuthenticatedUserData.java @@ -9,6 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement; public class AuthenticatedUserData { private String username; + private String base64EncodedAuthenticationKey; private boolean authenticated = false; private Collection permissions = new ArrayList(); @@ -43,4 +44,13 @@ public class AuthenticatedUserData { public void setAuthenticated(boolean authenticated) { this.authenticated = authenticated; } + + public String getBase64EncodedAuthenticationKey() { + return base64EncodedAuthenticationKey; + } + + public void setBase64EncodedAuthenticationKey( + String base64EncodedAuthenticationKey) { + this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey; + } } \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/ApplicationPagesRoutesController.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/ApplicationPagesRoutesController.java new file mode 100644 index 000000000..8303a03ad --- /dev/null +++ b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/ApplicationPagesRoutesController.java @@ -0,0 +1,119 @@ +package org.mifosng.ui; + +import org.mifosng.configuration.ApplicationConfigurationService; +import org.mifosng.configuration.OAuthProviderDetails; +import org.mifosng.ui.infrastructure.BasicAuthUserDetails; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +/** + * Controller responsible for routing requests on client application to correct jsp page. + */ +@Controller +public class ApplicationPagesRoutesController { + + private final ApplicationConfigurationService applicationConfigurationService; + + @Autowired + public ApplicationPagesRoutesController(ApplicationConfigurationService applicationConfigurationService) { + this.applicationConfigurationService = applicationConfigurationService; + } + + @ExceptionHandler(AccessDeniedException.class) + public String accessDeniedException() { + return "unAuthorizedAction"; + } + + @RequestMapping(value="/", method = RequestMethod.GET) + public String redirectToIndexPage(final Model model, final Authentication authentication) { + + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + + return "redirect:/home"; + } + + @RequestMapping(value = "/home", method = RequestMethod.GET) + public ModelAndView showIndividualClientsOnHomePage(final Model model, final Authentication authentication) { + + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + + return new ModelAndView("/home"); + } + + @RequestMapping(value="/switchToClient", method = RequestMethod.POST) + public String switchToClientView(@RequestParam("client") final Long client) { + return "redirect:/portfolio/client/" + client; + } + + @RequestMapping(value = "/portfolio/client/{clientId}", method = RequestMethod.GET) + public String viewClientAccount(final Model model, final Authentication authentication, @PathVariable("clientId") final Long clientId) { + + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + model.addAttribute("clientId", clientId); + return "client/viewClientAccount"; + } + + @RequestMapping(value = "/org/admin", method = RequestMethod.GET) + public String organisationAdminScreen(final Model model, final Authentication authentication) { + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + return "admin/orghome"; + } + + @RequestMapping(value = "/org/admin/user", method = RequestMethod.GET) + public String userAdminScreen(final Model model, final Authentication authentication) { + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + return "admin/userhome"; + } + + @RequestMapping(value = "/org/admin/settings", method = RequestMethod.GET) + public String userSettingsScreen(final Model model, final Authentication authentication) { + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + return "admin/accountsettings"; + } + + @RequestMapping(value = "/portfolio/client/{clientId}/loan/new", method = RequestMethod.GET) + public String loadLoanCreationWorkflow(final Model model, final Authentication authentication, @PathVariable("clientId") final Long clientId) { + + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + model.addAttribute("clientId", clientId); + + return "newloanapplication"; + } + + @RequestMapping(value = "/reporting/flexireport", method = RequestMethod.GET) + public String viewFlexibleReportingPage(final Model model, final Authentication authentication) { + + OAuthProviderDetails oauthDetails = this.applicationConfigurationService.retrieveOAuthProviderDetails(); + + BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal(); + model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey()); + model.addAttribute("baseApiUrl", userDetails.getFullApiUrl()); + + model.addAttribute("baseUrl", oauthDetails.getProviderBaseUrl()); + + return "reports/flexireport"; + } +} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/ApplicationPagesRoutesController.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/ApplicationPagesRoutesController.java deleted file mode 100644 index 72e2317ef..000000000 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/ApplicationPagesRoutesController.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.mifosng.ui.admin; - -import org.springframework.security.access.AccessDeniedException; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.servlet.ModelAndView; - -/** - * Controller responsible for routing requests on client application to correct jsp page. - */ -@Controller -public class ApplicationPagesRoutesController { - - @ExceptionHandler(AccessDeniedException.class) - public String accessDeniedException() { - return "unAuthorizedAction"; - } - - @RequestMapping(value="/", method = RequestMethod.GET) - public String redirectToIndexPage() { - return "redirect:/home"; - } - - @RequestMapping(value = "/home", method = RequestMethod.GET) - public ModelAndView showIndividualClientsOnHomePage() { - return new ModelAndView("/home"); - } - - @RequestMapping(value="/switchToClient", method = RequestMethod.POST) - public String switchToClientView(@RequestParam("client") final Long client) { - return "redirect:/portfolio/client/" + client; - } - - @RequestMapping(value = "/portfolio/client/{clientId}", method = RequestMethod.GET) - public String viewClientAccount(final Model model, @PathVariable("clientId") final Long clientId) { - model.addAttribute("clientId", clientId); - return "client/viewClientAccount"; - } - - @RequestMapping(value = "/org/admin", method = RequestMethod.GET) - public String organisationAdminScreen() { - return "admin/orghome"; - } - - @RequestMapping(value = "/org/admin/user", method = RequestMethod.GET) - public String userAdminScreen() { - return "admin/userhome"; - } - - @RequestMapping(value = "/org/admin/settings", method = RequestMethod.GET) - public String userSettingsScreen() { - return "admin/accountsettings"; - } - - @RequestMapping(value = "/portfolio/client/{clientId}/loan/new", method = RequestMethod.GET) - public String loadLoanCreationWorkflow(final Model model, @PathVariable("clientId") final Long clientId) { - -// UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) principal; -// ConsumerUserDetails user = (ConsumerUserDetails) authenticationToken.getPrincipal(); -// if (user.hasNoAuthorityToSumitLoanApplication()) { -// throw new AccessDeniedException(""); -// } - - model.addAttribute("clientId", clientId); - - return "newloanapplication"; - } -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/infrastructure/ApiDelegatingAuthenticationProvider.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/infrastructure/ApiDelegatingAuthenticationProvider.java index 0a1488cc0..0c217e439 100644 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/infrastructure/ApiDelegatingAuthenticationProvider.java +++ b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/infrastructure/ApiDelegatingAuthenticationProvider.java @@ -4,6 +4,8 @@ import java.net.URI; import java.util.ArrayList; import java.util.Collection; +import org.mifosng.configuration.ApplicationConfigurationService; +import org.mifosng.configuration.OAuthProviderDetails; import org.mifosng.data.AuthenticatedUserData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -13,20 +15,26 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.web.client.RestTemplate; /** - * A {@link AbstractUserDetailsAuthenticationProvider} which is responsible for delegating authentication to the mifos platform API. + * A {@link AbstractUserDetailsAuthenticationProvider} which is responsible for delegating authentication to the mifos platform API. + * + * If successful, the permissions associated with the authenticated user are returned. As this class is used as a hook into spring security, + * a proper authentication object is persisted for this client applications {@link SecurityContext}. */ public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { private final RestTemplate restTemplate; + private final ApplicationConfigurationService applicationConfigurationService; @Autowired - public ApiDelegatingAuthenticationProvider(final RestTemplate restTemplate) { + public ApiDelegatingAuthenticationProvider(final RestTemplate restTemplate, final ApplicationConfigurationService applicationConfigurationService) { this.restTemplate = restTemplate; + this.applicationConfigurationService = applicationConfigurationService; } @Override @@ -38,7 +46,12 @@ public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuth String password = (String) authentication.getCredentials(); - URI restUri = URI.create("http://localhost:8080/mifosng-provider/api/v1/authentication?username=" + username + "&password=" + password); + OAuthProviderDetails oauthDetails = this.applicationConfigurationService.retrieveOAuthProviderDetails(); + String apiVersion = "api/v1/"; + String authUrlExtension = "authentication?username=" + username + "&password=" + password; + StringBuilder authenticationApiUrl = new StringBuilder(oauthDetails.getProviderBaseUrl()).append(apiVersion).append(authUrlExtension); + + URI restUri = URI.create(authenticationApiUrl.toString()); ResponseEntity s = this.restTemplate.postForEntity(restUri, authRequest(), AuthenticatedUserData.class); UserDetails userDetails = null; @@ -49,7 +62,8 @@ public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuth for (String permission : authenticatedUserData.getPermissions()) { authorities.add(new SimpleGrantedAuthority(permission)); } - userDetails = new User(authenticatedUserData.getUsername(), "[not needed]", authorities); + User user = new User(authenticatedUserData.getUsername(), "[not needed]", authorities); + userDetails = new BasicAuthUserDetails(user, authenticatedUserData.getBase64EncodedAuthenticationKey(), oauthDetails.getProviderBaseUrl(), apiVersion); } return userDetails; @@ -63,4 +77,4 @@ public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuth HttpEntity requestEntity = new HttpEntity(requestHeaders); return requestEntity; } -} +} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/infrastructure/BasicAuthUserDetails.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/infrastructure/BasicAuthUserDetails.java new file mode 100644 index 000000000..efda943a3 --- /dev/null +++ b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/infrastructure/BasicAuthUserDetails.java @@ -0,0 +1,73 @@ +package org.mifosng.ui.infrastructure; + +import java.util.Collection; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; + +public class BasicAuthUserDetails implements UserDetails { + + private final User user; + private final String basicAuthenticationKey; + private final String apiBaseUrl; + private final String apiVersion; + + public BasicAuthUserDetails(User user, String basicAuthenticationKey, String apiBaseUrl, String apiVersion) { + this.user = user; + this.basicAuthenticationKey = basicAuthenticationKey; + this.apiBaseUrl = apiBaseUrl; + this.apiVersion = apiVersion; + } + + @Override + public Collection getAuthorities() { + return this.user.getAuthorities(); + } + + @Override + public String getPassword() { + return this.getPassword(); + } + + @Override + public String getUsername() { + return this.user.getUsername(); + } + + @Override + public boolean isAccountNonExpired() { + return this.user.isAccountNonExpired(); + } + + @Override + public boolean isAccountNonLocked() { + return this.user.isAccountNonExpired(); + } + + @Override + public boolean isCredentialsNonExpired() { + return this.user.isCredentialsNonExpired(); + } + + @Override + public boolean isEnabled() { + return this.user.isEnabled(); + } + + public String getBasicAuthenticationKey() { + return basicAuthenticationKey; + } + + public String getApiBaseUrl() { + return apiBaseUrl; + } + + public String getApiVersion() { + return apiVersion; + } + + public String getFullApiUrl() { + return this.apiBaseUrl + apiVersion; + } +} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/reporting/ReportingController.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/reporting/ReportingController.java deleted file mode 100644 index 8120f27bd..000000000 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/reporting/ReportingController.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.mifosng.ui.reporting; - -import org.mifosng.configuration.ApplicationConfigurationService; -import org.mifosng.configuration.OAuthProviderDetails; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@Controller -@RequestMapping("/reporting") -public class ReportingController { - - private final ApplicationConfigurationService applicationConfigurationService; - - @Autowired - public ReportingController( - ApplicationConfigurationService applicationConfigurationService) { - this.applicationConfigurationService = applicationConfigurationService; - } - - @RequestMapping(value = "/flexireport", method = RequestMethod.GET) - public String viewFlexibleReportingPage(final Model model) { - -// UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) principal; -// ConsumerUserDetails user = (ConsumerUserDetails) authenticationToken.getPrincipal(); -// if (user.hasNoReportingAuthority()) { -// throw new AccessDeniedException(""); -// } - - OAuthProviderDetails oauthDetails = this.applicationConfigurationService - .retrieveOAuthProviderDetails(); - - model.addAttribute("baseUrl", oauthDetails.getProviderBaseUrl()); -// model.addAttribute("consumerKey", oauthDetails.getConsumerkey()); -// model.addAttribute("consumerSecret", oauthDetails.getSharedSecret()); -// - return "reports/flexireport"; - } - - @ExceptionHandler(AccessDeniedException.class) - public String accessDeniedException() { - return "unAuthorizedAction"; - } -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchydata-0.945.js b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchydata-0.947.js similarity index 87% rename from mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchydata-0.945.js rename to mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchydata-0.947.js index db152dc56..dc532c90a 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchydata-0.945.js +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/static/stretchydata-0.947.js @@ -4,12 +4,14 @@ $.stretchyData.displayAllExtraData = function(params) { - username="mifos"; - password="password"; if (!(params.url)) { alert(doI18N("reportingInitError - url parameter")); return; } + if (!(params.basicAuthKey)) { + alert(doI18N("reportingInitError - basicAuthKey parameter")); + return; + } if (!(params.datasetType)) { alert(doI18N("reportingInitError - datasetType parameter")); return; @@ -35,15 +37,13 @@ var valueClass = ""; if (params.valueClass) valueClass = params.valueClass; - displayAllExtraData(params.url, params.datasetType, + displayAllExtraData(params.url, params.basicAuthKey, params.datasetType, params.datasetPKValue, params.datasetTypeDiv, headingPrefix, headingClass, labelClass, valueClass); }; - $.stretchyData.popupEditDialog = function(url, datasetType, datasetName, - datasetPKValue, dsnDivName, title, width, height) { - popupEditDialog(url, datasetType, datasetName, datasetPKValue, - dsnDivName, title, width, height); + $.stretchyData.popupEditDialog = function(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName, title, width, height) { + popupEditDialog(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName, title, width, height); }; displayAllSuccessFunction = function(data, textStatus, jqXHR) { @@ -61,7 +61,7 @@ + doI18N(data.additionalFieldsSets[i].name) + ' - '; - extraDataNamesVar += editExtraDataLink(displayAllVars.url, + extraDataNamesVar += editExtraDataLink(displayAllVars.url, displayAllVars.basicAuthKey, displayAllVars.datasetType, data.additionalFieldsSets[i].name, displayAllVars.datasetPKValue, dsnDivName); @@ -73,7 +73,7 @@ for ( var i in data.additionalFieldsSets) { var dsnDivName = generateDsnDivName(displayAllVars.datasetType, i, displayAllVars.datasetTypeDiv); - viewExtraData(displayAllVars.url, displayAllVars.datasetType, + viewExtraData(displayAllVars.url, displayAllVars.basicAuthKey, displayAllVars.datasetType, data.additionalFieldsSets[i].name, displayAllVars.datasetPKValue, dsnDivName); } @@ -84,11 +84,12 @@ alert(jqXHR.responseText); }; - function displayAllExtraData(url, datasetType, datasetPKValue, + function displayAllExtraData(url, basicAuthKey, datasetType, datasetPKValue, datasetTypeDiv, headingPrefix, headingClass, labelClass, valueClass) { displayAllVars = { url : url, + basicAuthKey : basicAuthKey, datasetType : datasetType, datasetPKValue : datasetPKValue, datasetTypeDiv : datasetTypeDiv, @@ -98,16 +99,14 @@ valueClass : valueClass }; - displayAllUrl = url + "api/v1/additionalfields?type=" - + encodeURIComponent(datasetType); - getData(displayAllUrl, displayAllSuccessFunction, - displayAllErrorFunction); + displayAllUrl = url + "additionalfields?type=" + encodeURIComponent(datasetType); + getData(displayAllUrl, basicAuthKey, displayAllSuccessFunction, displayAllErrorFunction); } - function editExtraDataLink(url, datasetType, datasetName, datasetPKValue, + function editExtraDataLink(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName) { - var popupVar = "jQuery.stretchyData.popupEditDialog('" + url + "', '" + var popupVar = "jQuery.stretchyData.popupEditDialog('" + url + "', '" + basicAuthKey + "', '" + datasetType + "', '" + datasetName + "', " + datasetPKValue + ", '" + dsnDivName + "', '" + doI18N("Edit") + " " + doI18N(datasetName) + "', 900, 500)"; @@ -162,9 +161,8 @@ alert(jqXHR.responseText); }; - function viewExtraData(url, datasetType, datasetName, datasetPKValue, - dsnDivName) { - var viewExtraDataUrl = url + "api/v1/additionalfields/" + function viewExtraData(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName) { + var viewExtraDataUrl = url + "additionalfields/" + encodeURIComponent(datasetType) + "/" + encodeURIComponent(datasetName) + "/" + encodeURIComponent(datasetPKValue); @@ -172,22 +170,20 @@ var evalViewExtraDataSuccessFunction = "var viewExtraDataSuccessFunction = function(data, textStatus, jqXHR){ viewExtraDataset(data, '" + dsnDivName + "'); };" eval(evalViewExtraDataSuccessFunction); - getData(viewExtraDataUrl, viewExtraDataSuccessFunction, - viewExtraDataErrorFunction); + getData(viewExtraDataUrl, basicAuthKey, viewExtraDataSuccessFunction, viewExtraDataErrorFunction); } popupEditErrorFunction = function(jqXHR, textStatus, errorThrown) { alert("error"); - handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", - "#formerrors"); + handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors"); }; popupEditSuccessFunction = function(data, textStatus, jqXHR) { currentEditPopup.dialogDiv.append(extraDataBuildTemplate(data)); - extraDataOpenDialog(currentEditPopup.url); + extraDataOpenDialog(currentEditPopup.url, currentEditPopup.basicAuthKey); extraDataFormatDates(data.columnHeaders); }; - function popupEditDialog(url, datasetType, datasetName, datasetPKValue, - dsnDivName, title, width, height) { + + function popupEditDialog(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName, title, width, height) { currentEditPopup = { dialogDiv : $("
"), @@ -199,13 +195,13 @@ datasetName : datasetName, datasetPKValue : datasetPKValue, baseUrl : url, - url : url + "api/v1/additionalfields/" + basicAuthKey : basicAuthKey, + url : url + "additionalfields/" + encodeURIComponent(datasetType) + "/" + encodeURIComponent(datasetName) + "/" + encodeURIComponent(datasetPKValue) }; - getData(currentEditPopup.url, popupEditSuccessFunction, - popupEditErrorFunction); + getData(currentEditPopup.url, currentEditPopup.basicAuthKey, popupEditSuccessFunction, popupEditErrorFunction); } function generateDsnDivName(datasetType, i, uniqueDivid) { @@ -368,7 +364,7 @@ return o; }; - function extraDataOpenDialog(url) { + function extraDataOpenDialog(url, basicAuthKey) { // var saveButton = jQuery.i18n.prop('dialog.button.save'); // var cancelButton = jQuery.i18n.prop('dialog.button.cancel'); @@ -382,20 +378,17 @@ }); var form_data = JSON.stringify($('#entityform').serializeObject()); - // console.log(form_data); + var jqxhr = $.ajax({ url : url, type : 'POST', contentType : "application/json; charset=utf-8", - // dataType : 'jsonp', - // crossDomain : true, dataType : 'json', data : form_data, cache : false, beforeSend : function(xhr) { - var base64 = $.base64Encode(username + ":" + password); - console.log("base64: " + base64); - xhr.setRequestHeader("Authorization", "Basic " + base64); + console.log("base64: " + basicAuthKey); + xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey); }, success : function(data, textStatus, jqXHR) { currentEditPopup.dialogDiv.dialog("close"); @@ -406,8 +399,7 @@ currentEditPopup.dsnDivName) }, error : function(jqXHR, textStatus, errorThrown) { - handleXhrError(jqXHR, textStatus, errorThrown, - "#formErrorsTemplate", "#formerrors"); + handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors"); } }); }; @@ -457,23 +449,18 @@ /* end of code to fill data in edit form and display it */ - function getData(url, successFunction, errorFunction) { + function getData(url, basicAuthKey, successFunction, errorFunction) { $.ajax({ url : url, - cache : false, type : 'GET', contentType : "application/json; charset=utf-8", + dataType : 'json', cache : false, beforeSend : function(xhr) { - var base64 = $.base64Encode(username + ":" + password); - console.log("base64: " + base64); - xhr.setRequestHeader("Authorization", "Basic " + base64); + console.log("base64: " + basicAuthKey); + xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey); }, - // dataType : 'jsonp', - // crossDomain : true, - dataType : 'json', - // crossDomain : false, success : successFunction, error : errorFunction }); diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/admin/accountsettings.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/admin/accountsettings.jsp index 80356925d..a9a778f32 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/admin/accountsettings.jsp +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/admin/accountsettings.jsp @@ -20,6 +20,9 @@ - diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head.jsp index 090edae4b..ab4fac237 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head.jsp +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/common-head.jsp @@ -34,8 +34,7 @@ - - + diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/home.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/home.jsp index 734cbbfd9..1e2e3c499 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/home.jsp +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/home.jsp @@ -13,6 +13,10 @@