1 /* 2 * Copyright (c) 2002-2021, City of Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.plugins.oauth2.business; 35 36 import com.nimbusds.jose.Algorithm; 37 38 import java.io.Serializable; 39 40 import java.util.Iterator; 41 import java.util.Set; 42 43 /** 44 * OAuth RegisteredClient 45 */ 46 public class RegisteredClient implements Serializable 47 { 48 private static final long serialVersionUID = 1L; 49 private String _strClientId; 50 private String _strClientSecret; 51 private String _strTokenEndpointAuthMethod; 52 private String _strRedirectUri; 53 private Set<String> _scope; 54 private Set<String> _redirectUris; 55 56 /** 57 * Returns the ClientId 58 * 59 * @return The ClientId 60 */ 61 public String getClientId( ) 62 { 63 return _strClientId; 64 } 65 66 /** 67 * Sets the ClientId 68 * 69 * @param strClientId 70 * The ClientId 71 */ 72 public void setClientId( String strClientId ) 73 { 74 _strClientId = strClientId; 75 } 76 77 /** 78 * Returns the ClientSecret 79 * 80 * @return The ClientSecret 81 */ 82 public String getClientSecret( ) 83 { 84 return _strClientSecret; 85 } 86 87 /** 88 * Sets the ClientSecret 89 * 90 * @param strClientSecret 91 * The ClientSecret 92 */ 93 public void setClientSecret( String strClientSecret ) 94 { 95 _strClientSecret = strClientSecret; 96 } 97 98 /** 99 * Returns the TokenEndpointAuthMethod 100 * 101 * @return The TokenEndpointAuthMethod 102 */ 103 public String getTokenEndpointAuthMethod( ) 104 { 105 return _strTokenEndpointAuthMethod; 106 } 107 108 /** 109 * Sets the TokenEndpointAuthMethod 110 * 111 * @param strTokenEndpointAuthMethod 112 * The TokenEndpointAuthMethod 113 */ 114 public void setTokenEndpointAuthMethod( String strTokenEndpointAuthMethod ) 115 { 116 _strTokenEndpointAuthMethod = strTokenEndpointAuthMethod; 117 } 118 119 /** 120 * Returns the Scope 121 * 122 * @return The Scope 123 */ 124 public Set getScope( ) 125 { 126 return _scope; 127 } 128 129 /** 130 * Sets the Scope 131 * 132 * @param scope 133 * The Scope 134 */ 135 public void setScope( Set scope ) 136 { 137 _scope = scope; 138 } 139 140 /** 141 * Returns the RedirectUri 142 * 143 * @return The RedirectUri 144 */ 145 public String getRedirectUri( ) 146 { 147 return _strRedirectUri; 148 } 149 150 /** 151 * Sets the RedirectUri 152 * 153 * @param strRedirectUri 154 * The RedirectUri 155 */ 156 public void setRedirectUri( String strRedirectUri ) 157 { 158 _strRedirectUri = strRedirectUri; 159 } 160 161 /** 162 * Returns the RedirectUris 163 * 164 * @return The RedirectUris 165 */ 166 public Set getRedirectUris( ) 167 { 168 return _redirectUris; 169 } 170 171 /** 172 * Sets the RedirectUris 173 * 174 * @param redirectUris 175 * The RedirectUris 176 */ 177 public void setRedirectUris( Set redirectUris ) 178 { 179 _redirectUris = redirectUris; 180 } 181 182 /** 183 * Build a string that contains the list of scope separated by a plus 184 * 185 * @return The scopes 186 */ 187 public String getScopes( ) 188 { 189 StringBuilder sbScopes = new StringBuilder( ); 190 191 Iterator iterator = _scope.iterator( ); 192 boolean bFirst = true; 193 194 while ( iterator.hasNext( ) ) 195 { 196 if ( !bFirst ) 197 { 198 sbScopes.append( '+' ); 199 } 200 201 bFirst = false; 202 sbScopes.append( iterator.next( ) ); 203 } 204 205 return sbScopes.toString( ); 206 } 207 208 /** 209 * Return IDToken signed response Algorithm 210 * 211 * @return The IDToken signed response Algorithm 212 */ 213 public Algorithm getIdTokenSignedResponseAlg( ) 214 { 215 return null; 216 } 217 }