Search in sources :

Example 1 with AppsFormBasedDetails

use of org.maxkey.entity.apps.AppsFormBasedDetails in project MaxKey by dromara.

the class FormBasedDetailsController method forwardUpdate.

@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
    ModelAndView modelAndView = new ModelAndView("apps/formbased/appUpdate");
    AppsFormBasedDetails formBasedDetails = formBasedDetailsService.getAppDetails(id, false);
    decoderSecret(formBasedDetails);
    decoderSharedPassword(formBasedDetails);
    formBasedDetails.transIconBase64();
    modelAndView.addObject("model", formBasedDetails);
    return modelAndView;
}
Also used : AppsFormBasedDetails(org.maxkey.entity.apps.AppsFormBasedDetails) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with AppsFormBasedDetails

use of org.maxkey.entity.apps.AppsFormBasedDetails 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;
}
Also used : AbstractAuthorizeAdapter(org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter) FormBasedDefaultAdapter(org.maxkey.authz.formbased.endpoint.adapter.FormBasedDefaultAdapter) AppsFormBasedDetails(org.maxkey.entity.apps.AppsFormBasedDetails) ModelAndView(org.springframework.web.servlet.ModelAndView) Apps(org.maxkey.entity.apps.Apps) Accounts(org.maxkey.entity.Accounts) Operation(io.swagger.v3.oas.annotations.Operation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with AppsFormBasedDetails

use of org.maxkey.entity.apps.AppsFormBasedDetails in project MaxKey by dromara.

the class FormBasedNetease163EmailAdapter method authorize.

@Override
public ModelAndView authorize(ModelAndView modelAndView) {
    modelAndView.setViewName("authorize/formbased_163email_sso_submint");
    AppsFormBasedDetails details = (AppsFormBasedDetails) app;
    modelAndView.addObject("username", account.getRelatedUsername().substring(account.getRelatedUsername().indexOf("@")));
    modelAndView.addObject("email", account.getRelatedUsername());
    modelAndView.addObject("password", account.getRelatedPassword());
    if (ConstsBoolean.isTrue(details.getIsExtendAttr())) {
        modelAndView.addObject("extendAttr", details.getExtendAttr());
        modelAndView.addObject("isExtendAttr", true);
    } else {
        modelAndView.addObject("isExtendAttr", false);
    }
    modelAndView.addObject("action", details.getRedirectUri());
    modelAndView.addObject("usernameMapping", details.getUsernameMapping());
    modelAndView.addObject("passwordMapping", details.getPasswordMapping());
    return modelAndView;
}
Also used : AppsFormBasedDetails(org.maxkey.entity.apps.AppsFormBasedDetails)

Example 4 with AppsFormBasedDetails

use of org.maxkey.entity.apps.AppsFormBasedDetails in project MaxKey by dromara.

the class FormBasedDetailsServiceTest method insert.

@Test
public void insert() throws Exception {
    _logger.info("insert...");
    AppsFormBasedDetails formBasedDetails = new AppsFormBasedDetails();
    service.insert(formBasedDetails);
    Thread.sleep(1000);
    service.remove(formBasedDetails.getId());
}
Also used : AppsFormBasedDetails(org.maxkey.entity.apps.AppsFormBasedDetails) Test(org.junit.Test)

Example 5 with AppsFormBasedDetails

use of org.maxkey.entity.apps.AppsFormBasedDetails in project MaxKey by dromara.

the class FormBasedDetailsServiceTest method queryPageResults.

@Test
public void queryPageResults() throws Exception {
    _logger.info("queryPageResults...");
    AppsFormBasedDetails formBasedDetails = new AppsFormBasedDetails();
    formBasedDetails.setPageNumber(2);
    _logger.info("queryPageResults " + service.queryPageResults(formBasedDetails));
}
Also used : AppsFormBasedDetails(org.maxkey.entity.apps.AppsFormBasedDetails) Test(org.junit.Test)

Aggregations

AppsFormBasedDetails (org.maxkey.entity.apps.AppsFormBasedDetails)13 Test (org.junit.Test)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 Operation (io.swagger.v3.oas.annotations.Operation)1 Date (java.util.Date)1 AbstractAuthorizeAdapter (org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter)1 FormBasedDefaultAdapter (org.maxkey.authz.formbased.endpoint.adapter.FormBasedDefaultAdapter)1 Accounts (org.maxkey.entity.Accounts)1 Apps (org.maxkey.entity.apps.Apps)1