Package javax.security.auth.message.callback

Examples of javax.security.auth.message.callback.CallerPrincipalCallback


        if (this.callbackHandler instanceof WebJASPICallbackHandler) {
            WebJASPICallbackHandler cbh = (WebJASPICallbackHandler) callbackHandler;

            PasswordValidationCallback passwordValidationCallback =
                    new PasswordValidationCallback(null, username, password.toCharArray());
            CallerPrincipalCallback callerCallback = new CallerPrincipalCallback(null, userPrincipal);
            try {
                cbh.handle(new Callback[] {passwordValidationCallback, callerCallback});
            } catch (Exception e) {
                throw new RuntimeException("Error handling callbacks: " + e.getLocalizedMessage(), e);
            }
View Full Code Here


        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);
View Full Code Here

        if (userPrincipal != null && request.getParameter("continueSession") != null) {
           
            // ### If already authenticated before, continue this session
           
            // Execute protocol to signal container registered authentication session be used.
            callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, userPrincipal) };
           
        } else if (request.getParameter("doLogin") != null) {
           
            // ### If not authenticated before, do a new login if so requested

            // For the test perform a login by directly "returning" the details of the authenticated user.
            // Normally credentials would be checked and the details fetched from some repository

            callbacks = new Callback[] {
                    // The name of the authenticated user
                    new CallerPrincipalCallback(clientSubject, "test"),
                    // the roles of the authenticated user
                    new GroupPrincipalCallback(clientSubject, new String[] { "architect" }) };

            // Tell container to register an authentication session.
            messageInfo.getMap().put("javax.servlet.http.registerSession", TRUE.toString());
        } else {
           
            // ### If no registered session and no login request "do nothing"
           
            // The JASPIC protocol for "do nothing"
            callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, (Principal) null) };
        }

        try {

            // Communicate the details of the authenticated user to the container. In many
View Full Code Here

        Callback[] callbacks;

        if (request.getParameter("doLogin") != null) {

            callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, "test"),
                    new GroupPrincipalCallback(clientSubject, new String[] { "architect" }) };
        } else {

            // The JASPIC protocol for "do nothing"
            callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, (Principal) null) };
        }

        try {
            handler.handle(callbacks);
        } catch (IOException | UnsupportedCallbackException e) {
View Full Code Here

        try {
            response.getWriter().write("validateRequest invoked\n");

            handler.handle(new Callback[] {
                new CallerPrincipalCallback(clientSubject, "test"),
                new GroupPrincipalCallback(clientSubject, new String[] { "architect" }) });
        } catch (IOException | UnsupportedCallbackException e) {
            throw (AuthException) new AuthException().initCause(e);
        }
View Full Code Here

            // For the test perform a login by directly "returning" the details of the authenticated user.
            // Normally credentials would be checked and the details fetched from some repository

            callbacks = new Callback[] {
                // The name of the authenticated user
                new CallerPrincipalCallback(clientSubject, "test"),
                // the roles of the authenticated user
                new GroupPrincipalCallback(clientSubject, new String[] { "architect" })
            };
        } else {

            // The JASPIC protocol for "do nothing"
            callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, (Principal) null) };
        }

        try {

            // Communicate the details of the authenticated user to the container. In many
View Full Code Here

            // For the test perform a login by directly "returning" the details of the authenticated user.
            // Normally credentials would be checked and the details fetched from some repository

            callbacks = new Callback[] {
                // The name of the authenticated user
                new CallerPrincipalCallback(clientSubject, "test"),
                // the roles of the authenticated user
                new GroupPrincipalCallback(clientSubject, new String[] { "architect" })
            };
        } else {

            // The JASPIC protocol for "do nothing"
            callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, (Principal) null) };
        }

        try {

            // Communicate the details of the authenticated user to the container. In many
View Full Code Here

    public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject)
            throws AuthException {

        try {
            handler.handle(new Callback[] {
                new CallerPrincipalCallback(clientSubject, "test"),
                new GroupPrincipalCallback(clientSubject, new String[] { "architect" }) });
        } catch (IOException | UnsupportedCallbackException e) {
            throw (AuthException) new AuthException().initCause(e);
        }
View Full Code Here

            // For the test perform a login by directly "returning" the details of the authenticated user.
            // Normally credentials would be checked and the details fetched from some repository

            callbacks = new Callback[] {
                // The name of the authenticated user
                new CallerPrincipalCallback(clientSubject, "test"),
                // the roles of the authenticated user
                new GroupPrincipalCallback(clientSubject, new String[] { "architect" })
            };
        } else {

            // The JASPIC protocol for "do nothing"
            callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, (Principal) null) };
        }

        try {

            // Communicate the details of the authenticated user to the container. In many
View Full Code Here

            }
        }
    }

    public CallerPrincipalCallback getThreadCallerPrincipalCallback() {
        CallerPrincipalCallback callerPrincipalCallback = callerPrincipals.get();
        callerPrincipals.remove();
        return callerPrincipalCallback;
    }
View Full Code Here

TOP

Related Classes of javax.security.auth.message.callback.CallerPrincipalCallback

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.