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.common.lib.oidc;
20  
21  import com.fasterxml.jackson.annotation.JsonIgnore;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
23  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
24  import java.io.Serializable;
25  import java.time.OffsetDateTime;
26  import java.util.HashSet;
27  import java.util.Optional;
28  import java.util.Set;
29  import org.apache.syncope.common.lib.Attr;
30  
31  public class OIDCLoginResponse implements Serializable {
32  
33      private static final long serialVersionUID = -5971442076182154492L;
34  
35      private String username;
36  
37      private boolean logoutSupported;
38  
39      private boolean selfReg;
40  
41      private String accessToken;
42  
43      private OffsetDateTime accessTokenExpiryTime;
44  
45      private final Set<Attr> attrs = new HashSet<>();
46  
47      public String getUsername() {
48          return username;
49      }
50  
51      public void setUsername(final String username) {
52          this.username = username;
53      }
54  
55      public boolean isLogoutSupported() {
56          return logoutSupported;
57      }
58  
59      public void setLogoutSupported(final boolean logoutSupported) {
60          this.logoutSupported = logoutSupported;
61      }
62  
63      public boolean isSelfReg() {
64          return selfReg;
65      }
66  
67      public void setSelfReg(final boolean selfReg) {
68          this.selfReg = selfReg;
69      }
70  
71      public String getAccessToken() {
72          return accessToken;
73      }
74  
75      public void setAccessToken(final String accessToken) {
76          this.accessToken = accessToken;
77      }
78  
79      public OffsetDateTime getAccessTokenExpiryTime() {
80          return accessTokenExpiryTime;
81      }
82  
83      public void setAccessTokenExpiryTime(final OffsetDateTime accessTokenExpiryTime) {
84          this.accessTokenExpiryTime = accessTokenExpiryTime;
85      }
86  
87      @JsonIgnore
88      public Optional<Attr> getAttr(final String schema) {
89          return attrs.stream().filter(attr -> attr.getSchema().equals(schema)).findFirst();
90      }
91  
92      @JacksonXmlElementWrapper(localName = "attrs")
93      @JacksonXmlProperty(localName = "attr")
94      public Set<Attr> getAttrs() {
95          return attrs;
96      }
97  }