use of org.maxkey.entity.Accounts in project MaxKey by dromara.
the class AppListController method appUserConfig.
@ResponseBody
@RequestMapping(value = { "/appUserConfig" })
public Message appUserConfig(@RequestParam("protocol") String protocol, @RequestParam("credential") int credential, @RequestParam("appId") String appId, @RequestParam("identity_username") String identity_username, @RequestParam("identity_password") String identity_password) {
Apps app = appsService.get(appId);
UserInfo userInfo = WebContext.getUserInfo();
Accounts appUsers = new Accounts();
appUsers.setAppId(appId);
appUsers.setUserId(userInfo.getId());
if (identity_password != null && !identity_password.equals("") && credential == Apps.CREDENTIALS.USER_DEFINED) {
appUsers = appUsersService.load(new Accounts(userInfo.getId(), appId));
if (appUsers == null) {
appUsers = new Accounts();
appUsers.setId(appUsers.generateId());
appUsers.setAppId(appId);
appUsers.setAppName(app.getName());
appUsers.setUserId(userInfo.getId());
appUsers.setUsername(userInfo.getUsername());
appUsers.setDisplayName(userInfo.getDisplayName());
appUsers.setRelatedUsername(identity_username);
appUsers.setRelatedPassword(PasswordReciprocal.getInstance().encode(identity_password));
appUsers.setInstId(userInfo.getInstId());
appUsers.setStatus(ConstsStatus.ACTIVE);
appUsersService.insert(appUsers);
} else {
appUsers.setRelatedUsername(identity_username);
appUsers.setRelatedPassword(PasswordReciprocal.getInstance().encode(identity_password));
appUsersService.update(appUsers);
}
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS), MessageType.success);
}
use of org.maxkey.entity.Accounts in project MaxKey by dromara.
the class FormBasedAuthorizeEndpoint method authorize.
@Operation(summary = "FormBased认证地址接口", description = "参数应用ID", method = "GET")
@RequestMapping("/authz/formbased/{id}")
public ModelAndView authorize(HttpServletRequest request, @PathVariable("id") String id) {
AppsFormBasedDetails formBasedDetails = formBasedDetailsService.getAppDetails(id, true);
_logger.debug("formBasedDetails {}", formBasedDetails);
Apps application = getApp(id);
formBasedDetails.setAdapter(application.getAdapter());
formBasedDetails.setIsAdapter(application.getIsAdapter());
ModelAndView modelAndView = null;
Accounts account = getAccounts(formBasedDetails);
_logger.debug("Accounts {}", account);
if (account == null) {
return generateInitCredentialModelAndView(id, "/authz/formbased/" + id);
} else {
modelAndView = new ModelAndView();
AbstractAuthorizeAdapter adapter;
if (ConstsBoolean.isTrue(formBasedDetails.getIsAdapter())) {
Object formBasedAdapter = Instance.newInstance(formBasedDetails.getAdapter());
adapter = (AbstractAuthorizeAdapter) formBasedAdapter;
} else {
FormBasedDefaultAdapter formBasedDefaultAdapter = new FormBasedDefaultAdapter();
adapter = (AbstractAuthorizeAdapter) formBasedDefaultAdapter;
}
adapter.setAuthentication((SigninPrincipal) WebContext.getAuthentication().getPrincipal());
adapter.setUserInfo(WebContext.getUserInfo());
adapter.setApp(formBasedDetails);
adapter.setAccount(account);
modelAndView = adapter.authorize(modelAndView);
}
_logger.debug("FormBased View Name {}", modelAndView.getViewName());
return modelAndView;
}
use of org.maxkey.entity.Accounts in project MaxKey by dromara.
the class ExtendApiAuthorizeEndpoint method authorize.
@Operation(summary = "ExtendApi认证地址接口", description = "参数应用ID", method = "GET")
@RequestMapping("/authz/api/{id}")
public ModelAndView authorize(HttpServletRequest request, @PathVariable("id") String id) {
ModelAndView modelAndView = new ModelAndView("authorize/redirect_sso_submit");
Apps apps = getApp(id);
_logger.debug("" + apps);
if (ConstsBoolean.isTrue(apps.getIsAdapter())) {
AbstractAuthorizeAdapter adapter = (AbstractAuthorizeAdapter) Instance.newInstance(apps.getAdapter());
Accounts account = getAccounts(apps);
if (apps.getCredential() == Apps.CREDENTIALS.USER_DEFINED && account == null) {
return generateInitCredentialModelAndView(id, "/authorize/api/" + id);
}
adapter.setAuthentication((SigninPrincipal) WebContext.getAuthentication().getPrincipal());
adapter.setUserInfo(WebContext.getUserInfo());
adapter.setApp(apps);
adapter.setAccount(account);
return adapter.authorize(modelAndView);
} else {
modelAndView.addObject("redirect_uri", apps.getLoginUrl());
return modelAndView;
}
}
use of org.maxkey.entity.Accounts in project MaxKey by dromara.
the class AccountsServiceTest method get.
@Test
public void get() throws Exception {
_logger.info("get...");
Accounts accounts = service.get("26b1c864-ae81-4b1f-9355-74c4c699cb6b");
_logger.info("accounts " + accounts);
}
use of org.maxkey.entity.Accounts in project MaxKey by dromara.
the class AccountsServiceTest method load.
@Test
public void load() throws Exception {
_logger.info("get...");
Accounts queryAccounts = new Accounts("7BF5315CA1004CDB8E614B0361C4D46B", "fe86db85-5475-4494-b5aa-dbd3b886ff64");
Accounts accounts = service.load(queryAccounts);
_logger.info("accounts " + accounts);
}
Aggregations