本文整理汇总了Java中org.springframework.security.oauth2.provider.AuthorizationRequest.getApprovalParameters方法的典型用法代码示例。如果您正苦于以下问题:Java AuthorizationRequest.getApprovalParameters方法的具体用法?Java AuthorizationRequest.getApprovalParameters怎么用?Java AuthorizationRequest.getApprovalParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.oauth2.provider.AuthorizationRequest
的用法示例。
在下文中一共展示了AuthorizationRequest.getApprovalParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkForPreApproval
import org.springframework.security.oauth2.provider.AuthorizationRequest; //导入方法依赖的package包/类
@Override
public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest,
Authentication userAuthentication) {
ClientDetails client = osiamClientDetailsService.loadClientByClientId(authorizationRequest.getClientId());
if (client.isAutoApprove("") || hasRememberedApprovalForClient(authorizationRequest, client)) {
authorizationRequest.setApproved(true);
HashMap<String, String> newApprovalParameters = new HashMap<>(authorizationRequest.getApprovalParameters());
newApprovalParameters.put(IS_PRE_APPROVED_PARAMETER, "true");
authorizationRequest.setApprovalParameters(Collections.unmodifiableMap(newApprovalParameters));
}
return authorizationRequest;
}
示例2: checkForPreApproval
import org.springframework.security.oauth2.provider.AuthorizationRequest; //导入方法依赖的package包/类
@Override
public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest,
Authentication userAuthentication) {
ClientDetails client = osiamClientDetailsService.loadClientByClientId(authorizationRequest.getClientId());
if (client.isAutoApprove("") || hasRememberedApprovalForClient(authorizationRequest, client)) {
authorizationRequest.setApproved(true);
HashMap<String, String> newApprovalParameters = new HashMap<>(authorizationRequest.getApprovalParameters());
newApprovalParameters.put(IS_PRE_APPROVED_PARAMETER, "true");
authorizationRequest.setApprovalParameters(Collections.unmodifiableMap(newApprovalParameters));
}
return authorizationRequest;
}
示例3: updateAfterApproval
import org.springframework.security.oauth2.provider.AuthorizationRequest; //导入方法依赖的package包/类
public AuthorizationRequest updateAfterApproval(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
Map<String, String> approvalParameters = authorizationRequest.getApprovalParameters();
String flag = approvalParameters.get(approvalParameter);
boolean approved = flag != null && flag.toLowerCase().equals("true");
authorizationRequest.setApproved(approved);
return authorizationRequest;
}
示例4: updateAfterApproval
import org.springframework.security.oauth2.provider.AuthorizationRequest; //导入方法依赖的package包/类
/**
* Requires the authorization request to be explicitly approved, including all individual scopes, and the user to be
* authenticated. A scope that was requested in the authorization request can be approved by sending a request
* parameter <code>scope.<scopename></code> equal to "true" or "approved" (otherwise it will be assumed to
* have been denied). The {@link ApprovalStore} will be updated to reflect the inputs.
*
* @param authorizationRequest The authorization request.
* @param userAuthentication the current user authentication
*
* @return An approved request if all scopes have been approved by the current user.
*/
public AuthorizationRequest updateAfterApproval(AuthorizationRequest authorizationRequest,
Authentication userAuthentication) {
// Get the approved scopes
Set<String> requestedScopes = authorizationRequest.getScope();
Set<String> approvedScopes = new HashSet<String>();
Set<Approval> approvals = new HashSet<Approval>();
Date expiry = computeExpiry();
// Store the scopes that have been approved / denied
Map<String, String> approvalParameters = authorizationRequest.getApprovalParameters();
for (String requestedScope : requestedScopes) {
String approvalParameter = scopePrefix + requestedScope;
String value = approvalParameters.get(approvalParameter);
value = value == null ? "" : value.toLowerCase();
if ("true".equals(value) || value.startsWith("approve")) {
approvedScopes.add(requestedScope);
approvals.add(new Approval(userAuthentication.getName(), authorizationRequest.getClientId(),
requestedScope, expiry, ApprovalStatus.APPROVED));
}
else {
approvals.add(new Approval(userAuthentication.getName(), authorizationRequest.getClientId(),
requestedScope, expiry, ApprovalStatus.DENIED));
}
}
approvalStore.addApprovals(approvals);
boolean approved;
authorizationRequest.setScope(approvedScopes);
if (approvedScopes.isEmpty() && !requestedScopes.isEmpty()) {
approved = false;
}
else {
approved = true;
}
authorizationRequest.setApproved(approved);
return authorizationRequest;
}