Search in sources :

Example 1 with AuthConfiguration

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

the class SignController method getAuthConfiguration.

private AuthConfiguration getAuthConfiguration() {
    try {
        JSONObject authConfig = userAuthService.getPublicConfiguration();
        JSONObject clientConfig = userAuthService.getClientConfiguration();
        return new AuthConfiguration(authConfig, clientConfig);
    } catch (Exception e) {
        return new AuthConfiguration(new JSONObject(), new JSONObject());
    }
}
Also used : JSONObject(org.json.JSONObject) AuthConfiguration(org.obiba.mica.web.controller.domain.AuthConfiguration) JSONException(org.json.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with AuthConfiguration

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

the class ProfileController method getProfile.

@GetMapping("/profile")
public ModelAndView getProfile() {
    Subject subject = SecurityUtils.getSubject();
    if (subject.isAuthenticated()) {
        ModelAndView mv = new ModelAndView("profile");
        mv.getModel().put("oidcProviders", userAuthService.getOidcProviders("en"));
        mv.getModel().put("authConfig", new AuthConfiguration(userAuthService.getPublicConfiguration(), null));
        return mv;
    } else {
        return new ModelAndView("redirect:signin?redirect=" + micaConfigService.getContextPath() + "/profile");
    }
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) AuthConfiguration(org.obiba.mica.web.controller.domain.AuthConfiguration) Subject(org.apache.shiro.subject.Subject) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

AuthConfiguration (org.obiba.mica.web.controller.domain.AuthConfiguration)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Subject (org.apache.shiro.subject.Subject)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1