Package com.adito.security

Examples of com.adito.security.AuthenticationScheme


    public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        PolicyUtil.checkPermission(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, PolicyConstants.PERM_EDIT_AND_ASSIGN, request);
        AuthenticationSchemesForm schemesForm = (AuthenticationSchemesForm) form;
        int id = schemesForm.getSelectedResource();
        AuthenticationScheme scheme = getAuthenticationScheme(form);

        List resourceIds = PolicyDatabaseFactory.getInstance().getGrantedResourcesOfType(getSessionInfo(request).getUser(),
            PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE);
        // remove the WebDav and Embedded Client as they are not sign-on-able.
        resourceIds.remove(new Integer(3));
        resourceIds.remove(new Integer(4));
        resourceIds.remove(new Integer(id));

        if (resourceIds.size() == 0) {
            saveError(request, "authenticationSchemes.error.mustHavePolicySuperUserAssociation", scheme);
            return list(mapping, form, request, response);
        }

        List<AuthenticationScheme> authSchemes = SystemDatabaseFactory.getInstance().getAuthenticationSchemeSequences();
        int enabled = 0;
        for (Iterator i = authSchemes.iterator(); i.hasNext();) {
            AuthenticationScheme oseq = (DefaultAuthenticationScheme) i.next();
            if (oseq.getResourceId() == id && !oseq.getEnabled()) {
                throw new Exception("Scheme already disabled.");
            }
            if (oseq.getEnabled() && !oseq.isSystemScheme()) {
                enabled++;
            }
        }
        if (enabled == 1) {
            saveError(request, "authenticationSchemes.error.cantDisableLastEnabledScheme", scheme);
View Full Code Here


     * @throws Exception on any error
     */
    public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        PolicyUtil.checkPermission(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, PolicyConstants.PERM_EDIT_AND_ASSIGN, request);
        AuthenticationScheme scheme = getAuthenticationScheme(form);
        if (scheme.getEnabled()) {
            throw new Exception("Alreadty enabled.");
        }
        scheme.setEnabled(true);
        SystemDatabaseFactory.getInstance().updateAuthenticationSchemeSequence(scheme);
        saveMessage(request, "authenticationSchemes.message.schemeEnabled", scheme);
        return getRedirectWithMessages(mapping, request);
    }
View Full Code Here

    public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        PolicyUtil.checkPermissions(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, new Permission[] {
                        PolicyConstants.PERM_EDIT_AND_ASSIGN, PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN,
                        PolicyConstants.PERM_ASSIGN }, request);
        AuthenticationScheme seq = getAuthenticationScheme(form);
        ResourceStack.pushToEditingStack(request.getSession(), seq);
        return mapping.findForward("edit");
    }
View Full Code Here

     * @return ActionForward
     * @throws Exception
     */
    public ActionForward moveUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        AuthenticationScheme scheme = getAuthenticationScheme(form);
        if (scheme.getPriorityInt() == 1) {
            saveError(request, "authenticationSchemes.error.moveup.top", scheme);
            return unspecified(mapping, form, request, response);
        }
       
        PolicyUtil.checkPermission(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, PolicyConstants.PERM_EDIT_AND_ASSIGN, request);
View Full Code Here

     * @param response
     * @return ActionForward
     * @throws Exception
     */
    public ActionForward moveDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        AuthenticationScheme scheme = getAuthenticationScheme(form);
        List<AuthenticationScheme> schemes = SystemDatabaseFactory.getInstance().getAuthenticationSchemeSequences();
        if (schemes.indexOf(scheme) == schemes.size() - 1) {
            saveError(request, "authenticationSchemes.error.movedown.bottom", scheme);
            return unspecified(mapping, form, request, response);
        }
