コード例 #1
0
  public String toString() {
    String print = "RuleTarget:\n";
    print = print.concat("\tRequestors\n");
    for (Requestor s : subjects) {
      print = print.concat("\t\t" + s.toString() + "\n");
    }

    print = print.concat("Resource:\n");
    print = print.concat(this.resource.toString());
    print = print.concat("Actions:\n");
    for (Action a : actions) {
      print = print.concat("\t\t" + a.toString() + "\n");
    }
    return print;
  }
コード例 #2
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((affectedCtxId == null) ? 0 : affectedCtxId.hashCode());
   result = prime * result + ((myContextType == null) ? 0 : myContextType.hashCode());
   result = prime * result + ((myPrivacyType == null) ? 0 : myPrivacyType.hashCode());
   result = prime * result + ((pref == null) ? 0 : pref.hashCode());
   result = prime * result + ((requestor == null) ? 0 : requestor.hashCode());
   return result;
 }
コード例 #3
0
  /*
   * (non-Javadoc)
   * @see org.societies.api.internal.privacytrust.privacyprotection.IPrivacyAgreementManager#getAgreement(org.societies.api.identity.Requestor)
   */
  @Override
  public AgreementEnvelope getAgreement(Requestor requestor) throws PrivacyException {
    // -- Verify
    if (null == requestor || null == requestor.getRequestorId()) {
      throw new PrivacyException(
          "Not enought information to search a privacy policy agreement. Requestor needed.");
    }
    // Dependency injection not ready
    if (!isDepencyInjectionDone()) {
      throw new PrivacyException("[Dependency Injection] PrivacyPolicyAgreementManager not ready");
    }

    try {
      List<CtxIdentifier> agreementIdList =
          ctxBroker
              .lookup(
                  CtxModelType.ATTRIBUTE, PrivacyAgreementManagerInternal.getRequestorId(requestor))
              .get();
      if (null == agreementIdList || agreementIdList.size() <= 0) {
        return null;
      }
      CtxIdentifier agreementId = agreementIdList.get(0);
      CtxAttribute agreementData = (CtxAttribute) ctxBroker.retrieve(agreementId).get();
      org.societies.api.internal.schema.privacytrust.privacyprotection.model.privacypolicy
              .AgreementEnvelope
          agreementTmp =
              (org.societies.api.internal.schema.privacytrust.privacyprotection.model.privacypolicy
                      .AgreementEnvelope)
                  SerialisationHelper.deserialise(
                      agreementData.getBinaryValue(),
                      this.getClass().getClassLoader()); // ClassLoader.getSystemClassLoader());
      if (null == agreementTmp) {
        throw new NullPointerException("NullPointerException Deserialized agreement is null");
      }
      AgreementEnvelope agreement =
          AgreementEnvelopeUtils.toAgreementEnvelope(agreementTmp, commManager.getIdManager());
      return agreement;
    } catch (CtxException e) {
      LOG.error("[Error getAgreement] Can't find the agreement. Context error.", e);
    } catch (IOException e) {
      LOG.error("[Error getAgreement] Can't find the agreement. IO error.", e);
    } catch (ClassNotFoundException e) {
      LOG.error("[Error getAgreement] Can't find the agreement. ClassNotFound error.", e);
    } catch (InterruptedException e) {
      LOG.error("[Error getAgreement] Can't find the agreement.", e);
    } catch (ExecutionException e) {
      LOG.error("[Error getAgreement] Can't find the agreement.", e);
    } catch (InvalidFormatException e) {
      LOG.error(
          "[Error getAgreement] Can't transform the agreement into a bean for serialization.", e);
    }
    return null;
  }
コード例 #4
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   PPNPrivacyPreferenceTreeModel other = (PPNPrivacyPreferenceTreeModel) obj;
   if (affectedCtxId == null) {
     if (other.affectedCtxId != null) return false;
   } else if (!affectedCtxId.equals(other.affectedCtxId)) return false;
   if (myContextType == null) {
     if (other.myContextType != null) return false;
   } else if (!myContextType.equals(other.myContextType)) return false;
   if (myPrivacyType != other.myPrivacyType) return false;
   if (pref == null) {
     if (other.pref != null) return false;
   } else if (!pref.equals(other.pref)) return false;
   if (requestor == null) {
     if (other.requestor != null) return false;
   } else if (!requestor.equals(other.requestor)) return false;
   return true;
 }