PasswordReciprocal

This commit is contained in:
MaxKey
2021-12-19 11:22:11 +08:00
parent 6b6dafc79e
commit b483af3f89
3 changed files with 14 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.entity.SocialsProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -194,7 +195,9 @@ public class SocialSignOnProviderService{
socialsProvider.setProviderName(rs.getString("providername"));
socialsProvider.setIcon(rs.getString("icon"));
socialsProvider.setClientId(rs.getString("clientid"));
socialsProvider.setClientSecret(rs.getString("clientsecret"));
String clientSecret= rs.getString("clientsecret");
clientSecret = PasswordReciprocal.getInstance().decoder(clientSecret);
socialsProvider.setClientSecret(clientSecret);
socialsProvider.setAgentId(rs.getString("agentId"));
socialsProvider.setHidden(rs.getString("hidden"));
socialsProvider.setSortIndex(rs.getInt("sortindex"));

View File

@@ -19,6 +19,7 @@ package org.maxkey.web.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.entity.SocialsProvider;
import org.maxkey.persistence.service.SocialsProviderService;
import org.maxkey.web.WebContext;
@@ -66,7 +67,9 @@ public class SocialsProviderController {
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("socialsprovider/socialsProviderUpdate");
modelAndView.addObject("model",socialsProviderService.get(id));
SocialsProvider socialsProvider = socialsProviderService.get(id);
socialsProvider.setClientSecret(PasswordReciprocal.getInstance().decoder(socialsProvider.getClientSecret()));
modelAndView.addObject("model",socialsProvider);
return modelAndView;
}
@@ -75,6 +78,7 @@ public class SocialsProviderController {
public Message insert(@ModelAttribute("socialsProvider") SocialsProvider socialsProvider) {
_logger.debug("-Add :" + socialsProvider);
socialsProvider.setInstId(WebContext.getUserInfo().getInstId());
socialsProvider.setClientSecret(PasswordReciprocal.getInstance().encode(socialsProvider.getClientSecret()));
if (socialsProviderService.insert(socialsProvider)) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
@@ -113,6 +117,7 @@ public class SocialsProviderController {
public Message update(@ModelAttribute("socialsProvider") SocialsProvider socialsProvider) {
_logger.debug("-update socialsProvider :" + socialsProvider);
socialsProvider.setInstId(WebContext.getUserInfo().getInstId());
socialsProvider.setClientSecret(PasswordReciprocal.getInstance().encode(socialsProvider.getClientSecret()));
if (socialsProviderService.update(socialsProvider)) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);

View File

@@ -21,6 +21,7 @@ import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.entity.Synchronizers;
import org.maxkey.persistence.service.SynchronizersService;
import org.maxkey.synchronizer.ISynchronizerService;
@@ -72,6 +73,7 @@ public class SynchronizersController {
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("synchronizers/synchronizerUpdate");
Synchronizers synchronizers=synchronizersService.get(id);
synchronizers.setCredentials(PasswordReciprocal.getInstance().decoder(synchronizers.getCredentials()));
modelAndView.addObject("model",synchronizers);
return modelAndView;
}
@@ -88,6 +90,7 @@ public class SynchronizersController {
public Message update(@ModelAttribute("synchronizers") Synchronizers synchronizers) {
_logger.debug("-update synchronizers :" + synchronizers);
synchronizers.setInstId(WebContext.getUserInfo().getInstId());
synchronizers.setCredentials(PasswordReciprocal.getInstance().encode(synchronizers.getCredentials()));
if (synchronizersService.update(synchronizers)) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
@@ -111,6 +114,7 @@ public class SynchronizersController {
try {
for(String sysId : ids) {
Synchronizers synchronizer = synchronizersService.get(sysId);
synchronizer.setCredentials(PasswordReciprocal.getInstance().decoder(synchronizer.getCredentials()));
_logger.debug("synchronizer " + synchronizer);
ISynchronizerService synchronizerService = WebContext.getBean(synchronizer.getService(),ISynchronizerService.class);
synchronizerService.setSynchronizer(synchronizer);