Package org.jboss.seam.security.management

Source Code of org.jboss.seam.security.management.IdentityObjectImpl

package org.jboss.seam.security.management;

import java.io.Serializable;

import org.picketlink.idm.common.exception.PolicyValidationException;
import org.picketlink.idm.spi.model.IdentityObject;
import org.picketlink.idm.spi.model.IdentityObjectType;

/**
* Based implementation of IdentityObject
*
* @author Shane Bryzak
*/
public class IdentityObjectImpl implements IdentityObject, Serializable
{
   private static final long serialVersionUID = -7880202628037808071L;
  
   private String id;
   private String name;
   private IdentityObjectType type;
  
   public IdentityObjectImpl(String id, String name, IdentityObjectType type)
   {
      if (name == null) throw new IllegalArgumentException("IdentityObject.name cannot be null");
      if (type == null) throw new IllegalArgumentException("IdentityObject.identityType cannot be null");
     
      this.id = id;
      this.name = name;
      this.type = type;
   }

   public String getId()
   {
      return id;
   }

   public IdentityObjectType getIdentityType()
   {
      return type;
   }

   public String getName()
   {
      return name;
   }

   public void validatePolicy() throws PolicyValidationException
   {

   }
  
   @Override
   public boolean equals(Object value)
   {
      if (!(value instanceof IdentityObject)) return false;
      IdentityObject other = (IdentityObject) value;
     
      return (id != null ? id.equals(other.getId()) : other.getId() == null) &&
             name.equals(other.getName()) &&
             type.equals(other.getIdentityType());
   }
  
   @Override
   public int hashCode()
   {
      int hash = 0;
      if (id != null) hash ^= (id.hashCode() * 17);
      hash ^= (name.hashCode() * 29) ^ (type.hashCode() * 37);     
      return hash;
   }
}
TOP

Related Classes of org.jboss.seam.security.management.IdentityObjectImpl

TOP
Copyright © 2018 www.massapi.com. 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.