Package com.adito.policyframework

Examples of com.adito.policyframework.Policy


          storeToCache(cacheKey, val);
          return val.booleanValue();
        }
      }
           
            Policy p = getGrantingPolicy(principal, resource);
            val = p == null ? Boolean.FALSE : Boolean.TRUE;

      storeToCache(cacheKey, val);
    }
    return val.booleanValue();
View Full Code Here


  /* (non-Javadoc)
   * @see com.adito.policyframework.PolicyDatabase#getPolicyByName(java.lang.String, int)
   */
  public Policy getPolicyByName(String name, int realmID) throws Exception {
    String cacheKey = "policyByName-" + name;
    Policy pol = (Policy) policyCache.retrieve(cacheKey);
    if (pol == null) {
      JDBCPreparedStatement ps = db
          .getStatement("getPolicyByName.selectByName");
      ps.setString(1, name);
      ps.setInt(2, realmID);
View Full Code Here

                                 && (requiredPermission.getId() == PolicyConstants.PERM_PERSONAL_CREATE_EDIT_AND_DELETE_ID)) {
                                    List policiesResource = getPoliciesAttachedToResource(resource, user.getRealm());
                                    if (policiesResource.size() != 1) {
                                        val = Boolean.FALSE;
                                    } else {
                                        Policy policy = (Policy) policiesResource.get(0);
                                        Policy policyUser = getGrantingPolicyForUser(user, resource);
                                        if (!policy.equals(policyUser)) {
                                            val = Boolean.FALSE;
                                        } else {
                                            if ((policy.getType() != Policy.TYPE_PERSONAL) || (!policy.getResourceName().equals(PolicyUtil.getPersonalPolicyName(user.getPrincipalName())))) {
                                                val = Boolean.FALSE;
View Full Code Here

                // LDP - Add the policies attached to a resource
                // as well
                List del = getPoliciesAttachedToResource(resourcePermission, user.getRealm());

                for (Iterator k = del.iterator(); k.hasNext();) {
                  Policy p = (Policy) k.next();
                  if (!l.contains(p)) {
                    l.add(p);
                  }
                }
                break;
View Full Code Here

   
    /* (non-Javadoc)
     * @see com.adito.policyframework.PolicyDatabase#getGrantingPolicyForUser(com.adito.security.User, com.adito.policyframework.Resource)
     */
    public Policy getGrantingPolicyForUser(User user, Resource resource) throws Exception {
        Policy policy = null;
        if((policy = getGrantingPolicy(user, resource))==null) {
            Role[] roles = user.getRoles();
            for(int i=0;i<roles.length;i++) {
               
                if((policy = getGrantingPolicy(roles[i], resource))!=null) {
View Full Code Here

     */
    private Policy getGrantingPolicy(Principal principal, Resource resource) throws Exception {
        String cacheKey = "grantingPolicy-" + principal.getPrincipalName() + "-realmID-" + principal.getRealm().getResourceId()
                + "-" + resource.getResourceId() + "-"
                + resource.getResourceType().getResourceTypeId();
        Policy val = (Policy) policyCache.retrieve(cacheKey);
        if (val == null) {
            List policies = getPoliciesAttachedToResource(resource, principal.getRealm());
            for (Iterator i = policies.iterator(); val == null && i.hasNext();) {
                Policy p = (Policy) i.next();
                if (isPolicyGrantedToPrincipal(p, principal)) {
                    val = p;
                }
                if (principal instanceof User) {
                    Role[] r = ((User) principal).getRoles();
View Full Code Here

     * @see com.adito.policyframework.PolicyDatabase#detachResourceFromPolicyList(com.adito.policyframework.Resource, com.adito.security.SessionInfo)
     */
    public void detachResourceFromPolicyList(Resource resource, SessionInfo session) throws Exception {
        List policies = getPolicies(session.getUser().getRealm());
        for (Iterator i = policies.iterator(); i.hasNext();) {
            Policy p = (Policy) i.next();
            if(isResourceAttachedToPolicy(resource, p, session.getUser().getRealm())) {
                if (log.isDebugEnabled())
                    log.debug("Detaching policy " + p.getResourceName() + " (" + p.getResourceId() + ") to resource "
                                + resource.getResourceName() + "(id=" + resource.getResourceId() + ", type="
                                + resource.getResourceType() + ")");
                try {
                    detachResourceFromPolicy(resource, p, session.getUser().getRealm());
                    CoreServlet.getServlet().fireCoreEvent(new ResourceDetachedFromPolicyEvent(this, resource, p, session, CoreEvent.STATE_SUCCESSFUL));
View Full Code Here

     * @see com.adito.policyframework.PolicyDatabase#attachResourceToPolicyList(com.adito.policyframework.Resource, com.adito.boot.PropertyList, com.adito.security.SessionInfo)
     */
    public void attachResourceToPolicyList(Resource resource, PropertyList selectedPolicies, SessionInfo session) throws Exception {
        List l = getPoliciesAttachedToResource(resource, session.getUser().getRealm());
        for (Iterator i = l.iterator(); i.hasNext();) {
            Policy p = (Policy) i.next();
            if(!selectedPolicies.contains(String.valueOf(p.getResourceId()))) {
                if (log.isDebugEnabled())
                    log.debug("Detaching policy " + p.getResourceName() + " (" + p.getResourceId() + ") to resource "
                                + resource.getResourceName() + "(id=" + resource.getResourceId() + ", type="
                                + resource.getResourceType() + ")");
                try {
                    detachResourceFromPolicy(resource, p, session.getUser().getRealm());
                    CoreServlet.getServlet().fireCoreEvent(new ResourceDetachedFromPolicyEvent(this, resource, p, session, CoreEvent.STATE_SUCCESSFUL));
                }
                catch(Exception e) {
                    CoreServlet.getServlet().fireCoreEvent(new ResourceDetachedFromPolicyEvent(this, resource, p, session, CoreEvent.STATE_UNSUCCESSFUL));
                    throw e;
                }               
            }
        }
        int idx = 0;
        for (Iterator i = selectedPolicies.iterator(); i.hasNext(); ) {
            String pn = (String)i.next();
            Policy p = getPolicy(Integer.parseInt(pn));
            if (!l.contains(p)) {
                if (log.isDebugEnabled())
                    log.debug("Attaching policy " + p.getResourceName() + " (" + p.getResourceId() + ") to resource "
                                + resource.getResourceName() + "(id=" + resource.getResourceId() + ", type="
                                + resource.getResourceType() + ")");
                try {
                    attachResourceToPolicy(resource, p, idx++, session.getUser().getRealm());
                    CoreServlet.getServlet().fireCoreEvent(new ResourceAttachedToPolicyEvent(this, resource, p, session, CoreEvent.STATE_SUCCESSFUL));
View Full Code Here

                    AuthenticationScheme element = (DefaultAuthenticationScheme) iter.next();
                    if (element.getEnabled() && !element.isSystemScheme() && element.getResourceId() != this.getResourceId()) {

                        for (Iterator iterator = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(element,
                            info.getUser().getRealm()).iterator(); iterator.hasNext();) {
                            Policy policy = (Policy) iterator.next();
                            if (PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy,
                                LogonControllerFactory.getInstance().getSessionInfo(request).getUser())) {
                                found = true;
                            }
                        }
View Full Code Here

        int id = (int)reader.readInt();
        NetworkPlace resource = (NetworkPlace)NetworkPlacePlugin.NETWORK_PLACE_RESOURCE_TYPE.getResourceById(id);
        if (resource == null) {
          throw new Exception("No resource with ID " + id);
        }
        Policy policy = LaunchSessionManager.getLaunchRequestPolicy(null, agent.getSession(), resource);
        if (resource.sessionPasswordRequired(agent.getSession())) {
          // TODO: prompt user for credentials through agent!
          return true;
        } else {
          LaunchSession launchSession = LaunchSessionFactory.getInstance().createLaunchSession(agent.getSession(),
View Full Code Here

TOP

Related Classes of com.adito.policyframework.Policy

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.