com.onelogin.saml2.exception.SettingsException Java Examples

The following examples show how to use com.onelogin.saml2.exception.SettingsException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthTokenProcessorHandler.java    From deprecated-security-advanced-modules with Apache License 2.0 6 votes vote down vote up
boolean handle(RestRequest restRequest, RestChannel restChannel) throws Exception {
    try {
        final SecurityManager sm = System.getSecurityManager();

        if (sm != null) {
            sm.checkPermission(new SpecialPermission());
        }

        return AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
            @Override
            public Boolean run() throws XPathExpressionException, SamlConfigException, IOException,
                    ParserConfigurationException, SAXException, SettingsException {
                return handleLowLevel(restRequest, restChannel);
            }
        });
    } catch (PrivilegedActionException e) {
        if (e.getCause() instanceof Exception) {
            throw (Exception) e.getCause();
        } else {
            throw new RuntimeException(e);
        }
    }
}
 
Example #2
Source File: SSOController.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The service provider-initiated single logout (SLO)
 * @param request the Spark Request instance used in the current request scope
 * @param response the Spark Response instance used in the current response scope
 * @return the response object
 */
public static Object logout(Request request, Response response) {
    if (ssoConfig.isPresent() && ConfigDefaults.get().isSingleSignOnEnabled()) {
        try {
            AuthenticationServiceFactory.getInstance()
                    .getAuthenticationService()
                    .invalidate(request.raw(), response.raw());
            final Auth auth = new Auth(ssoConfig.get(), request.raw(), response.raw());
            auth.logout();
            return response;
        }
        catch (SettingsException | ServletException | IOException | XMLEntityException e) {
            LOG.error("Unable to parse settings for SSO and/or XML parsing: " + e.getMessage());
        }
    }

    return null;
}
 
Example #3
Source File: LoginController.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the login page.
 *
 * @param request the request object
 * @param response the response object
 * @return the model and view
 */
public static ModelAndView loginView(Request request, Response response) {
    if (ConfigDefaults.get().isSingleSignOnEnabled() && SSOConfig.getSSOSettings().isPresent()) {
        try {
            Auth auth = new Auth(SSOConfig.getSSOSettings().get(), request.raw(), response.raw());
            auth.login(LoginHelper.DEFAULT_URL_BOUNCE);
        }
        catch (SettingsException | IOException e) {
            log.error(e.getMessage());
        }
        return new ModelAndView(new HashMap<>(), "controllers/login/templates/login.jade");
        // the return above is dummy, we already sent a redirect to the IdP login page via `auth.login`
    }
    else {
        // Redirect to user creation if needed
        if (!UserManager.satelliteHasUsers()) {
            response.redirect(URL_CREATE_FIRST_USER);
        }

        // Handle "url_bounce" parameters
        String urlBounce = request.queryParams("url_bounce");
        String reqMethod = request.queryParams("request_method");
        urlBounce = LoginHelper.updateUrlBounce(urlBounce, reqMethod);

        // In case we are authenticated go directly to redirect target
        if (AclManager.hasAcl("user_authenticated()", request.raw(), null)) {
            log.debug("Already authenticated, redirecting to: " + urlBounce);
            response.redirect(urlBounce);
        }

        Map<String, Object> model = new HashMap<>();
        model.put("url_bounce", urlBounce);
        model.put("isUyuni", ConfigDefaults.get().isUyuni());
        model.put("title", Config.get().getString(ConfigDefaults.PRODUCT_NAME) + " - Sign In");
        model.put("request_method", reqMethod);
        model.put("validationErrors", Json.GSON.toJson(LoginHelper.validateDBVersion()));
        model.put("schemaUpgradeRequired", Json.GSON.toJson(LoginHelper.isSchemaUpgradeRequired()));
        model.put("webVersion", ConfigDefaults.get().getProductVersion());
        model.put("productName", Config.get().getString(ConfigDefaults.PRODUCT_NAME));
        model.put("customHeader", Config.get().getString("java.custom_header"));
        model.put("customFooter", Config.get().getString("java.custom_footer"));
        model.put("legalNote", Config.get().getString("java.legal_note"));
        model.put("loginLength", Config.get().getString("max_user_len"));
        model.put("passwordLength", Config.get().getString("max_passwd_len"));

        return new ModelAndView(model, "controllers/login/templates/login.jade");
    }
}