Skip to content

Commit

Permalink
Carried out some suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
gershom96 committed Sep 8, 2022
1 parent 324fc23 commit af6b257
Showing 1 changed file with 14 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/*
* Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wso2.carbon.identity.api.server.application.management.v1.core.functions.application.inbound.oauth2;
Expand Down Expand Up @@ -89,7 +87,7 @@ private AccessTokenConfiguration buildTokenConfiguration(OAuthConsumerAppDTO oAu
.revokeTokensWhenIDPSessionTerminated(oAuthConsumerAppDTO
.isTokenRevocationWithIDPSessionTerminationEnabled())
.validateTokenBinding(oAuthConsumerAppDTO.isTokenBindingValidationEnabled())
.audience(getAccessTokenAudiences(oAuthConsumerAppDTO));
.audience(getAccessTokenAudiences(oAuthConsumerAppDTO.getAccessTokenAudiences()));
}

private RefreshTokenConfiguration buildRefreshTokenConfiguration(OAuthConsumerAppDTO oAuthConsumerAppDTO) {
Expand All @@ -103,39 +101,18 @@ private IdTokenConfiguration buildIdTokenConfiguration(OAuthConsumerAppDTO oAuth

return new IdTokenConfiguration()
.expiryInSeconds(oAuthConsumerAppDTO.getIdTokenExpiryTime())
.audience(getIdTokenAudiences(oAuthConsumerAppDTO))
.audience(getIdTokenAudiences(oAuthConsumerAppDTO.getIdTokenAudiences()))
.encryption(buildIdTokenEncryptionConfiguration(oAuthConsumerAppDTO));
}

/**
* @deprecated use {@link #getIdTokenAudiences()} instead.
*/
@Deprecated
private List<String> getAudiences(OAuthConsumerAppDTO oAuthConsumerAppDTO) {
private List<String> getIdTokenAudiences(String[] audiences) {

if (oAuthConsumerAppDTO.getAudiences() == null) {
return Collections.emptyList();
} else {
return Arrays.asList(oAuthConsumerAppDTO.getAudiences());
}
}

private List<String> getIdTokenAudiences(OAuthConsumerAppDTO oAuthConsumerAppDTO) {

if (oAuthConsumerAppDTO.getIdTokenAudiences() == null) {
return Collections.emptyList();
} else {
return Arrays.asList(oAuthConsumerAppDTO.getIdTokenAudiences());
}
return (audiences == null) ? Collections.emptyList() : Arrays.asList(audiences);
}

private List<String> getAccessTokenAudiences(OAuthConsumerAppDTO oAuthConsumerAppDTO) {
private List<String> getAccessTokenAudiences(String[] audiences) {

if (oAuthConsumerAppDTO.getAccessTokenAudiences() == null) {
return Collections.emptyList();
} else {
return Arrays.asList(oAuthConsumerAppDTO.getAccessTokenAudiences());
}
return (audiences == null) ? Collections.emptyList() : Arrays.asList(audiences);
}
private IdTokenEncryptionConfiguration buildIdTokenEncryptionConfiguration(OAuthConsumerAppDTO appDTO) {

Expand Down

0 comments on commit af6b257

Please sign in to comment.