001/******************************************************************************* 002 * Copyright 2014 The MITRE Corporation 003 * and the MIT Kerberos and Internet Trust Consortium 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 ******************************************************************************/ 017/** 018 * 019 */ 020package org.mitre.oauth2.model; 021 022import java.util.Date; 023import java.util.HashMap; 024import java.util.HashSet; 025import java.util.Map; 026import java.util.Set; 027 028import javax.persistence.AttributeOverride; 029import javax.persistence.AttributeOverrides; 030import javax.persistence.Basic; 031import javax.persistence.CollectionTable; 032import javax.persistence.Column; 033import javax.persistence.ElementCollection; 034import javax.persistence.Embedded; 035import javax.persistence.Entity; 036import javax.persistence.EnumType; 037import javax.persistence.Enumerated; 038import javax.persistence.FetchType; 039import javax.persistence.GeneratedValue; 040import javax.persistence.GenerationType; 041import javax.persistence.Id; 042import javax.persistence.JoinColumn; 043import javax.persistence.NamedQueries; 044import javax.persistence.NamedQuery; 045import javax.persistence.PrePersist; 046import javax.persistence.PreUpdate; 047import javax.persistence.Table; 048import javax.persistence.Temporal; 049import javax.persistence.TemporalType; 050import javax.persistence.Transient; 051 052import org.mitre.jose.JWEAlgorithmEmbed; 053import org.mitre.jose.JWEEncryptionMethodEmbed; 054import org.mitre.jose.JWSAlgorithmEmbed; 055import org.springframework.security.core.GrantedAuthority; 056import org.springframework.security.oauth2.provider.ClientDetails; 057 058import com.nimbusds.jose.EncryptionMethod; 059import com.nimbusds.jose.JWEAlgorithm; 060import com.nimbusds.jose.JWSAlgorithm; 061 062/** 063 * @author jricher 064 * 065 */ 066@Entity 067@Table(name = "client_details") 068@NamedQueries({ 069 @NamedQuery(name = "ClientDetailsEntity.findAll", query = "SELECT c FROM ClientDetailsEntity c"), 070 @NamedQuery(name = "ClientDetailsEntity.getByClientId", query = "select c from ClientDetailsEntity c where c.clientId = :clientId") 071}) 072public class ClientDetailsEntity implements ClientDetails { 073 074 /** 075 * 076 */ 077 private static final int DEFAULT_ID_TOKEN_VALIDITY_SECONDS = 600; 078 079 private static final long serialVersionUID = -1617727085733786296L; 080 081 private Long id; 082 083 /** Fields from the OAuth2 Dynamic Registration Specification */ 084 private String clientId = null; // client_id 085 private String clientSecret = null; // client_secret 086 private Set<String> redirectUris = new HashSet<String>(); // redirect_uris 087 private String clientName; // client_name 088 private String clientUri; // client_uri 089 private String logoUri; // logo_uri 090 private Set<String> contacts; // contacts 091 private String tosUri; // tos_uri 092 private AuthMethod tokenEndpointAuthMethod = AuthMethod.SECRET_BASIC; // token_endpoint_auth_method 093 private Set<String> scope = new HashSet<String>(); // scope 094 private Set<String> grantTypes = new HashSet<String>(); // grant_types 095 private Set<String> responseTypes = new HashSet<String>(); // response_types 096 private String policyUri; 097 private String jwksUri; 098 099 /** Fields from OIDC Client Registration Specification **/ 100 private AppType applicationType; // application_type 101 private String sectorIdentifierUri; // sector_identifier_uri 102 private SubjectType subjectType; // subject_type 103 104 private JWSAlgorithmEmbed requestObjectSigningAlg = null; // request_object_signing_alg 105 106 private JWSAlgorithmEmbed userInfoSignedResponseAlg = null; // user_info_signed_response_alg 107 private JWEAlgorithmEmbed userInfoEncryptedResponseAlg = null; // user_info_encrypted_response_alg 108 private JWEEncryptionMethodEmbed userInfoEncryptedResponseEnc = null; // user_info_encrypted_response_enc 109 110 private JWSAlgorithmEmbed idTokenSignedResponseAlg = null; // id_token_signed_response_alg 111 private JWEAlgorithmEmbed idTokenEncryptedResponseAlg = null; // id_token_encrypted_response_alg 112 private JWEEncryptionMethodEmbed idTokenEncryptedResponseEnc = null; // id_token_encrypted_response_enc 113 114 private JWSAlgorithmEmbed tokenEndpointAuthSigningAlg = null; // token_endpoint_auth_signing_alg 115 116 private Integer defaultMaxAge; // default_max_age 117 private Boolean requireAuthTime; // require_auth_time 118 private Set<String> defaultACRvalues; // default_acr_values 119 120 private String initiateLoginUri; // initiate_login_uri 121 private String postLogoutRedirectUri; // post_logout_redirect_uri 122 123 private Set<String> requestUris; // request_uris 124 125 /** Fields to support the ClientDetails interface **/ 126 private Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>(); 127 private Integer accessTokenValiditySeconds = 0; // in seconds 128 private Integer refreshTokenValiditySeconds = 0; // in seconds 129 private Set<String> resourceIds = new HashSet<String>(); 130 private Map<String, Object> additionalInformation = new HashMap<String, Object>(); 131 132 /** Our own fields **/ 133 private String clientDescription = ""; // human-readable description 134 private boolean reuseRefreshToken = true; // do we let someone reuse a refresh token? 135 private boolean dynamicallyRegistered = false; // was this client dynamically registered? 136 private boolean allowIntrospection = false; // do we let this client call the introspection endpoint? 137 private Integer idTokenValiditySeconds; //timeout for id tokens 138 private Date createdAt; // time the client was created 139 140 public enum AuthMethod { 141 SECRET_POST("client_secret_post"), 142 SECRET_BASIC("client_secret_basic"), 143 SECRET_JWT("client_secret_jwt"), 144 PRIVATE_KEY("private_key_jwt"), 145 NONE("none"); 146 147 private final String value; 148 149 // map to aid reverse lookup 150 private static final Map<String, AuthMethod> lookup = new HashMap<String, AuthMethod>(); 151 static { 152 for (AuthMethod a : AuthMethod.values()) { 153 lookup.put(a.getValue(), a); 154 } 155 } 156 157 AuthMethod(String value) { 158 this.value = value; 159 } 160 161 public String getValue() { 162 return value; 163 } 164 165 public static AuthMethod getByValue(String value) { 166 return lookup.get(value); 167 } 168 } 169 170 public enum AppType { 171 WEB("web"), NATIVE("native"); 172 173 private final String value; 174 175 // map to aid reverse lookup 176 private static final Map<String, AppType> lookup = new HashMap<String, AppType>(); 177 static { 178 for (AppType a : AppType.values()) { 179 lookup.put(a.getValue(), a); 180 } 181 } 182 183 AppType(String value) { 184 this.value = value; 185 } 186 187 public String getValue() { 188 return value; 189 } 190 191 public static AppType getByValue(String value) { 192 return lookup.get(value); 193 } 194 } 195 196 public enum SubjectType { 197 PAIRWISE("pairwise"), PUBLIC("public"); 198 199 private final String value; 200 201 // map to aid reverse lookup 202 private static final Map<String, SubjectType> lookup = new HashMap<String, SubjectType>(); 203 static { 204 for (SubjectType u : SubjectType.values()) { 205 lookup.put(u.getValue(), u); 206 } 207 } 208 209 SubjectType(String value) { 210 this.value = value; 211 } 212 213 public String getValue() { 214 return value; 215 } 216 217 public static SubjectType getByValue(String value) { 218 return lookup.get(value); 219 } 220 } 221 222 /** 223 * Create a blank ClientDetailsEntity 224 */ 225 public ClientDetailsEntity() { 226 227 } 228 229 @PrePersist 230 @PreUpdate 231 private void prePersist() { 232 // make sure that ID tokens always time out, default to 5 minutes 233 if (getIdTokenValiditySeconds() == null) { 234 setIdTokenValiditySeconds(DEFAULT_ID_TOKEN_VALIDITY_SECONDS); 235 } 236 } 237 238 /** 239 * @return the id 240 */ 241 @Id 242 @GeneratedValue(strategy = GenerationType.IDENTITY) 243 @Column(name = "id") 244 public Long getId() { 245 return id; 246 } 247 248 /** 249 * 250 * @param id the id to set 251 */ 252 public void setId(Long id) { 253 this.id = id; 254 } 255 256 /** 257 * @return the clientDescription 258 */ 259 @Basic 260 @Column(name="client_description") 261 public String getClientDescription() { 262 return clientDescription; 263 } 264 265 /** 266 * @param clientDescription Human-readable long description of the client (optional) 267 */ 268 public void setClientDescription(String clientDescription) { 269 this.clientDescription = clientDescription; 270 } 271 272 /** 273 * @return the allowRefresh 274 */ 275 @Transient 276 public boolean isAllowRefresh() { 277 if (grantTypes != null) { 278 return getAuthorizedGrantTypes().contains("refresh_token"); 279 } else { 280 return false; // if there are no grants, we can't be refreshing them, can we? 281 } 282 } 283 284 @Basic 285 @Column(name="reuse_refresh_tokens") 286 public boolean isReuseRefreshToken() { 287 return reuseRefreshToken; 288 } 289 290 public void setReuseRefreshToken(boolean reuseRefreshToken) { 291 this.reuseRefreshToken = reuseRefreshToken; 292 } 293 294 /** 295 * Number of seconds ID token is valid for. MUST be a positive integer, can not be null. 296 * 297 * @return the idTokenValiditySeconds 298 */ 299 @Basic 300 @Column(name="id_token_validity_seconds") 301 public Integer getIdTokenValiditySeconds() { 302 return idTokenValiditySeconds; 303 } 304 305 /** 306 * @param idTokenValiditySeconds the idTokenValiditySeconds to set 307 */ 308 public void setIdTokenValiditySeconds(Integer idTokenValiditySeconds) { 309 this.idTokenValiditySeconds = idTokenValiditySeconds; 310 } 311 312 /** 313 * @return the dynamicallyRegistered 314 */ 315 @Basic 316 @Column(name="dynamically_registered") 317 public boolean isDynamicallyRegistered() { 318 return dynamicallyRegistered; 319 } 320 321 /** 322 * @param dynamicallyRegistered the dynamicallyRegistered to set 323 */ 324 public void setDynamicallyRegistered(boolean dynamicallyRegistered) { 325 this.dynamicallyRegistered = dynamicallyRegistered; 326 } 327 328 329 330 331 332 /** 333 * @return the allowIntrospection 334 */ 335 @Basic 336 @Column(name="allow_introspection") 337 public boolean isAllowIntrospection() { 338 return allowIntrospection; 339 } 340 341 /** 342 * @param allowIntrospection the allowIntrospection to set 343 */ 344 public void setAllowIntrospection(boolean allowIntrospection) { 345 this.allowIntrospection = allowIntrospection; 346 } 347 348 /** 349 * 350 */ 351 @Override 352 @Transient 353 public boolean isSecretRequired() { 354 if (getTokenEndpointAuthMethod() != null && 355 (getTokenEndpointAuthMethod().equals(AuthMethod.SECRET_BASIC) || 356 getTokenEndpointAuthMethod().equals(AuthMethod.SECRET_POST) || 357 getTokenEndpointAuthMethod().equals(AuthMethod.SECRET_JWT))) { 358 return true; 359 } else { 360 return false; 361 } 362 363 } 364 365 /** 366 * If the scope list is not null or empty, then this client has been scoped. 367 */ 368 @Override 369 @Transient 370 public boolean isScoped() { 371 return getScope() != null && !getScope().isEmpty(); 372 } 373 374 /** 375 * @return the clientId 376 */ 377 @Basic 378 @Override 379 @Column(name="client_id") 380 public String getClientId() { 381 return clientId; 382 } 383 384 /** 385 * @param clientId The OAuth2 client_id, must be unique to this client 386 */ 387 public void setClientId(String clientId) { 388 this.clientId = clientId; 389 } 390 391 /** 392 * @return the clientSecret 393 */ 394 @Basic 395 @Override 396 @Column(name="client_secret") 397 public String getClientSecret() { 398 return clientSecret; 399 } 400 401 /** 402 * @param clientSecret the OAuth2 client_secret (optional) 403 */ 404 public void setClientSecret(String clientSecret) { 405 this.clientSecret = clientSecret; 406 } 407 408 /** 409 * @return the scope 410 */ 411 @ElementCollection(fetch = FetchType.EAGER) 412 @CollectionTable( 413 name="client_scope", 414 joinColumns=@JoinColumn(name="owner_id") 415 ) 416 @Override 417 @Column(name="scope") 418 public Set<String> getScope() { 419 return scope; 420 } 421 422 /** 423 * @param scope the set of scopes allowed to be issued to this client 424 */ 425 public void setScope(Set<String> scope) { 426 this.scope = scope; 427 } 428 429 /** 430 * @return the authorizedGrantTypes 431 */ 432 @ElementCollection(fetch = FetchType.EAGER) 433 @CollectionTable( 434 name="client_grant_type", 435 joinColumns=@JoinColumn(name="owner_id") 436 ) 437 @Column(name="grant_type") 438 public Set<String> getGrantTypes() { 439 return grantTypes; 440 } 441 442 /** 443 * @param authorizedGrantTypes the OAuth2 grant types that this client is allowed to use 444 */ 445 public void setGrantTypes(Set<String> grantTypes) { 446 this.grantTypes = grantTypes; 447 } 448 449 /** 450 * passthrough for SECOAUTH api 451 */ 452 @Override 453 @Transient 454 public Set<String> getAuthorizedGrantTypes() { 455 return getGrantTypes(); 456 } 457 458 /** 459 * @return the authorities 460 */ 461 @ElementCollection(fetch = FetchType.EAGER) 462 @CollectionTable( 463 name="client_authority", 464 joinColumns=@JoinColumn(name="owner_id") 465 ) 466 @Override 467 @Column(name="authority") 468 public Set<GrantedAuthority> getAuthorities() { 469 return authorities; 470 } 471 472 /** 473 * @param authorities the Spring Security authorities this client is given 474 */ 475 public void setAuthorities(Set<GrantedAuthority> authorities) { 476 this.authorities = authorities; 477 } 478 479 @Override 480 @Basic 481 @Column(name="access_token_validity_seconds") 482 public Integer getAccessTokenValiditySeconds() { 483 return accessTokenValiditySeconds; 484 } 485 486 /** 487 * @param accessTokenTimeout the accessTokenTimeout to set 488 */ 489 public void setAccessTokenValiditySeconds(Integer accessTokenValiditySeconds) { 490 this.accessTokenValiditySeconds = accessTokenValiditySeconds; 491 } 492 493 @Override 494 @Basic 495 @Column(name="refresh_token_validity_seconds") 496 public Integer getRefreshTokenValiditySeconds() { 497 return refreshTokenValiditySeconds; 498 } 499 500 /** 501 * @param refreshTokenTimeout Lifetime of refresh tokens, in seconds (optional - leave null for no timeout) 502 */ 503 public void setRefreshTokenValiditySeconds(Integer refreshTokenValiditySeconds) { 504 this.refreshTokenValiditySeconds = refreshTokenValiditySeconds; 505 } 506 507 /** 508 * @return the registeredRedirectUri 509 */ 510 @ElementCollection(fetch = FetchType.EAGER) 511 @CollectionTable( 512 name="client_redirect_uri", 513 joinColumns=@JoinColumn(name="owner_id") 514 ) 515 @Column(name="redirect_uri") 516 public Set<String> getRedirectUris() { 517 return redirectUris; 518 } 519 520 /** 521 * @param registeredRedirectUri the registeredRedirectUri to set 522 */ 523 public void setRedirectUris(Set<String> redirectUris) { 524 this.redirectUris = redirectUris; 525 } 526 527 /** 528 * Pass-through method to fulfill the ClientDetails interface with a bad name 529 */ 530 @Override 531 @Transient 532 public Set<String> getRegisteredRedirectUri() { 533 return getRedirectUris(); 534 } 535 536 /** 537 * @return the resourceIds 538 */ 539 @Override 540 @ElementCollection(fetch = FetchType.EAGER) 541 @CollectionTable( 542 name="client_resource", 543 joinColumns=@JoinColumn(name="owner_id") 544 ) 545 @Column(name="resource_id") 546 public Set<String> getResourceIds() { 547 return resourceIds; 548 } 549 550 /** 551 * @param resourceIds the resourceIds to set 552 */ 553 public void setResourceIds(Set<String> resourceIds) { 554 this.resourceIds = resourceIds; 555 } 556 557 558 /** 559 * This library does not make use of this field, so it is not 560 * stored using our persistence layer. 561 * 562 * However, it's somehow required by SECOUATH. 563 * 564 * @return an empty map 565 */ 566 @Override 567 @Transient 568 public Map<String, Object> getAdditionalInformation() { 569 return this.additionalInformation; 570 } 571 572 573 574 575 @Enumerated(EnumType.STRING) 576 @Column(name="application_type") 577 public AppType getApplicationType() { 578 return applicationType; 579 } 580 581 public void setApplicationType(AppType applicationType) { 582 this.applicationType = applicationType; 583 } 584 585 @Basic 586 @Column(name="client_name") 587 public String getClientName() { 588 return clientName; 589 } 590 591 public void setClientName(String clientName) { 592 this.clientName = clientName; 593 } 594 595 @Enumerated(EnumType.STRING) 596 @Column(name="token_endpoint_auth_method") 597 public AuthMethod getTokenEndpointAuthMethod() { 598 return tokenEndpointAuthMethod; 599 } 600 601 public void setTokenEndpointAuthMethod(AuthMethod tokenEndpointAuthMethod) { 602 this.tokenEndpointAuthMethod = tokenEndpointAuthMethod; 603 } 604 605 @Enumerated(EnumType.STRING) 606 @Column(name="subject_type") 607 public SubjectType getSubjectType() { 608 return subjectType; 609 } 610 611 public void setSubjectType(SubjectType subjectType) { 612 this.subjectType = subjectType; 613 } 614 615 @ElementCollection(fetch = FetchType.EAGER) 616 @CollectionTable( 617 name="client_contact", 618 joinColumns=@JoinColumn(name="owner_id") 619 ) 620 @Column(name="contact") 621 public Set<String> getContacts() { 622 return contacts; 623 } 624 625 public void setContacts(Set<String> contacts) { 626 this.contacts = contacts; 627 } 628 629 @Basic 630 @Column(name="logo_uri") 631 public String getLogoUri() { 632 return logoUri; 633 } 634 635 public void setLogoUri(String logoUri) { 636 this.logoUri = logoUri; 637 } 638 639 @Basic 640 @Column(name="policy_uri") 641 public String getPolicyUri() { 642 return policyUri; 643 } 644 645 public void setPolicyUri(String policyUri) { 646 this.policyUri = policyUri; 647 } 648 649 /** 650 * @return the clientUrl 651 */ 652 @Basic 653 @Column(name="client_uri") 654 public String getClientUri() { 655 return clientUri; 656 } 657 658 /** 659 * @param clientUrl the clientUrl to set 660 */ 661 public void setClientUri(String clientUri) { 662 this.clientUri = clientUri; 663 } 664 665 /** 666 * @return the tosUrl 667 */ 668 @Basic 669 @Column(name="tos_uri") 670 public String getTosUri() { 671 return tosUri; 672 } 673 674 /** 675 * @param tosUrl the tosUrl to set 676 */ 677 public void setTosUri(String tosUri) { 678 this.tosUri = tosUri; 679 } 680 681 @Basic 682 @Column(name="jwks_uri") 683 public String getJwksUri() { 684 return jwksUri; 685 } 686 687 public void setJwksUri(String jwksUri) { 688 this.jwksUri = jwksUri; 689 } 690 691 @Basic 692 @Column(name="sector_identifier_uri") 693 public String getSectorIdentifierUri() { 694 return sectorIdentifierUri; 695 } 696 697 public void setSectorIdentifierUri(String sectorIdentifierUri) { 698 this.sectorIdentifierUri = sectorIdentifierUri; 699 } 700 701 @Embedded 702 @AttributeOverrides({ 703 @AttributeOverride(name = "algorithmName", column=@Column(name="request_object_signing_alg")) 704 }) 705 public JWSAlgorithmEmbed getRequestObjectSigningAlgEmbed() { 706 return requestObjectSigningAlg; 707 } 708 709 public void setRequestObjectSigningAlgEmbed(JWSAlgorithmEmbed requestObjectSigningAlg) { 710 this.requestObjectSigningAlg = requestObjectSigningAlg; 711 } 712 713 @Embedded 714 @AttributeOverrides({ 715 @AttributeOverride(name = "algorithmName", column=@Column(name="user_info_signed_response_alg")) 716 }) 717 public JWSAlgorithmEmbed getUserInfoSignedResponseAlgEmbed() { 718 return userInfoSignedResponseAlg; 719 } 720 721 public void setUserInfoSignedResponseAlgEmbed(JWSAlgorithmEmbed userInfoSignedResponseAlg) { 722 this.userInfoSignedResponseAlg = userInfoSignedResponseAlg; 723 } 724 725 @Embedded 726 @AttributeOverrides({ 727 @AttributeOverride(name = "algorithmName", column=@Column(name="user_info_encrypted_response_alg")) 728 }) 729 public JWEAlgorithmEmbed getUserInfoEncryptedResponseAlgEmbed() { 730 return userInfoEncryptedResponseAlg; 731 } 732 733 public void setUserInfoEncryptedResponseAlgEmbed(JWEAlgorithmEmbed userInfoEncryptedResponseAlg) { 734 this.userInfoEncryptedResponseAlg = userInfoEncryptedResponseAlg; 735 } 736 737 @Embedded 738 @AttributeOverrides({ 739 @AttributeOverride(name = "algorithmName", column=@Column(name="user_info_encrypted_response_enc")) 740 }) 741 public JWEEncryptionMethodEmbed getUserInfoEncryptedResponseEncEmbed() { 742 return userInfoEncryptedResponseEnc; 743 } 744 745 public void setUserInfoEncryptedResponseEncEmbed(JWEEncryptionMethodEmbed userInfoEncryptedResponseEnc) { 746 this.userInfoEncryptedResponseEnc = userInfoEncryptedResponseEnc; 747 } 748 749 @Embedded 750 @AttributeOverrides({ 751 @AttributeOverride(name = "algorithmName", column=@Column(name="id_token_signed_response_alg")) 752 }) 753 public JWSAlgorithmEmbed getIdTokenSignedResponseAlgEmbed() { 754 return idTokenSignedResponseAlg; 755 } 756 757 public void setIdTokenSignedResponseAlgEmbed(JWSAlgorithmEmbed idTokenSignedResponseAlg) { 758 this.idTokenSignedResponseAlg = idTokenSignedResponseAlg; 759 } 760 761 @Embedded 762 @AttributeOverrides({ 763 @AttributeOverride(name = "algorithmName", column=@Column(name="id_token_encrypted_response_alg")) 764 }) 765 public JWEAlgorithmEmbed getIdTokenEncryptedResponseAlgEmbed() { 766 return idTokenEncryptedResponseAlg; 767 } 768 769 public void setIdTokenEncryptedResponseAlgEmbed(JWEAlgorithmEmbed idTokenEncryptedResponseAlg) { 770 this.idTokenEncryptedResponseAlg = idTokenEncryptedResponseAlg; 771 } 772 773 @Embedded 774 @AttributeOverrides({ 775 @AttributeOverride(name = "algorithmName", column=@Column(name="id_token_encrypted_response_enc")) 776 }) 777 public JWEEncryptionMethodEmbed getIdTokenEncryptedResponseEncEmbed() { 778 return idTokenEncryptedResponseEnc; 779 } 780 781 public void setIdTokenEncryptedResponseEncEmbed(JWEEncryptionMethodEmbed idTokenEncryptedResponseEnc) { 782 this.idTokenEncryptedResponseEnc = idTokenEncryptedResponseEnc; 783 } 784 785 @Embedded 786 @AttributeOverrides({ 787 @AttributeOverride(name = "algorithmName", column=@Column(name="token_endpoint_auth_signing_alg")) 788 }) 789 public JWSAlgorithmEmbed getTokenEndpointAuthSigningAlgEmbed() { 790 return tokenEndpointAuthSigningAlg; 791 } 792 793 public void setTokenEndpointAuthSigningAlgEmbed(JWSAlgorithmEmbed tokenEndpointAuthSigningAlgEmbed) { 794 this.tokenEndpointAuthSigningAlg = tokenEndpointAuthSigningAlgEmbed; 795 } 796 797 // 798 // Transient passthrough methods for JOSE elements 799 // 800 801 @Transient 802 public JWSAlgorithm getRequestObjectSigningAlg() { 803 if (requestObjectSigningAlg != null) { 804 return requestObjectSigningAlg.getAlgorithm(); 805 } else { 806 return null; 807 } 808 } 809 810 public void setRequestObjectSigningAlg(JWSAlgorithm requestObjectSigningAlg) { 811 this.requestObjectSigningAlg = new JWSAlgorithmEmbed(requestObjectSigningAlg); 812 } 813 814 @Transient 815 public JWSAlgorithm getUserInfoSignedResponseAlg() { 816 if (userInfoSignedResponseAlg != null) { 817 return userInfoSignedResponseAlg.getAlgorithm(); 818 } else { 819 return null; 820 } 821 } 822 823 public void setUserInfoSignedResponseAlg(JWSAlgorithm userInfoSignedResponseAlg) { 824 this.userInfoSignedResponseAlg = new JWSAlgorithmEmbed(userInfoSignedResponseAlg); 825 } 826 827 @Transient 828 public JWEAlgorithm getUserInfoEncryptedResponseAlg() { 829 if (userInfoEncryptedResponseAlg != null) { 830 return userInfoEncryptedResponseAlg.getAlgorithm(); 831 } else { 832 return null; 833 } 834 } 835 836 public void setUserInfoEncryptedResponseAlg(JWEAlgorithm userInfoEncryptedResponseAlg) { 837 this.userInfoEncryptedResponseAlg = new JWEAlgorithmEmbed(userInfoEncryptedResponseAlg); 838 } 839 840 @Transient 841 public EncryptionMethod getUserInfoEncryptedResponseEnc() { 842 if (userInfoEncryptedResponseEnc != null) { 843 return userInfoEncryptedResponseEnc.getAlgorithm(); 844 } else { 845 return null; 846 } 847 } 848 849 public void setUserInfoEncryptedResponseEnc(EncryptionMethod userInfoEncryptedResponseEnc) { 850 this.userInfoEncryptedResponseEnc = new JWEEncryptionMethodEmbed(userInfoEncryptedResponseEnc); 851 } 852 853 @Transient 854 public JWSAlgorithm getIdTokenSignedResponseAlg() { 855 if (idTokenSignedResponseAlg != null) { 856 return idTokenSignedResponseAlg.getAlgorithm(); 857 } else { 858 return null; 859 } 860 } 861 862 public void setIdTokenSignedResponseAlg(JWSAlgorithm idTokenSignedResponseAlg) { 863 this.idTokenSignedResponseAlg = new JWSAlgorithmEmbed(idTokenSignedResponseAlg); 864 } 865 866 @Transient 867 public JWEAlgorithm getIdTokenEncryptedResponseAlg() { 868 if (idTokenEncryptedResponseAlg != null) { 869 return idTokenEncryptedResponseAlg.getAlgorithm(); 870 } else { 871 return null; 872 } 873 } 874 875 public void setIdTokenEncryptedResponseAlg(JWEAlgorithm idTokenEncryptedResponseAlg) { 876 this.idTokenEncryptedResponseAlg = new JWEAlgorithmEmbed(idTokenEncryptedResponseAlg); 877 } 878 879 @Transient 880 public EncryptionMethod getIdTokenEncryptedResponseEnc() { 881 if (idTokenEncryptedResponseEnc != null) { 882 return idTokenEncryptedResponseEnc.getAlgorithm(); 883 } else { 884 return null; 885 } 886 } 887 888 public void setIdTokenEncryptedResponseEnc(EncryptionMethod idTokenEncryptedResponseEnc) { 889 this.idTokenEncryptedResponseEnc = new JWEEncryptionMethodEmbed(idTokenEncryptedResponseEnc); 890 } 891 892 @Transient 893 public JWSAlgorithm getTokenEndpointAuthSigningAlg() { 894 if (tokenEndpointAuthSigningAlg != null) { 895 return tokenEndpointAuthSigningAlg.getAlgorithm(); 896 } else { 897 return null; 898 } 899 } 900 901 public void setTokenEndpointAuthSigningAlg(JWSAlgorithm tokenEndpointAuthSigningAlg) { 902 this.tokenEndpointAuthSigningAlg = new JWSAlgorithmEmbed(tokenEndpointAuthSigningAlg); 903 } 904 905 // END Transient JOSE methods 906 907 @Basic 908 @Column(name="default_max_age") 909 public Integer getDefaultMaxAge() { 910 return defaultMaxAge; 911 } 912 913 public void setDefaultMaxAge(Integer defaultMaxAge) { 914 this.defaultMaxAge = defaultMaxAge; 915 } 916 917 @Basic 918 @Column(name="require_auth_time") 919 public Boolean getRequireAuthTime() { 920 return requireAuthTime; 921 } 922 923 public void setRequireAuthTime(Boolean requireAuthTime) { 924 this.requireAuthTime = requireAuthTime; 925 } 926 927 /** 928 * @return the responseTypes 929 */ 930 @ElementCollection(fetch = FetchType.EAGER) 931 @CollectionTable( 932 name="client_response_type", 933 joinColumns=@JoinColumn(name="owner_id") 934 ) 935 @Column(name="response_type") 936 public Set<String> getResponseTypes() { 937 return responseTypes; 938 } 939 940 /** 941 * @param responseTypes the responseTypes to set 942 */ 943 public void setResponseTypes(Set<String> responseTypes) { 944 this.responseTypes = responseTypes; 945 } 946 947 /** 948 * @return the defaultACRvalues 949 */ 950 @ElementCollection(fetch = FetchType.EAGER) 951 @CollectionTable( 952 name="client_default_acr_value", 953 joinColumns=@JoinColumn(name="owner_id") 954 ) 955 @Column(name="default_acr_value") 956 public Set<String> getDefaultACRvalues() { 957 return defaultACRvalues; 958 } 959 960 /** 961 * @param defaultACRvalues the defaultACRvalues to set 962 */ 963 public void setDefaultACRvalues(Set<String> defaultACRvalues) { 964 this.defaultACRvalues = defaultACRvalues; 965 } 966 967 /** 968 * @return the initiateLoginUri 969 */ 970 @Basic 971 @Column(name="initiate_login_uri") 972 public String getInitiateLoginUri() { 973 return initiateLoginUri; 974 } 975 976 /** 977 * @param initiateLoginUri the initiateLoginUri to set 978 */ 979 public void setInitiateLoginUri(String initiateLoginUri) { 980 this.initiateLoginUri = initiateLoginUri; 981 } 982 983 /** 984 * @return the postLogoutRedirectUri 985 */ 986 @Basic 987 @Column(name="post_logout_redirect_uri") 988 public String getPostLogoutRedirectUri() { 989 return postLogoutRedirectUri; 990 } 991 992 /** 993 * @param postLogoutRedirectUri the postLogoutRedirectUri to set 994 */ 995 public void setPostLogoutRedirectUri(String postLogoutRedirectUri) { 996 this.postLogoutRedirectUri = postLogoutRedirectUri; 997 } 998 999 /** 1000 * @return the requestUris 1001 */ 1002 @ElementCollection(fetch = FetchType.EAGER) 1003 @CollectionTable( 1004 name="client_request_uri", 1005 joinColumns=@JoinColumn(name="owner_id") 1006 ) 1007 @Column(name="request_uri") 1008 public Set<String> getRequestUris() { 1009 return requestUris; 1010 } 1011 1012 /** 1013 * @param requestUris the requestUris to set 1014 */ 1015 public void setRequestUris(Set<String> requestUris) { 1016 this.requestUris = requestUris; 1017 } 1018 1019 /** 1020 * @return the createdAt 1021 */ 1022 @Temporal(TemporalType.TIMESTAMP) 1023 @Column(name="created_at") 1024 public Date getCreatedAt() { 1025 return createdAt; 1026 } 1027 1028 /** 1029 * @param createdAt the createdAt to set 1030 */ 1031 public void setCreatedAt(Date createdAt) { 1032 this.createdAt = createdAt; 1033 } 1034 1035 /** 1036 * Our framework doesn't use this construct, we use WhitelistedSites and ApprovedSites instead. 1037 */ 1038 @Override 1039 public boolean isAutoApprove(String scope) { 1040 return false; 1041 } 1042 1043}