-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ClientInstanceTokenBinding type #2304
Merged
VivekVinushanth
merged 6 commits into
wso2-extensions:master
from
VivekVinushanth:vv-add-clientInstanceBindingType
Dec 18, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5d916f0
Add ClientInstanceTokenBinding
VivekVinushanth a53a7a2
Merge remote-tracking branch 'upstream/master' into vv-add-clientInst…
VivekVinushanth 8cb2bde
Fix checkstyle
VivekVinushanth 4980141
Update error message
VivekVinushanth 1990572
change bindingType
VivekVinushanth 23eb69a
change bindingType
VivekVinushanth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...in/java/org/wso2/carbon/identity/oauth2/token/bindings/impl/ClientRequestTokenBinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.com). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we update License header |
||
* | ||
* WSO2 Inc. 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. | ||
* 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. | ||
*/ | ||
|
||
package org.wso2.carbon.identity.oauth2.token.bindings.impl; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; | ||
import org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenReqDTO; | ||
import org.wso2.carbon.identity.oauth2.model.RequestParameter; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import static org.wso2.carbon.identity.oauth2.OAuth2Constants.TokenBinderType.CLIENT_REQUEST; | ||
|
||
|
||
/** | ||
* Client Request binding to the token. | ||
*/ | ||
public class ClientRequestTokenBinder extends AbstractTokenBinder { | ||
|
||
private static final String CLIENT_INSTANCE_REF = "tokenBindingReference"; | ||
|
||
@Override | ||
public Optional<String> getTokenBindingValue(OAuth2AccessTokenReqDTO oAuth2AccessTokenReqDTO) { | ||
|
||
RequestParameter[] parameters = oAuth2AccessTokenReqDTO.getRequestParameters(); | ||
for (RequestParameter parameter : parameters) { | ||
if (CLIENT_INSTANCE_REF.equals(parameter.getKey()) | ||
&& StringUtils.isNotBlank(parameter.getValue()[0])) { | ||
return Optional.ofNullable(parameter.getValue()[0]); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
|
||
return "Client Request"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
|
||
return "Client Request Token Binding"; | ||
} | ||
|
||
@Override | ||
public String getBindingType() { | ||
|
||
return CLIENT_REQUEST; | ||
} | ||
|
||
@Override | ||
public List<String> getSupportedGrantTypes() { | ||
Set<String> supportedGrantTypes = OAuthServerConfiguration.getInstance().getSupportedGrantTypes().keySet(); | ||
return supportedGrantTypes.stream().collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
public String getOrGenerateTokenBindingValue(HttpServletRequest request) { | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void setTokenBindingValueForResponse(HttpServletResponse response, String bindingValue) { | ||
|
||
} | ||
|
||
@Override | ||
public void clearTokenBindingElements(HttpServletRequest request, HttpServletResponse response) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isValidTokenBinding(Object request, String bindingReference) { | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isValidTokenBinding(OAuth2AccessTokenReqDTO oAuth2AccessTokenReqDTO, String bindingReference) { | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we do this validation within the ClientInstanceTokenBinder itself ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can but we are unable to throw a client exception from the binder itself.