View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.persistence.jpa.entity;
20  
21  import java.time.OffsetDateTime;
22  import javax.persistence.Cacheable;
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.Lob;
26  import javax.persistence.Table;
27  import org.apache.commons.lang3.ArrayUtils;
28  import org.apache.syncope.core.persistence.api.entity.AccessToken;
29  
30  @Entity
31  @Table(name = JPAAccessToken.TABLE)
32  @Cacheable
33  public class JPAAccessToken extends AbstractProvidedKeyEntity implements AccessToken {
34  
35      public static final String TABLE = "AccessToken";
36  
37      private static final long serialVersionUID = -8734194815582467949L;
38  
39      @Lob
40      private String body;
41  
42      private OffsetDateTime expirationTime;
43  
44      @Column(unique = true)
45      private String owner;
46  
47      @Lob
48      private byte[] authorities;
49  
50      @Override
51      public String getBody() {
52          return body;
53      }
54  
55      @Override
56      public void setBody(final String body) {
57          this.body = body;
58      }
59  
60      @Override
61      public OffsetDateTime getExpirationTime() {
62          return expirationTime;
63      }
64  
65      @Override
66      public void setExpirationTime(final OffsetDateTime expirationTime) {
67          this.expirationTime = expirationTime;
68      }
69  
70      @Override
71      public String getOwner() {
72          return owner;
73      }
74  
75      @Override
76      public void setOwner(final String owner) {
77          this.owner = owner;
78      }
79  
80      @Override
81      public byte[] getAuthorities() {
82          return authorities;
83      }
84  
85      @Override
86      public void setAuthorities(final byte[] authorities) {
87          this.authorities = ArrayUtils.clone(authorities);
88      }
89  }