Search in sources :

Example 1 with OidcProvider

use of org.obiba.mica.web.controller.domain.OidcProvider in project mica2 by obiba.

the class SignController method signup.

@GetMapping("/signup")
public ModelAndView signup(HttpServletRequest request, @RequestParam(value = "redirect", required = false) String redirect, @CookieValue(value = "NG_TRANSLATE_LANG_KEY", required = false, defaultValue = "en") String locale, @RequestParam(value = "language", required = false) String language) {
    if (!micaConfigService.getConfig().isSignupEnabled())
        return new ModelAndView("redirect:" + micaConfigService.getContextPath() + "/");
    ModelAndView mv = new ModelAndView("signup");
    String lang = getLang(locale, language);
    List<OidcProvider> providers = getOidcProviders(lang, true).stream().map(o -> new OidcProvider(o, getOidcSignupUrl(o.getName(), request, redirect))).collect(Collectors.toList());
    mv.getModel().put("oidcProviders", providers);
    mv.getModel().put("authConfig", getAuthConfiguration());
    return mv;
}
Also used : RequestParam(org.springframework.web.bind.annotation.RequestParam) OidcProvider(org.obiba.mica.web.controller.domain.OidcProvider) Controller(org.springframework.stereotype.Controller) Collectors(java.util.stream.Collectors) UserAuthService(org.obiba.mica.core.service.UserAuthService) CookieValue(org.springframework.web.bind.annotation.CookieValue) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ModelAndView(org.springframework.web.servlet.ModelAndView) JSONException(org.json.JSONException) HttpServletRequest(javax.servlet.http.HttpServletRequest) URLEncoder(java.net.URLEncoder) List(java.util.List) Lists(com.google.common.collect.Lists) JSONObject(org.json.JSONObject) OIDCAuthProviderSummary(org.obiba.oidc.OIDCAuthProviderSummary) MicaConfigService(org.obiba.mica.micaConfig.service.MicaConfigService) AgateServerConfigService(org.obiba.mica.core.service.AgateServerConfigService) GetMapping(org.springframework.web.bind.annotation.GetMapping) AuthConfiguration(org.obiba.mica.web.controller.domain.AuthConfiguration) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ModelAndView(org.springframework.web.servlet.ModelAndView) OidcProvider(org.obiba.mica.web.controller.domain.OidcProvider) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with OidcProvider

use of org.obiba.mica.web.controller.domain.OidcProvider in project mica2 by obiba.

the class SignController method signin.

@GetMapping("/signin")
public ModelAndView signin(HttpServletRequest request, @RequestParam(value = "redirect", required = false) String redirect, @CookieValue(value = "NG_TRANSLATE_LANG_KEY", required = false, defaultValue = "en") String locale, @RequestParam(value = "language", required = false) String language) {
    ModelAndView mv = new ModelAndView("signin");
    String lang = getLang(locale, language);
    List<OidcProvider> providers = getOidcProviders(lang, false).stream().map(o -> new OidcProvider(o, getOidcSigninUrl(o.getName(), request, redirect))).collect(Collectors.toList());
    mv.getModel().put("oidcProviders", providers);
    return mv;
}
Also used : RequestParam(org.springframework.web.bind.annotation.RequestParam) OidcProvider(org.obiba.mica.web.controller.domain.OidcProvider) Controller(org.springframework.stereotype.Controller) Collectors(java.util.stream.Collectors) UserAuthService(org.obiba.mica.core.service.UserAuthService) CookieValue(org.springframework.web.bind.annotation.CookieValue) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ModelAndView(org.springframework.web.servlet.ModelAndView) JSONException(org.json.JSONException) HttpServletRequest(javax.servlet.http.HttpServletRequest) URLEncoder(java.net.URLEncoder) List(java.util.List) Lists(com.google.common.collect.Lists) JSONObject(org.json.JSONObject) OIDCAuthProviderSummary(org.obiba.oidc.OIDCAuthProviderSummary) MicaConfigService(org.obiba.mica.micaConfig.service.MicaConfigService) AgateServerConfigService(org.obiba.mica.core.service.AgateServerConfigService) GetMapping(org.springframework.web.bind.annotation.GetMapping) AuthConfiguration(org.obiba.mica.web.controller.domain.AuthConfiguration) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ModelAndView(org.springframework.web.servlet.ModelAndView) OidcProvider(org.obiba.mica.web.controller.domain.OidcProvider) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

Strings (com.google.common.base.Strings)2 Lists (com.google.common.collect.Lists)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URLEncoder (java.net.URLEncoder)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 AgateServerConfigService (org.obiba.mica.core.service.AgateServerConfigService)2 UserAuthService (org.obiba.mica.core.service.UserAuthService)2 MicaConfigService (org.obiba.mica.micaConfig.service.MicaConfigService)2 AuthConfiguration (org.obiba.mica.web.controller.domain.AuthConfiguration)2 OidcProvider (org.obiba.mica.web.controller.domain.OidcProvider)2 OIDCAuthProviderSummary (org.obiba.oidc.OIDCAuthProviderSummary)2 Controller (org.springframework.stereotype.Controller)2 CookieValue (org.springframework.web.bind.annotation.CookieValue)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 RequestParam (org.springframework.web.bind.annotation.RequestParam)2