/*
 * Project: ironvas
 * Package: main.java.de.fhhannover.inform.trust.ironvas
 * File:    Vulnerability.java
 *
 * Copyright (C) 2011-2012 Fachhochschule Hannover
 * Ricklinger Stadtweg 118, 30459 Hannover, Germany 
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.fhhannover.inform.trust.ironvas;

import java.util.Date;

/**
 * This class contains informations related to a vulnerability detected by
 * OpenVAS.
 * 
 * @author Ralf Steuerwald
 *
 */
public class Vulnerability {

	private final String id;
	private Date timestamp;

	private final String subnet;
	private final String host;
	private final String port;
	
	private final ThreatLevel threat;
	private final String description;
	
	private Nvt nvt;
	
	public Vulnerability(String id, Date timestamp, String subnet, String host, String port,
			ThreatLevel threat, String description, Nvt nvt) {
		super();
		this.id = id;
		this.timestamp = timestamp;
		this.subnet = subnet;
		this.host = host;
		this.port = port;
		this.threat = threat;
		this.description = description;
		this.nvt = nvt;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((host == null) ? 0 : host.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((nvt == null) ? 0 : nvt.hashCode());
		result = prime * result + ((port == null) ? 0 : port.hashCode());
		result = prime * result + ((subnet == null) ? 0 : subnet.hashCode());
		result = prime * result + ((threat == null) ? 0 : threat.hashCode());
		result = prime * result
				+ ((timestamp == null) ? 0 : timestamp.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Vulnerability other = (Vulnerability) obj;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (host == null) {
			if (other.host != null)
				return false;
		} else if (!host.equals(other.host))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (nvt == null) {
			if (other.nvt != null)
				return false;
		} else if (!nvt.equals(other.nvt))
			return false;
		if (port == null) {
			if (other.port != null)
				return false;
		} else if (!port.equals(other.port))
			return false;
		if (subnet == null) {
			if (other.subnet != null)
				return false;
		} else if (!subnet.equals(other.subnet))
			return false;
		if (threat != other.threat)
			return false;
		if (timestamp == null) {
			if (other.timestamp != null)
				return false;
		} else if (!timestamp.equals(other.timestamp))
			return false;
		return true;
	}

	public String getId() {
		return id;
	}
	
	public Date getTimestamp() {
		return this.timestamp;
	}

	public String getSubnet() {
		return subnet;
	}

	public String getHost() {
		return host;
	}

	public String getPort() {
		return port;
	}

	public ThreatLevel getThreat() {
		return threat;
	}

	public String getDescription() {
		return description;
	}
	
	public Nvt getNvt() {
		return nvt;
	}
	
}


@@ -1405,38 +1405,8 @@
 id;%0A
-%09%09this.timestamp = timestamp;%0A
 %09%09th
@@ -1537,24 +1537,77 @@
 .nvt = nvt;%0A
+%09%09%0A%09%09this.timestamp = new Date(timestamp.getTime());%0A
 %09%7D%0A%09%0A%09@Overr
@@ -3546,30 +3546,45 @@
 %09return 
-this.timestamp
+new Date(timestamp.getTime())
 ;%0A%09%7D%0A%0A%09p

remove encapsulation gap in Vulnerability