Search in sources :

Example 6 with Apps

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

the class OAuth20DetailsController method forwardUpdate.

@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
    ModelAndView modelAndView = new ModelAndView("apps/oauth20/appUpdate");
    BaseClientDetails baseClientDetails = (BaseClientDetails) oauth20JdbcClientDetailsService.loadClientByClientId(id, false);
    // 
    Apps application = appsService.get(id);
    decoderSecret(application);
    AppsOAuth20Details oauth20Details = new AppsOAuth20Details(application, baseClientDetails);
    oauth20Details.setSecret(application.getSecret());
    oauth20Details.setClientSecret(application.getSecret());
    _logger.debug("forwardUpdate " + oauth20Details);
    oauth20Details.transIconBase64();
    modelAndView.addObject("model", oauth20Details);
    return modelAndView;
}
Also used : BaseClientDetails(org.maxkey.entity.apps.oauth2.provider.client.BaseClientDetails) ModelAndView(org.springframework.web.servlet.ModelAndView) Apps(org.maxkey.entity.apps.Apps) AppsOAuth20Details(org.maxkey.entity.apps.AppsOAuth20Details) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Apps

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

the class GroupPrivilegesController method queryAppsInGroup.

@RequestMapping(value = { "/queryAppsInGroup" })
@ResponseBody
public JpaPageResults<GroupPrivileges> queryAppsInGroup(@ModelAttribute("groupApp") GroupPrivileges groupApp) {
    JpaPageResults<GroupPrivileges> groupPrivileges;
    groupApp.setInstId(WebContext.getUserInfo().getInstId());
    groupPrivileges = groupPrivilegesService.queryPageResults("appsInGroup", groupApp);
    if (groupPrivileges != null && groupPrivileges.getRows() != null) {
        for (Apps app : groupPrivileges.getRows()) {
            app.transIconBase64();
        }
    }
    return groupPrivileges;
}
Also used : GroupPrivileges(org.maxkey.entity.GroupPrivileges) Apps(org.maxkey.entity.apps.Apps) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with Apps

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

the class GroupPrivilegesController method queryAppsNotInGroup.

@RequestMapping(value = { "/queryAppsNotInGroup" })
@ResponseBody
public JpaPageResults<GroupPrivileges> queryAppsNotInGroup(@ModelAttribute("groupApp") GroupPrivileges groupApp) {
    JpaPageResults<GroupPrivileges> groupPrivileges;
    groupApp.setInstId(WebContext.getUserInfo().getInstId());
    groupPrivileges = groupPrivilegesService.queryPageResults("appsNotInGroup", groupApp);
    if (groupPrivileges != null && groupPrivileges.getRows() != null) {
        for (Apps app : groupPrivileges.getRows()) {
            app.transIconBase64();
        }
    }
    return groupPrivileges;
}
Also used : GroupPrivileges(org.maxkey.entity.GroupPrivileges) Apps(org.maxkey.entity.apps.Apps) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with Apps

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

the class HistoryLoginAppAdapter method postHandle.

/**
 * postHandle .
 * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(
 *          javax.servlet.http.HttpServletRequest,
 *          javax.servlet.http.HttpServletResponse, java.lang.Object)
 */
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    _logger.debug("postHandle");
    final Apps app = (Apps) WebContext.getAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP);
    String sessionId = (String) WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID);
    final UserInfo userInfo = WebContext.getUserInfo();
    _logger.debug("sessionId : " + sessionId + " ,appId : " + app.getId());
    HistoryLoginApps historyLoginApps = new HistoryLoginApps();
    historyLoginApps.setAppId(app.getId());
    historyLoginApps.setSessionId(sessionId);
    historyLoginApps.setAppName(app.getName());
    historyLoginApps.setUserId(userInfo.getId());
    historyLoginApps.setUsername(userInfo.getUsername());
    historyLoginApps.setDisplayName(userInfo.getDisplayName());
    historyLoginApps.setInstId(userInfo.getInstId());
    historyLoginAppsService.insert(historyLoginApps);
    WebContext.removeAttribute(WebConstants.CURRENT_SINGLESIGNON_URI);
    WebContext.removeAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID);
}
Also used : UserInfo(org.maxkey.entity.UserInfo) HistoryLoginApps(org.maxkey.entity.HistoryLoginApps) Apps(org.maxkey.entity.apps.Apps) HistoryLoginApps(org.maxkey.entity.HistoryLoginApps)

Example 10 with Apps

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

the class ExtendApiZentaoAdapter method authorize.

@Override
public ModelAndView authorize(ModelAndView modelAndView) {
    Apps details = (Apps) app;
    // extraAttrs from Applications
    ExtraAttrs extraAttrs = null;
    if (details.getIsExtendAttr() == 1) {
        extraAttrs = new ExtraAttrs(details.getExtendAttr());
    }
    _logger.trace("Extra Attrs " + extraAttrs);
    String code = details.getPrincipal();
    String key = details.getCredentials();
    String time = "" + Instant.now().getEpochSecond();
    String token = DigestUtils.md5Hex(code + key + time);
    _logger.debug("" + token);
    String account = userInfo.getUsername();
    String redirect_uri = details.getLoginUrl();
    if (redirect_uri.indexOf("api.php?") < 0) {
        if (redirect_uri.endsWith("/")) {
            redirect_uri += String.format(login_url_template, account, code, time, token);
        } else {
            redirect_uri += "/" + String.format(login_url_template, account, code, time, token);
        }
    } else if (redirect_uri.endsWith("&")) {
        redirect_uri += String.format(login_url_m_template, account, code, time, token);
    } else {
        redirect_uri += "&" + String.format(login_url_m_template, account, code, time, token);
    }
    _logger.debug("redirect_uri : " + redirect_uri);
    modelAndView = new ModelAndView("authorize/redirect_sso_submit");
    modelAndView.addObject("redirect_uri", redirect_uri);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) ExtraAttrs(org.maxkey.entity.ExtraAttrs) Apps(org.maxkey.entity.apps.Apps)

Aggregations

Apps (org.maxkey.entity.apps.Apps)28 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 ModelAndView (org.springframework.web.servlet.ModelAndView)13 Operation (io.swagger.v3.oas.annotations.Operation)7 AbstractAuthorizeAdapter (org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter)5 ExtraAttrs (org.maxkey.entity.ExtraAttrs)5 Accounts (org.maxkey.entity.Accounts)4 UserInfo (org.maxkey.entity.UserInfo)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 ClientDetails (org.maxkey.entity.apps.oauth2.provider.ClientDetails)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashMap (java.util.HashMap)2 Cookie (javax.servlet.http.Cookie)2 SigninPrincipal (org.maxkey.authn.SigninPrincipal)2 AuthorizationRequest (org.maxkey.authz.oauth2.provider.AuthorizationRequest)2 OAuth2Authentication (org.maxkey.authz.oauth2.provider.OAuth2Authentication)2 GroupPrivileges (org.maxkey.entity.GroupPrivileges)2 HistoryLoginApps (org.maxkey.entity.HistoryLoginApps)2 UserApps (org.maxkey.entity.apps.UserApps)2 HttpRequestAdapter (org.maxkey.web.HttpRequestAdapter)2