001package org.apache.archiva.redback.keys.jpa.model; 002 003/* 004 * Copyright 2001-2016 The Apache Software Foundation. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019import org.apache.archiva.redback.keys.AuthenticationKey; 020 021import javax.persistence.Column; 022import javax.persistence.Id; 023import javax.persistence.Table; 024import java.util.Date; 025 026/** 027 * Authentication Key implementation for JPA. 028 * 029 * The table names are set to match the legacy JDO tables. 030 * 031 * @author <a href="mailto:martin_s@apache.org">Martin Stockhammer</a> 032 */ 033@javax.persistence.Entity 034@Table(name="JDOAUTHENTICATIONKEY") 035public class JpaAuthenticationKey implements AuthenticationKey { 036 037 @Column(name="AUTHKEY") 038 @Id 039 private String key; 040 041 @Column(name="FOR_PRINCIPAL") 042 private String forPrincipal; 043 044 @Column(name="PURPOSE") 045 private String purpose; 046 047 @Column(name="DATE_CREATED") 048 private Date dateCreated; 049 050 @Column(name="DATE_EXPIRES") 051 private Date dateExpires; 052 053 public String getKey() { 054 return key; 055 } 056 057 public void setKey(String key) { 058 this.key = key; 059 } 060 061 public String getForPrincipal() { 062 return forPrincipal; 063 } 064 065 public void setForPrincipal(String forPrincipal) { 066 this.forPrincipal = forPrincipal; 067 } 068 069 public String getPurpose() { 070 return purpose; 071 } 072 073 public void setPurpose(String purpose) { 074 this.purpose = purpose; 075 } 076 077 public Date getDateCreated() { 078 return dateCreated; 079 } 080 081 public void setDateCreated(Date dateCreated) { 082 this.dateCreated = dateCreated; 083 } 084 085 public Date getDateExpires() { 086 return dateExpires; 087 } 088 089 public void setDateExpires(Date dateExpires) { 090 this.dateExpires = dateExpires; 091 } 092 093 @Override 094 public boolean equals(Object o) { 095 if (this == o) return true; 096 if (o == null || getClass() != o.getClass()) return false; 097 098 JpaAuthenticationKey that = (JpaAuthenticationKey) o; 099 100 return key.equals(that.key); 101 102 } 103 104 @Override 105 public int hashCode() { 106 return key.hashCode(); 107 } 108}