use of org.maxkey.authz.formbased.endpoint.adapter.FormBasedDefaultAdapter 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;
}
Aggregations