/*
 * Copyright (c) 2013, Carnegie Mellon University
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of SWITCH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL SWITCH BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package edu.cmu.ece.PrivacyLens.ar;

import org.joda.time.DateTime;

/** Represents an attribute release choice. */
public class AttributeReleaseChoice {

    /** The attribute id. */
    private final String attributeId;

    /** An hash over all attribute values. */
    private final String valuesHash;

    /** A timestamp when consent for this attribute release was given. */
    private final DateTime choiceDate;

    /** True if consent, false if denial */
    private final boolean isConsented;

    /**
     * Constructs a @see AttributeReleaseConsent.
     * 
     * @param attributeId The id of the attribute.
     * @param valuesHash The hashed values.
     * @param choiceDate The timestamp for this @see AttributeRelease.
     */
    public AttributeReleaseChoice(final String attributeId, final String valuesHash, final DateTime choiceDate,
            final boolean isConsented) {
        this.attributeId = attributeId;
        this.valuesHash = valuesHash;
        this.choiceDate = choiceDate;
        this.isConsented = isConsented;
    }

    /**
     * Constructs a @see AttributeReleaseConsent.
     * 
     * @param attribute The @see Attribute.
     * @param choiceDate The timestamp for this @see AttributeRelease.
     */
    public AttributeReleaseChoice(final Attribute attribute, final DateTime choiceDate, final boolean isConsented) {
        this.attributeId = attribute.getId();
        this.valuesHash = AttributeReleaseHelper.hashValues(attribute.getValues());
        this.choiceDate = choiceDate;
        this.isConsented = isConsented;
    }

    /**
     * Gets the attribute id.
     * 
     * @return Returns the id.
     */
    public String getAttributeId() {
        return attributeId;
    }

    /**
     * Gets the hash value of the attribute values.
     * 
     * @return Returns the values hash.
     */
    public String getValuesHash() {
        return valuesHash;
    }

    /**
     * Gets the timestamp when consent for this attribute release was given.
     * 
     * @return Returns the date.
     */
    public DateTime getDate() {
        return choiceDate;
    }

    /**
     * Gets whether this choice is a consent or denial.
     * 
     * @return Returns true if consent, false if denial
     */

    public boolean isConsented() {
        return isConsented;
    }

}

@@ -17,16 +17,21 @@
 (c) 2013
+-2015
 , Carneg
@@ -51,16 +51,16 @@
 versity%0A
-
  * All r
@@ -73,25 +73,24 @@
 reserved.%0A *
- 
 %0A * Redistri
@@ -803,17 +803,16 @@
 sion.%0A *
- 
 %0A * THIS
@@ -1637,16 +1637,19 @@
 me;%0A%0A/**
+%0A *
  Represe
@@ -1679,17 +1679,61 @@
 e choice
-.
+: %7Battribute, value, hash, date,%0A * consent%7D%0A
  */%0Apubl
@@ -1844,17 +1844,16 @@
    /** A
-n
  hash ov
@@ -2172,33 +2172,32 @@
 eConsent.%0A     *
- 
 %0A     * @param a
@@ -2727,33 +2727,32 @@
 eConsent.%0A     *
- 
 %0A     * @param a
@@ -3227,33 +3227,32 @@
 ibute id.%0A     *
- 
 %0A     * @return 
@@ -3405,33 +3405,32 @@
 e values.%0A     *
- 
 %0A     * @return 
@@ -3615,33 +3615,32 @@
 as given.%0A     *
- 
 %0A     * @return 
@@ -3795,23 +3795,22 @@
 denial.%0A
+
      *
- 
 %0A     * 

edit comments