Package javax.security.auth.message

Examples of javax.security.auth.message.AuthException


      if (oldModule != null) {
                oldModule.validateResponse(config.getAuthParam(messageInfo),
            clientSubject, messageInfo.getMap());
                return AuthStatus.SUCCESS;
            } else {
                throw new AuthException();
            }
        }
View Full Code Here


            if (module != null) {
                module.cleanSubject(messageInfo, subject);
            } else if (oldModule != null) {
                oldModule.disposeSubject(subject, messageInfo.getMap());
            } else {
    throw new AuthException();
            }
        }
View Full Code Here

            return new ModuleInfo(newModule, map);
        } catch(Exception e) {
            if (e instanceof AuthException) {
                throw (AuthException)e;
            }
            AuthException ae = new AuthException();
            ae.initCause(e);
            throw ae;
        }
    }
View Full Code Here

                if (rvalue) { // cache it only if validateRequest = true
                    messageInfo.getMap().put(SERVER_AUTH_CONTEXT, sAC);
                    req.setAttribute(MESSAGE_INFO, messageInfo);
                }
            } else {
                throw new AuthException("null ServerAuthContext");
            }
        } catch (AuthException ae) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE,
                        "JMAC: http msg authentication fail", ae);
View Full Code Here

            getLc();
            ejbClient = new JNDIClient(config.getProviderUrl());
            loginEJB = (JaasEjb) ejbClient.lookup(config.getJndi());
        } catch (LoginException ex) {
            LOGGER.log(Level.SEVERE, "Exception d''init SAM{0}", ex.toString());
            AuthException ae = new AuthException();
            ae.initCause(ex);
            throw ae;
        }
    }
View Full Code Here

            try {
                response.setHeader("Location", response.encodeRedirectURL(request.getContextPath() + this.loginURI));
                response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
                //    rd.forward(request, response);
            } catch (Exception ex) {
                AuthException ae = new AuthException();
                ae.initCause(ex);
                throw ae;
            }
            return AuthStatus.SEND_CONTINUE;
        }


        // Check to see if successfull
        try {
            cbh.setRequest(request);
            lc.login();
            LOGGER.fine("Traitement du formulaire d'authentification");
            clientSubject = lc.getSubject();
            Principal userPrincipal = setCallerPrincipal(clientSubject);

            // recreate the session
            Map<String, Object> map = new HashMap<String, Object>();
            Enumeration<String> names = session.getAttributeNames();
            while (names.hasMoreElements()) {
                String key = names.nextElement();
                map.put(key, session.getAttribute(key));
            }
            session.invalidate();
            session = request.getSession(true);
            for (String key : map.keySet()) {
                session.setAttribute(key, map.get(key));
            }

            // Save the Subject...
            session.setAttribute(SAVED_SUBJECT, clientSubject);

            // Save the userName
            session.setAttribute(USER_NAME, username);

            try {
                // Redirect...
                if (getSavedRequestURL(session) != null) {
                    response.sendRedirect(response.encodeRedirectURL(getSavedRequestURL(session)));
                } else if (backward != null) {
                    response.sendRedirect(response.encodeRedirectURL(backward));
                } else {
                    response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/"));
                }
            } catch (Exception ex) {
                AuthException ae = new AuthException();
                ae.initCause(ex);
                throw ae;
            }

            /*
             * if ((new Date().getTime() - ((EvasionPrincipal)
             * userPrincipal).getLastLogin().getTime()) > 86400) {
             * UserTransaction tx = ejbClient.getTransaction(); if (tx != null)
             * { LOGGER.log(Level.FINE, "UserTransaction status
             * {0}",tx.getStatus()); tx.begin(); try {
             * loginEJB.postLogin(userPrincipal.getName()); } finally {
             * tx.commit(); tx = null; } } }
             */
            saveLoginBackToURL(request, session);

            // Continue...
            return AuthStatus.SEND_CONTINUE;

        } catch (LoginException le) {
            LOGGER.log(Level.SEVERE, "ERROR SAM!!!", le);
            RequestDispatcher rd = request.getRequestDispatcher(this.loginURI);
            try {
                rd.forward(request, response);
            } catch (Exception ex) {
                AuthException ae = new AuthException();
                ae.initCause(ex);
                throw ae;
            }
            return AuthStatus.SEND_FAILURE;
        } catch (Exception ex) {
            LOGGER.log(Level.SEVERE, "ERROR SAM!!!", ex);
View Full Code Here

                        assignedGroups)} : new Callback[]{callerPrincipalCallback}));

            LOGGER.log(Level.FINE, "jmac.caller_principal:{0} {1}", new Object[]{callerPrincipalCallback.getName(), callerPrincipalCallback.getPrincipal()});
        } catch (Exception ex) {
            LOGGER.log(Level.SEVERE, "ERROR SAM!!!", ex);
            AuthException ae = new AuthException();
            ae.initCause(ex);
            throw ae;
        }


        return userPrincipal;
