Package com.adito.properties

Examples of com.adito.properties.PropertyProfile


                                }
                            }

                            if (request.getSession().getAttribute(Constants.SESSION_LOCKED) == null || isIgnoreSessionLock()) {
                                if (requiresProfile()) {
                                    PropertyProfile profile = (PropertyProfile) request.getSession().getAttribute(
                                        Constants.SELECTED_PROFILE);
                                    if (profile == null) {
                                        request.getSession().setAttribute(Constants.ORIGINAL_REQUEST,
                                            Util.getOriginalRequest(request));
                                        return mapping.findForward("selectPropertyProfile");
View Full Code Here


                         * If not, then check the user can switch to the correct
                         * and switch it.
                         */
                        CoreUtil.checkNavigationContext(this, mapping, form, request, response);

                        PropertyProfile profile = null;
                        if (request.getSession().getAttribute(Constants.SESSION_LOCKED) == null) {
                            profile = (PropertyProfile) request.getSession().getAttribute(Constants.SELECTED_PROFILE);
                            if (profile == null) {
                                request.getSession().setAttribute(Constants.ORIGINAL_REQUEST, Util.getOriginalRequest(request));
                                return mapping.findForward("selectPropertyProfile");
View Full Code Here

     *
     * @param session session
     * @return property profile ID
     */
    public static int getCurrentPropertyProfileId(HttpSession session) {
        PropertyProfile p = (PropertyProfile) session.getAttribute(Constants.SELECTED_PROFILE);
        if (p != null) {
            return p.getResourceId();
        }
        return 0;
    }
View Full Code Here

  }

  public String getPath(AvailableTableItemAction availableItem) {
    ResourceItem item = (ResourceItem) availableItem
        .getRowItem();
    PropertyProfile p = (PropertyProfile)item.getResource();
    return p.getOwnerUsername() != null || ( p.getOwnerUsername() == null && availableItem.getSessionInfo().getNavigationContext() == SessionInfo.USER_CONSOLE_CONTEXT) ? "/showUserProperties.do?selectedPropertyProfile=" + item.getResource().getResourceId() :
      "/showGlobalProperties.do?selectedPropertyProfile=" + item.getResource().getResourceId();
  }
View Full Code Here

        getPolicyService().grantPolicyToPrincipal(policy, user);
       
        AccessRights accessRights = createAssignAccessRights(getResourceType().getPermissionClass());
        PropertyList selectedPolicies = PropertyList.createFromArray(new int[] {policy.getResourceId()});
        PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(accessRights, selectedPolicies, getSessionInfo());
        PropertyProfile resource = createResource();
        assertTrue("Should be, as one already exists.", getPolicyService().isPrincipalGrantedResourcesOfType(user, resource.getResourceType(), null));
        assertEquals("Should be only one.", getPolicyService().getGrantedResourcesOfType(user, getResourceType()).size(), 1);
       
        PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(resource, selectedPolicies, getSessionInfo());
        assertEquals("Should be two.", getPolicyService().getGrantedResourcesOfType(user, getResourceType()).size(), 2);
       
View Full Code Here

     */
    @Test
    public void createProfileWithoutUser() throws Exception {
        DefaultPropertyProfile newProfile = new DefaultPropertyProfile(getDefaultRealm().getRealmID(), -1, "test3", "profile", "A profile", Calendar.getInstance(), Calendar.getInstance());
        assertEquals("There should not be any PropertyProfile", 0, propertyDatabase.getPropertyProfiles("test1", true, 1).size());
        PropertyProfile createdProfile = createResource(newProfile);
        assertEquals("There should be two PropertyProfile", 1, propertyDatabase.getPropertyProfiles("test3", true, 1).size());
        deleteResource(createdProfile);
        assertEquals("There should not be any PropertyProfile", 0, propertyDatabase.getPropertyProfiles("test1", true, 1).size());
    }
View Full Code Here

    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        // Get the property profile selected
        User user = getSessionInfo(request).getUser();
        ProfileSelectionForm profileSelectionForm = (ProfileSelectionForm) form;
        PropertyProfile profile = ProfilesFactory.getInstance().getPropertyProfile(
                        profileSelectionForm.getSelectedPropertyProfile());
        if (profile == null) {
            profile = ProfilesFactory.getInstance().getPropertyProfile(user.getPrincipalName(), "Default",
                            user.getRealm().getResourceId());
            if (profile == null) {
                throw new Exception("No default profile.");
            }
        }

        // Make the selected profile the one in use for this session
        if (log.isInfoEnabled())
          log.info("Switching user " + user.getPrincipalName() + " to profile " + profile.getResourceName());
        request.getSession().setAttribute(Constants.SELECTED_PROFILE, profile);
        String originalRequest = (String) request.getSession().getAttribute(Constants.ORIGINAL_REQUEST);

        // Optionally set the users default property profile
        if (profileSelectionForm.getMakeDefault()) {
            Property.setProperty(new UserAttributeKey(user, User.USER_STARTUP_PROFILE), String.valueOf(profile.getResourceId()), getSessionInfo(request));
        }

        // Reset the navigation and timeouts, they may be different in this new
        // profile
        CoreUtil.resetMainNavigation(request.getSession());
        LogonControllerFactory.getInstance().resetSessionTimeout(user, profile, request.getSession());

        // The new profile may have 'Automatically launch VPN client' enabled so
        // launch the VPN client
        if (!DefaultAgentManager.getInstance().hasActiveAgent(LogonControllerFactory.getInstance().getSessionInfo(request))
                        && Property.getPropertyBoolean(new ProfilePropertyKey(profile.getResourceId(), user.getPrincipalName(),
                                        "client.autoStart", user.getRealm().getResourceId()))) {
            request.getSession().removeAttribute(Constants.ORIGINAL_REQUEST);
            request.getSession().setAttribute(Constants.REQ_ATTR_LAUNCH_AGENT_REFERER, originalRequest);
            return mapping.findForward("launchAgent");
        }
View Full Code Here

  public void initialiseSession(HttpSession session, User user) throws UserDatabaseException {
    if (log.isInfoEnabled())
      log.info("Initialising session " + session.getId()
        + " with user "
        + (user == null ? "[none]" : user.getPrincipalName()));
    PropertyProfile profile = (PropertyProfile) session.getAttribute(Constants.SELECTED_PROFILE);
    session.setAttribute(Constants.USER, user);
    String logonInfo = MessageResources.getMessageResources("com.adito.navigation.ApplicationResources")
            .getMessage("footer.info",
              user.getPrincipalName(),
              SimpleDateFormat.getDateTimeInstance().format(new Date()));
    session.setAttribute(Constants.LOGON_INFO, logonInfo);
    try {
      List profiles = ResourceUtil.filterResources(user, ProfilesFactory.getInstance()
              .getPropertyProfiles(user.getPrincipalName(), true, user.getRealm().getResourceId()), true);
      session.setAttribute(Constants.PROFILES, profiles);
      if (profiles.size() == 0) {
        throw new UserDatabaseException("You do not have permission to use any profiles.");
      }
      String startupProfile = Property.getProperty(new UserAttributeKey(user, User.USER_STARTUP_PROFILE));
      if (profiles.size() < 2) {
        profile = (PropertyProfile) profiles.get(0);
      } else if (!startupProfile.equals(ProfilesListDataSource.SELECT_ON_LOGIN)) {
        int profileId = Integer.parseInt(startupProfile);
        profile = null;
        for (Iterator i = profiles.iterator(); i.hasNext();) {
          PropertyProfile p = (PropertyProfile) i.next();
          if (profileId == p.getResourceId()) {
            profile = p;
            break;
          }
        }
        if (profile == null) {
View Full Code Here

            ps.execute();
        } finally {
            ps.releasePreparedStatement();
        }
        int id = db.getLastInsertId(ps, "insert.profile.lastInsertId");
        PropertyProfile profile = new DefaultPropertyProfile(realmID, id, username == null ? "" : username, shortName, description,
                        c, c);
        profile.setResourceName(shortName);
        profile.setResourceDescription(description);

        if (baseOn != -1) {
            for (PropertyDefinition def : PropertyClassManager.getInstance()
                            .getPropertyClass(ProfileProperties.NAME)
                            .getDefinitions()) {
View Full Code Here

     * (non-Javadoc)
     *
     * @see com.adito.boot.PropertyDatabase#deletePropertyProfile(int)
     */
    public PropertyProfile deletePropertyProfile(int id) throws Exception {
        PropertyProfile prof = getPropertyProfile(id);
        if (prof == null) {
            throw new Exception("No property profile with " + id + ".");
        }
        propertyCache.clear();
        JDBCPreparedStatement ps = db.getStatement("delete.profile.1");
View Full Code Here

TOP

Related Classes of com.adito.properties.PropertyProfile

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.