Package org.rhq.core.domain.auth

Examples of org.rhq.core.domain.auth.Subject


        getTransactionManager().begin();

        ContentServiceRequest request = null;
        try {
            resource1 = em.find(Resource.class, resource1.getId());
            Subject overlord = subjectManager.getOverlord();
            PackageVersion packageVersion = em.find(PackageVersion.class, package3.getVersions().get(0).getId());

            request = new ContentServiceRequest(resource1, overlord.getName(), ContentRequestType.DEPLOY);

            InstalledPackageHistory originalRequestedPackage = new InstalledPackageHistory();
            originalRequestedPackage.setContentServiceRequest(request);
            originalRequestedPackage.setPackageVersion(packageVersion);
            originalRequestedPackage.setStatus(InstalledPackageHistoryStatus.BEING_INSTALLED);
View Full Code Here


    }

    @Test(enabled = ENABLE_TESTS)
    public void testSuccessfullyDeletePackages() throws Exception {
        // Setup  --------------------------------------------
        Subject overlord = subjectManager.getOverlord();

        // Delete installed package for package4
        int[] deleteUs = new int[] { installedPackage1.getId() };

        // Leave package5 installed
View Full Code Here

    }

    @Test(enabled = ENABLE_TESTS)
    public void testDeletePackagesNoIndividualResponses() throws Exception {
        // Setup  --------------------------------------------
        Subject overlord = subjectManager.getOverlord();

        // Delete installed package for package4
        int[] deleteUs = new int[] { installedPackage1.getId() };

        // Leave package5 installed
View Full Code Here

        availabilityManager.mergeAvailabilityReport(report);

        executeInTransaction(new TransactionCallback() {
            public void execute() throws Exception {
                // Create the test group
                final Subject subject = SessionTestHelper.createNewSubject(em, "testSubject");
                final Role roleWithSubject = SessionTestHelper
                    .createNewRoleForSubject(em, subject, "role with subject");
                roleWithSubject.addPermission(Permission.VIEW_RESOURCE);
                ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(em, roleWithSubject,
                    "accessible group");
View Full Code Here

            commitAndClose();

            long allAvailCount = setUpAvailabilities();

            // we now have 1:00 UP, 1:20 DOWN, 1:40 UP
            Subject overlord = LookupUtil.getSubjectManager().getOverlord();
            avail = availabilityManager.getCurrentAvailabilityForResource(overlord, theResource.getId());
            assert avail.getAvailabilityType() == UP;
            assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId()) == UP;

            // add something after the start of last, but still be UP (result: nothing added)
View Full Code Here

            commitAndClose();

            long allAvailCount = setUpAvailabilities();

            // we now have 1:00 UP, 1:20 DOWN, 1:40 UP
            Subject overlord = LookupUtil.getSubjectManager().getOverlord();
            avail = availabilityManager.getCurrentAvailabilityForResource(overlord, theResource.getId());
            assert avail.getAvailabilityType() == UP;
            assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId()) == UP;

            // add something after the start of last, but still be UP (result: nothing added)
View Full Code Here

                            // be doable by looking for state transitions from UNKNOWN to other states.
                            // }
                        }

                        // set the session subject, so the fetch to load the configuration works
                        final Subject subject = new Subject();
                        subject.setId(subjectId);
                        subject.setSessionId(Integer.valueOf(sessionId));
                        // populate the username for the subject for isUserWithPrincipal check in ldap processing
                        subject.setName(user);
                        sessionSubject = subject;

                        if (subject.getId() == 0) {//either i)ldap new user registration ii)ldap case sensitive match
                            if ((subject.getName() == null) || (subject.getName().trim().isEmpty())) {
                                //we've lost crucial information, probably in a browser refresh. Send them back through login
                                Log.trace("Unable to locate information critical to ldap registration/account lookup. Log back in.");
                                sessionState = State.IS_LOGGED_OUT;
                                new LoginView().showLoginDialog(true);
                                return;
                            }

                            Log.error("Proceeding with case insensitive login of ldap user '" + user + "'.");
                            GWTServiceLookup.getSubjectService().processSubjectForLdap(subject, password,
                                new AsyncCallback<Subject>() {
                                    public void onFailure(Throwable caught) {
                                        // this means either: a) we mapped the username to a previously registered LDAP
                                        // user but login via LDAP failed, or b) we were not able to map the username
                                        // to any LDAP users, previously registered or not.
                                        Log.debug("Failed to complete ldap processing for subject: "
                                            + caught.getMessage());
                                        new LoginView().showLoginDialog(MSG.view_login_noUser());
                                        return;
                                    }

                                    public void onSuccess(final Subject processedSubject) {
                                        //Then found case insensitive and returned that logged in user
                                        //Figure out of this is new user registration
                                        boolean isNewUser = false;
                                        if (processedSubject.getUserConfiguration() != null) {
                                            isNewUser = Boolean.valueOf(processedSubject.getUserConfiguration()
                                                .getSimpleValue("isNewUser", "false"));
                                        }
                                        if (!isNewUser) {
                                            // otherwise, we successfully logged in as an existing LDAP user case insensitively.
                                            Log.trace("Logged in case insensitively as ldap user '"
                                                + processedSubject.getName() + "'");
                                            callback.onSuccess(processedSubject);
                                        } else {// if account is still active assume new LDAP user registration.
                                            Log.trace("Proceeding with registration for ldap user '" + user + "'.");
                                            sessionState = State.IS_REGISTERING;
                                            sessionSubject = processedSubject;

                                            new LoginView().showRegistrationDialog(subject.getName(),
                                                String.valueOf(processedSubject.getSessionId()), password, callback);
                                        }

                                        return;
                                    }

                                });//end processSubjectForLdap call
                        } else {//else send through regular session check
                            SubjectCriteria criteria = new SubjectCriteria();
                            criteria.fetchConfiguration(true);
                            criteria.addFilterId(subjectId);

                            GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria,
                                new AsyncCallback<PageList<Subject>>() {
                                    public void onFailure(Throwable caught) {
                                        CoreGUI.getErrorHandler().handleError(MSG.util_userSession_loadFailSubject(),
                                            caught);
                                        Log.info("Failed to load user's subject");
                                        //TODO: pass message to login ui.
                                        new LoginView().showLoginDialog(true);
                                        return;
                                    }

                                    public void onSuccess(PageList<Subject> results) {
                                        final Subject validSessionSubject = results.get(0);
                                        //update the returned subject with current session id
                                        validSessionSubject.setSessionId(Integer.valueOf(sessionId));

                                        Log.trace("Completed session check for subject '" + validSessionSubject + "'.");

                                        //initiate ldap check for ldap authz update(wrt roles) of subject with silent update
                                        //as the subject.id > 0 then only group authorization updates will occur if ldap configured.
                                        GWTServiceLookup.getSubjectService().processSubjectForLdap(validSessionSubject,
                                            "", new AsyncCallback<Subject>() {
                                                public void onFailure(Throwable caught) {
                                                    Log.warn("Errors occurred processing subject for LDAP."
                                                        + caught.getMessage());
                                                    //TODO: pass informative message to Login UI.
                                                    callback.onSuccess(validSessionSubject);
                                                    return;
                                                }

                                                public void onSuccess(Subject result) {
                                                    Log.trace("Successfully processed subject '"
                                                        + validSessionSubject.getName() + "' for LDAP.");
                                                    callback.onSuccess(validSessionSubject);
                                                    return;
                                                }
                                            });
                                    }
View Full Code Here

        try {
            // The logout() method should be called against the dying session. This makes sense and
            // also protects against the fact that sessionSubject may be null at the time of this call.
            // The sessionSubject is used to build the server request, so it must be valid.
            Subject tempSubject = sessionSubject;
            sessionSubject = new Subject();
            sessionSubject.setSessionId(doomedSessionId);

            GWTServiceLookup.getSubjectService().logout(doomedSessionId, new AsyncCallback<Void>() {
                public void onFailure(Throwable caught) {
                    CoreGUI.getErrorHandler().handleError(MSG.util_userSession_logoutFail(), caught);
View Full Code Here

    }


    public void testSimple() throws Exception {

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        Query q = em.createQuery("SELECT r FROM Resource r");
        List<Resource> resources = q.getResultList();
        Resource res = resources.get(0);
        if (!(res.getResourceType().getCategory()== ResourceCategory.PLATFORM))
View Full Code Here

    @Test(enabled = ENABLE_TESTS)
    public void testLatestConfiguration() throws Exception {
        int resourceId = newResource1.getId();

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        // create a config, then another that spends some time in INPROGRESS before succeeding
        Configuration configuration1 = new Configuration();
        configuration1.put(new PropertySimple("myboolean", "true"));
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.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.