View Full Code Here

        subject.getPublicCredentials().clear();

        try {
            lc.logout();
        } catch (LoginException ex) {
            AuthException ae = new AuthException();
            ae.initCause(ex);
            throw ae;
        }
    }
View Full Code Here

    public void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy, CallbackHandler handler, Map options) throws AuthException {
        this.handler = handler;
        if (options != null) {
            this.loginPage = (String) options.get("loginPage");
            if (loginPage == null) {
                throw new AuthException("'loginPage' "
                        + "must be supplied as a property in the provider-config "
                        + "in the domain.xml file!");
            }
            this.loginErrorPage = (String) options.get("loginErrorPage");
            if (loginErrorPage == null) {
                throw new AuthException("'loginErrorPage' "
                        + "must be supplied as a property in the provider-config "
                        + "in the domain.xml file!");
            }
            ServiceLocator habitat = SecurityServicesUtil.getInstance().getHabitat();
            Domain domain = habitat.getService(Domain.class);
View Full Code Here

            session.setAttribute(ORIG_REQUEST_PATH, origPath);
            RequestDispatcher rd = request.getRequestDispatcher(loginPage);
            try {
                rd.forward(request, response);
            } catch (Exception ex) {
                AuthException ae = new AuthException();
                ae.initCause(ex);
                throw ae;
            }
            return AuthStatus.SEND_CONTINUE;
        }

// Don't use the PasswordValidationCallback... use REST authorization instead.
//  char[] pwd = new char[password.length()];
//  password.getChars(0, password.length(), pwd, 0);
//  PasswordValidationCallback pwdCallback =
//      new PasswordValidationCallback(clientSubject, username, pwd);

        // Make REST Request

        Client client2 = RestUtil.initialize(ClientBuilder.newBuilder()).build();
        WebTarget target = client2.target(restURL);
        target.register(new HttpBasicAuthFilter(username, password));
        MultivaluedMap payLoad = new MultivaluedHashMap();
        payLoad.putSingle("remoteHostName", request.getRemoteHost());

        Response resp = target.request(RESPONSE_TYPE).post(Entity.entity(payLoad, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse restResp = RestResponse.getRestResponse(resp);

        // Check to see if successful..
        if (restResp.isSuccess()) {
            // Username and Password sent in... validate them!
            CallerPrincipalCallback cpCallback =
                    new CallerPrincipalCallback(clientSubject, username);
            try {
                handler.handle(new Callback[]{ /*pwdCallback,*/cpCallback});
            } catch (Exception ex) {
                AuthException ae = new AuthException();
                ae.initCause(ex);
                throw ae;
            }

            request.changeSessionId();

                // Get the "extraProperties" section of the response...
            Object obj = restResp.getResponse().get("data");
            Map extraProperties = null;
            if ((obj != null) && (obj instanceof Map)) {
                obj = ((Map) obj).get("extraProperties");
                if ((obj != null) && (obj instanceof Map)) {
                    extraProperties = (Map) obj;
                }
            }

            // Save the Rest Token...
            if (extraProperties != null) {
                session.putValue(REST_TOKEN, extraProperties.get("token"));
            }

            // Save the Subject...
            session.putValue(SAVED_SUBJECT, clientSubject);

            // Save the userName
            session.putValue(USER_NAME, username);

            try {
                // Redirect...
                String origRequest = (String)session.getAttribute(ORIG_REQUEST_PATH);
                // Explicitly test for favicon.ico, as Firefox seems to ask for this on
                // every page
                if ((origRequest == null) || "/favicon.ico".equals(origRequest)) {
                    origRequest = "/index.jsf";
                }
                logger.log(Level.INFO, "Redirecting to {0}", origRequest);
                response.sendRedirect(response.encodeRedirectURL(origRequest));
            } catch (Exception ex) {
                AuthException ae = new AuthException();
                ae.initCause(ex);
                throw ae;
            }

            // Continue...
            return AuthStatus.SEND_CONTINUE;
        } else {
            int status = restResp.getResponseCode();
            if (status == 403) {
                request.setAttribute("errorText", GuiUtil.getMessage("alert.ConfigurationError"));
                request.setAttribute("messageText", GuiUtil.getMessage("alert.EnableSecureAdmin"));
            }
            RequestDispatcher rd = request.getRequestDispatcher(this.loginErrorPage);
            try {
                rd.forward(request, response);
            } catch (Exception ex) {
                AuthException ae = new AuthException();
                ae.initCause(ex);
                throw ae;
            }
            return AuthStatus.SEND_FAILURE;
        }
    }
View Full Code Here

TOP

Related Classes of javax.security.auth.message.AuthException

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.