Package javax.security.auth.message.callback

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


                {
                    userIdentity = ids.iterator().next();
                }
                else
                {
                    CallerPrincipalCallback principalCallback = _callbackHandler.getThreadCallerPrincipalCallback();
                    if (principalCallback == null) { return Authentication.UNAUTHENTICATED; }
                    Principal principal = principalCallback.getPrincipal();
                    if (principal == null)
                    {
                        String principalName = principalCallback.getName();
                        Set<Principal> principals = principalCallback.getSubject().getPrincipals();
                        for (Principal p : principals)
                        {
                            if (p.getName().equals(principalName))
                            {
                                principal = p;
View Full Code Here


        {
            Set<LoginCallbackImpl> loginCallbacks = clientSubject.getPrivateCredentials(LoginCallbackImpl.class);
            if (!loginCallbacks.isEmpty())
            {
                LoginCallbackImpl loginCallback = loginCallbacks.iterator().next();
                CallerPrincipalCallback callerPrincipalCallback = new CallerPrincipalCallback(clientSubject, loginCallback.getUserPrincipal());
                GroupPrincipalCallback groupPrincipalCallback = new GroupPrincipalCallback(clientSubject, loginCallback.getRoles());
                callbackHandler.handle(new Callback[] { callerPrincipalCallback, groupPrincipalCallback });
            }
            messageInfo.getMap().put(JaspiMessageInfo.AUTH_METHOD_KEY, authMethod);
        }
View Full Code Here

        // the authentication process has been a success. We need to register the principal, username, password and roles
        // with the container
        if (result) {
            PasswordValidationCallback pvc = cbh.getPasswordValidationCallback();
            CallerPrincipalCallback cpc = cbh.getCallerPrincipalCallback();

            // get the client principal from the callback.
            Principal clientPrincipal = cpc.getPrincipal();
            if (clientPrincipal == null) {
                clientPrincipal = new SimplePrincipal(cpc.getName());
            }

            // if the client principal is not a jboss generic principal, we need to build one before registering.
            if (!(clientPrincipal instanceof JBossGenericPrincipal))
                clientPrincipal = this.buildJBossPrincipal(clientSubject, clientPrincipal);
View Full Code Here

                  Principal principal = new SimplePrincipal(user);
                  char[] cred = workManager.getCallbackSecurity().getCredential(user);
                  String[] roles = workManager.getCallbackSecurity().getRoles(user);

                  GroupPrincipalCallback gpc = new GroupPrincipalCallback(subject, roles);
                  CallerPrincipalCallback cpc = new CallerPrincipalCallback(subject, principal);
                  PasswordValidationCallback pvc = new PasswordValidationCallback(subject, principal.getName(), cred);

                  callbacks.add(gpc);
                  callbacks.add(cpc);
                  callbacks.add(pvc);
View Full Code Here

            } else {
                userPrincipal = p;
            }
        }

        CallerPrincipalCallback callerPrincipalCallback = new CallerPrincipalCallback(clientSubject, userPrincipal);

        if (callerPrincipalCallback.getName() == null && callerPrincipalCallback.getPrincipal() == null) {
            assignGroups = false;
        }
        try {
            handler.handle((assignGroups ? new Callback[]{
                        callerPrincipalCallback,
                        new GroupPrincipalCallback(callerPrincipalCallback.getSubject(),
                        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;
View Full Code Here

        return;
    }
                Iterator<Principal> it = ps.iterator();

    Callback[] callbacks = new Callback[]
        { new CallerPrincipalCallback(s, it.next().getName()) };
    if (pvcSubject != null) {
        s.getPrincipals().addAll(pvcSubject.getPrincipals());
    }

    try {
View Full Code Here

            } else {
                userPrincipal = p;
            }
        }

        CallerPrincipalCallback callerPrincipalCallback = new CallerPrincipalCallback(clientSubject, userPrincipal);

        if (callerPrincipalCallback.getName() == null && callerPrincipalCallback.getPrincipal() == null) {
            assignGroups = false;
        }
        try {
            handler.handle((assignGroups ? new Callback[]{
                        callerPrincipalCallback,
                        new GroupPrincipalCallback(callerPrincipalCallback.getSubject(),
                        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;
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

        // the authentication process has been a success. We need to register the principal, username, password and roles
        // with the container
        if (result) {
            PasswordValidationCallback pvc = cbh.getPasswordValidationCallback();
            CallerPrincipalCallback cpc = cbh.getCallerPrincipalCallback();
            GroupPrincipalCallback gpc = cbh.getGroupPrincipalCallback();

            // get the client principal from the callback.
            Principal clientPrincipal = cpc.getPrincipal();
            if (clientPrincipal == null) {
                clientPrincipal = new SimplePrincipal(cpc.getName());
            }

            // if the client principal is not a jboss generic principal, we need to build one before registering.
            if (!(clientPrincipal instanceof JBossGenericPrincipal))
                clientPrincipal = this.buildJBossPrincipal(clientSubject, clientPrincipal, gpc);
View Full Code Here

        if (callbacks.length > 0) {
            for (Callback callback : callbacks) {
                if (callback instanceof CallerPrincipalCallback) {
                    if (this.callerPrincipalCallback == null) {
                        CallerPrincipalCallback callerCallback = (CallerPrincipalCallback) callback;
                        if (callerCallback.getPrincipal()  != null)
                            this.callerPrincipalCallback = new CallerPrincipalCallback(callerCallback.getSubject(),
                                    callerCallback.getPrincipal());
                        else
                            this.callerPrincipalCallback = new CallerPrincipalCallback(callerCallback.getSubject(),
                                    callerCallback.getName());
                    }
                } else if (callback instanceof PasswordValidationCallback) {
                    if (this.passwordValidationCallback == null) {
                        PasswordValidationCallback passCallback = (PasswordValidationCallback) callback;
                        this.passwordValidationCallback = new PasswordValidationCallback(passCallback.getSubject(),
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.