View Full Code Here

     * @return forward
     * @throws Exception on any error
     */
    public static ActionForward checkAuthSession(LogonForm form, boolean reset, ActionMapping mapping, HttpServletRequest request,
                    HttpServletResponse response, LogonStateAndCache logonStateMachine) throws Exception{
        AuthenticationScheme authScheme = (AuthenticationScheme) request.getSession().getAttribute(Constants.AUTH_SESSION);
        if (authScheme == null || reset || authScheme.getResourceId() != logonStateMachine.getHighestPriorityScheme().getResourceId()) {

            if (log.isDebugEnabled())
                log.debug("Creating new authentication session using scheme '" + "THE SCHEME NAME" + "'");

            // Try to initalise the highest priority scheme,
            if (request.getSession().getAttribute(Constants.SESSION_LOCKED) != null) {
                // If session locked then only display password

                SessionInfo info = LogonControllerFactory.getInstance().getSessionInfo(request);
                Calendar now = new GregorianCalendar();
                authScheme = new DefaultAuthenticationScheme(info.getRealmId(), Integer.MAX_VALUE, "Fake sheme", "Fake scheme",
                                now, now, true, 0);
                authScheme.addModule(PasswordAuthenticationModule.MODULE_NAME);
            } else {
                authScheme = logonStateMachine.getHighestPriorityScheme();
            }

            if (authScheme == null) {
                log.info("There are no authenticated schemes.");
                return null;
            } else {
               
                authScheme.setUser(logonStateMachine.getUser());
                authScheme.init(request.getSession());
               
                if (authScheme.nextAuthenticationModule() == null) {
                    throw new Exception("No authentication modules have been configured.");
                }
                request.getSession().setAttribute(Constants.AUTH_SESSION, authScheme);
                if (log.isDebugEnabled())
                    log.debug("Scheme " + authScheme.getSchemeName() + " initialised OK");
            }
        }

        while (true) {
            AuthenticationModule module = authScheme.currentAuthenticationModule();
            if (form != null) {
                form.setCurrentModuleIndex(authScheme.getCurrentModuleIndex());
            }

            // The module may wish to forward somewhere other than to the
            // default login page
            ActionForward forward = module.startAuthentication(mapping, request, response);

            if (module.isRequired()) {
                return forward;
            } else {
                // Are we at the end of the sequence
                if (authScheme.nextAuthenticationModule() == null) {
                    return LogonAction.finishAuthentication(authScheme, request, response);
                }
            }
        }
    }
View Full Code Here

            /*
             * If we wern't expecting authentication, but we got it anyway, the
             * client probably doesn't support cookies.
             */
            AuthenticationScheme authScheme = (DefaultAuthenticationScheme) req.getSession().getAttribute(Constants.AUTH_SESSION);
            if (authScheme != null) {
                throw new IOException("Not expecting a realm, yet an authentication session is available. This is unexpected!");
            }

            doAuth(expectingRealm, username, DAVServlet.configureAuthenticationScheme(req, res));

            /*
             * We now can get the sessionInfo object for this session and make
             * it temporary this will ensure it is destroyed once the request is
             * complete.
             */
            sessionInfo = LogonControllerFactory.getInstance().getSessionInfo(req);
            sessionInfo.setTemporary(true);

        } else if (expectingRealm.equals(WebDAVAuthenticationModule.DEFAULT_REALM)) {
            AuthenticationScheme authScheme = (DefaultAuthenticationScheme) req.getSession().getAttribute(Constants.AUTH_SESSION);
            if (authScheme == null) {
                throw new IOException("No authentication scheme initialised.");
            }

            doAuth(expectingRealm, username, authScheme);
View Full Code Here

                List nowAttached = this.getSelectedAccountsList();
                // only do this if the super user has been removed.
                if (wasAttached.contains(getUser()) && !nowAttached.contains(getUser().getPrincipalName())) {
                    List authSchemes = ResourceUtil.getGrantedResource(info, PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE);
                    for (Iterator iter = authSchemes.iterator(); iter.hasNext();) {
                        AuthenticationScheme element = (DefaultAuthenticationScheme) iter.next();
                        if (!element.isSystemScheme() && element.getEnabled()) {
                            List attachedPolicies = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(element,
                                info.getUser().getRealm());
                            for (Iterator iterator = attachedPolicies.iterator(); iterator.hasNext();) {
                                Policy policy = (Policy) iterator.next();
                                if (!this.getResource().equals(policy)
View Full Code Here

                /**
                 * LDP - This is broken, I'm guessing that the VPN
                 * client session is different from the browser
                 * session so the scheme is not being found
                 */
                AuthenticationScheme scheme = (AuthenticationScheme) sessionInfo.getHttpSession()
                                .getAttribute(Constants.AUTH_SESSION);
                if (scheme != null) {
                    char[] pw = LogonControllerFactory.getInstance().getPasswordFromCredentials(scheme);
                    return pw == null ? "" : new String(pw);
                } else {
View Full Code Here

            boolean found = false;

            try {
                List authSchemes = ResourceUtil.getGrantedResource(info, PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE);
                for (Iterator iter = authSchemes.iterator(); iter.hasNext();) {
                    AuthenticationScheme element = (DefaultAuthenticationScheme) iter.next();
                    if (!element.isSystemScheme() && element.getEnabled()) {
                        List attachedPolicies = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(
                                        element, info.getUser().getRealm());
                        for (Iterator iterator = attachedPolicies.iterator(); iterator.hasNext();) {
                            Policy policy = (Policy) iterator.next();
                            // we don't check the current policy as it is about to be deleted.
View Full Code Here

TOP

Related Classes of com.adito.security.AuthenticationScheme

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.