-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #763 add client authenticated user request in the OauthHelper f…
…or light-spa-4j (#764)
- Loading branch information
Showing
4 changed files
with
132 additions
and
5 deletions.
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
81 changes: 81 additions & 0 deletions
81
client/src/main/java/com/networknt/client/oauth/ClientAuthenticatedUserRequest.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,81 @@ | ||
package com.networknt.client.oauth; | ||
|
||
import com.networknt.client.ClientConfig; | ||
import com.networknt.client.Http2Client; | ||
import com.networknt.common.SecretConstants; | ||
import com.networknt.config.Config; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ClientAuthenticatedUserRequest extends TokenRequest { | ||
private String userType; | ||
private String userId; | ||
private String roles; | ||
private String redirectUri; | ||
|
||
/** | ||
* load default values from client.yml for client authenticated user grant, overwrite by setters | ||
* in case you want to change it at runtime. | ||
*/ | ||
public ClientAuthenticatedUserRequest(String userType, String userId, String roles) { | ||
setGrantType(ClientConfig.CLIENT_AUTHENTICATED_USER); | ||
setUserType(userType); | ||
setUserId(userId); | ||
setRoles(roles); | ||
Map<String, Object> tokenConfig = ClientConfig.get().getTokenConfig(); | ||
if(tokenConfig != null) { | ||
setServerUrl((String)tokenConfig.get(ClientConfig.SERVER_URL)); | ||
setServiceId((String)tokenConfig.get(ClientConfig.SERVICE_ID)); | ||
Object object = tokenConfig.get(ClientConfig.ENABLE_HTTP2); | ||
setEnableHttp2(object != null && (Boolean) object); | ||
Map<String, Object> acConfig = (Map<String, Object>) tokenConfig.get(ClientConfig.AUTHORIZATION_CODE); | ||
if(acConfig != null) { | ||
setClientId((String)acConfig.get(ClientConfig.CLIENT_ID)); | ||
// load client secret from client.yml and fallback to secret.yml | ||
if(acConfig.get(ClientConfig.CLIENT_SECRET) != null) { | ||
setClientSecret((String)acConfig.get(ClientConfig.CLIENT_SECRET)); | ||
} else { | ||
Map<String, Object> secret = Config.getInstance().getJsonMapConfig(Http2Client.CONFIG_SECRET); | ||
setClientSecret((String)secret.get(SecretConstants.AUTHORIZATION_CODE_CLIENT_SECRET)); | ||
} | ||
setUri((String)acConfig.get(ClientConfig.URI)); | ||
setScope((List<String>)acConfig.get(ClientConfig.SCOPE)); | ||
setRedirectUri((String)acConfig.get(ClientConfig.REDIRECT_URI)); | ||
} | ||
} | ||
} | ||
|
||
public String getUserType() { | ||
return userType; | ||
} | ||
|
||
public void setUserType(String userType) { | ||
this.userType = userType; | ||
} | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public String getRoles() { | ||
return roles; | ||
} | ||
|
||
public void setRoles(String roles) { | ||
this.roles = roles; | ||
} | ||
|
||
public String getRedirectUri() { | ||
return redirectUri; | ||
} | ||
|
||
public void setRedirectUri(String redirectUri) { | ||
this.redirectUri = redirectUri; | ||
} | ||
|
||
} |
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