Package org.rhq.enterprise.server.auth

Examples of org.rhq.enterprise.server.auth.SubjectManagerLocal


        if (forward != null) {
            return forward;
        }

        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
        Subject subject = WebUtility.getSubject(request);
        int subjectSession = subject.getSessionId();

        Subject userToBeModified = subjectManager.getSubjectById(pForm.getId());

        String userName = userToBeModified.getName();
        log.debug("Editing password for user [" + userName + "]");

        boolean admin = LookupUtil.getAuthorizationManager().hasGlobalPermission(subject, Permission.MANAGE_SECURITY);
        boolean isSameUser = subject.getName().equals(userName);

        // if this user cannot administer other user's passwords, make sure he gave the old password as confirmation
        if (!admin) {
            try {
                int dummySession = subjectManager.loginLocal(userName, pForm.getCurrentPassword()).getSessionId();
                subjectManager.logout(dummySession);

                // The above killed our session for subject if subject == userToBeModified
                if (isSameUser) {
                    subject = subjectManager.loginLocal(userName, pForm.getCurrentPassword());
                }
            } catch (LoginException e) {
                RequestUtils.setError(request, "admin.user.error.WrongPassword", "currentPassword");
                return returnFailure(request, mapping, ParamConstants.USER_PARAM, pForm.getId());
            }
        }

        String newPassword = pForm.getNewPassword();
        subjectManager.changePassword(subject, userName, newPassword);

        // when we have arrived here, the password is changed.
        // If this was a change of our own password, we need to re-login now
        if (isSameUser) {
            subjectManager.logout(subject.getSessionId());
        }

        return returnSuccess(request, mapping, ParamConstants.USER_PARAM,

        pForm.getId());
View Full Code Here


    private ResourceManagerLocal resourceManager;

    @Override
    protected void beforeMethod() throws Exception {
        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
        overlord = subjectManager.getOverlord();
        resourceManager = LookupUtil.getResourceManager();
    }
View Full Code Here

        String nameString = names.toString();
        return nameString.substring(1, nameString.length() - 1);
    }

    private List<String> getSubjectNames(List<Integer> subjectIds) {
        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
        List<String> results = new ArrayList<String>();
        for (Integer nextSubjectId : subjectIds) {
            Subject nextSubject = subjectManager.getSubjectById(nextSubjectId);
            if (nextSubject != null) { // handle unknown subject ids
                results.add(nextSubject.getName());
            }
        }
View Full Code Here

        return results;
    }

    private List<String> getSubjectEmails(List<Integer> subjectIds) {
        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
        List<String> results = new ArrayList<String>();
        for (Integer nextSubjectId : subjectIds) {
            Subject nextSubject = subjectManager.getSubjectById(nextSubjectId);
            if (nextSubject != null) { // handle unknown subject ids
                String nextEmail = nextSubject.getEmailAddress();
                if (nextEmail != null) {
                    results.add(nextEmail);
                }
View Full Code Here

        byte[] bytes = Base64.decode(authHeader);
        String userPass = new String(bytes);
        String username = userPass.substring(0,userPass.indexOf(":"));
        String password = userPass.substring(userPass.indexOf(":")+1);

        SubjectManagerLocal sm = LookupUtil.getSubjectManager();
        Subject subject = sm.checkAuthentication(username, password);

        if (subject==null) {

            ((HttpServletResponse) resp).sendError(HttpServletResponse.SC_UNAUTHORIZED);
        }
View Full Code Here

    public void testFindResourceComposite() throws Exception {
        getTransactionManager().begin();

        try {
            ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            PageControl pc = new PageControl(1, 5, new OrderingField("res.name", PageOrdering.ASC));
            Subject subject = subjectManager.loginUnauthenticated("ghinkle");

            //Subject subject = subjectManager.getOverlord();
            subject = createSession(subject);
            ResourceType t = em.getReference(ResourceType.class, new Integer(501064));
            String typeNameFilter = t == null ? null : t.getName();
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testMixedGroupCompositeQuery() throws Exception {
        getTransactionManager().begin();
        try {
            ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            PageControl pc = new PageControl(1, 5, new OrderingField("rg.name", PageOrdering.ASC));

            //Subject subject = subjectManager.loginUnauthenticated("ghinkle");
            Subject subject = subjectManager.getOverlord();
            subject = createSession(subject);
            List<ResourceGroupComposite> groups = groupManager.findResourceGroupComposites(subject,
                GroupCategory.MIXED, null, null, null, null, null, null, pc);
            System.out.println("Found mixed groups: " + groups.size());
            for (ResourceGroupComposite group : groups) {
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testCompatibleGroupCompositeQuery() throws Exception {
        getTransactionManager().begin();
        try {
            ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            PageControl pc = new PageControl(0, 5, new OrderingField("rg.name", PageOrdering.ASC));
            PageList<ResourceGroupComposite> groups = groupManager.findResourceGroupComposites(
                subjectManager.getOverlord(), GroupCategory.COMPATIBLE, null, null, null, null, null, null, pc);
            System.out.println("Found compatible groups: " + groups.getTotalSize());
            for (ResourceGroupComposite group : groups) {
                System.out.println("\t" + group);
            }
        } finally {
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void discoveryQueueTest() throws Exception {
        getTransactionManager().begin();
        try {
            DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            Subject rhqadmin = subjectManager.loginUnauthenticated("rhqadmin");
            rhqadmin = createSession(rhqadmin);

            Map<Resource, List<Resource>> queue = discoveryBoss.getQueuedPlatformsAndServers(rhqadmin,
                PageControl.getUnlimitedInstance());
            for (Resource root : queue.keySet()) {
View Full Code Here

    public void resourceTest() throws Exception {
        // TODO GH: Implement actual tests

        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();

        AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager();

        Subject rhqadmin = subjectManager.loginUnauthenticated("rhqadmin");
        System.out.println(rhqadmin);
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.auth.SubjectManagerLocal

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.