All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.net.woodstock.rockframework.security.Identity Maven / Gradle / Ivy

The newest version!
/*
 * This file is part of rockframework.
 * 
 * rockframework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 * 
 * rockframework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see ;.
 */
package br.net.woodstock.rockframework.security;

import java.io.Serializable;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.util.List;

import br.net.woodstock.rockframework.core.RockFrameworkVersion;
import br.net.woodstock.rockframework.core.util.EqualsBuilder;
import br.net.woodstock.rockframework.core.util.HashCodeBuilder;
import br.net.woodstock.rockframework.core.util.ToStringBuilder;
import br.net.woodstock.rockframework.core.utils.Collections;

public class Identity implements Serializable {

	private static final long	serialVersionUID	= RockFrameworkVersion.VERSION;

	private PrivateKey			privateKey;

	private List	chain;

	public Identity(final PrivateKey privateKey, final Certificate certificate) {
		super();
		this.privateKey = privateKey;
		if (certificate != null) {
			this.chain = Collections.unmodifiableList(Collections.singletonList(certificate));
		}
	}

	public Identity(final PrivateKey privateKey, final List chain) {
		super();
		this.privateKey = privateKey;
		this.chain = chain;
	}

	public PrivateKey getPrivateKey() {
		return this.privateKey;
	}

	public List getChain() {
		return this.chain;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().add(this.getPrivateKey()).add(this.getChain()).build().intValue();
	}

	@Override
	public boolean equals(final Object obj) {
		if (!(obj instanceof Identity)) {
			return false;
		}
		Identity other = (Identity) obj;
		return new EqualsBuilder().add(this.getPrivateKey(), other.getPrivateKey()).add(this.getChain(), other.getChain()).build().booleanValue();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this.getClass()).add("privateKey", this.getPrivateKey()).build();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy