Package javax.security.auth

Examples of javax.security.auth.Subject


    public void associate(Object securityIdentity) throws LoginException {
        if (securityIdentity == null) {
            return;
        }

        Subject subject = ContextManager.getRegisteredSubject((SubjectId) securityIdentity);
        if (subject == null) {
            return;
        }
        ContextManager.setCallers(subject, subject);
    }
View Full Code Here


        EjbDeployment ejbDeployment = deploymentInfo.get(EjbDeployment.class);
        if (ejbDeployment == null || !ejbDeployment.isSecurityEnabled()) {
            return null;
        }

        Subject callerSubject = ContextManager.getCurrentCaller();
        return ContextManager.getCurrentPrincipal(callerSubject);
    }
View Full Code Here

                //set up the login context
                LoginContext loginContext = ContextManager.login(securityRealmName, callbackHandler);
                callbackHandler.clear();

                Subject subject = loginContext.getSubject();
                ContextManager.setCallers(subject, subject);

                //login success
                userPrincipal = new JAASJettyPrincipal(username);
                userPrincipal.setSubject(subject);
View Full Code Here

    }

    public boolean reauthenticate(Principal user) {
        // TODO This is not correct if auth can expire! We need to

        Subject subject = ((JAASJettyPrincipal) user).getSubject();
        ContextManager.setCallers(subject, subject);

        // get the user out of the cache
        return (userMap.get(user.getName()) != null);
    }
View Full Code Here

        EMPTY.setReadOnly();
        registerSubject(EMPTY);
    }

    public static LoginContext login(String realm, CallbackHandler callbackHandler) throws LoginException {
        Subject subject = new Subject();
        LoginContext loginContext = new LoginContext(realm, subject, callbackHandler);
        loginContext.login();
        SubjectId id = ContextManager.registerSubject(subject);
        IdentificationPrincipal principal = new IdentificationPrincipal(id);
        subject.getPrincipals().add(principal);
        return loginContext;
    }
View Full Code Here

        subject.getPrincipals().add(principal);
        return loginContext;
    }

    public static void logout(LoginContext loginContext) throws LoginException {
        Subject subject = loginContext.getSubject();
        ContextManager.unregisterSubject(subject);
        loginContext.logout();
    }
View Full Code Here

    public static Callers pushNextCaller(Subject nextCaller) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) sm.checkPermission(SET_CONTEXT);
        Callers oldCallers = callers.get();
        Subject oldNextCaller = oldCallers == null? null: oldCallers.getNextCaller();
        Subject newNextCaller = (nextCaller == null || nextCaller == EMPTY)? oldNextCaller : nextCaller;
        Callers newCallers = new Callers(oldNextCaller, newNextCaller);
        callers.set(newCallers);
        return oldCallers;
    }
View Full Code Here

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) sm.checkPermission(GET_CONTEXT);

        Callers threadLocalCallers = callers.get();
        assert threadLocalCallers != null : "No current callers";
        Subject currentSubject = threadLocalCallers.getCurrentCaller();
        assert currentSubject != null : "No current caller";
        Context context = subjectContexts.get(currentSubject);

        assert context != null : "No registered context";
View Full Code Here

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) sm.checkPermission(GET_CONTEXT);

        Callers threadLocalCallers = callers.get();
        assert threadLocalCallers != null : "No current callers";
        Subject currentSubject = threadLocalCallers.getCurrentCaller();
        assert currentSubject != null : "No current caller";
        Context context = subjectContexts.get(currentSubject);

        assert context != null : "No registered context";
View Full Code Here

        try {
            Callers currentCallers = callers.get();
            if (currentCallers == null) {
                return false;
            }
            Subject currentSubject = currentCallers.getCurrentCaller();
            if (currentSubject == null) {
                return false;
            }

            Context context = subjectContexts.get(currentSubject);
View Full Code Here

TOP

Related Classes of javax.security.auth.Subject

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.