当前位置: 首页>>代码示例>>Java>>正文


Java AuthorizationRequest.getApprovalParameters方法代码示例

本文整理汇总了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;
}
 
开发者ID:osiam,项目名称:auth-server,代码行数:13,代码来源:OsiamUserApprovalHandler.java

示例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;
}
 
开发者ID:osiam,项目名称:osiam,代码行数:13,代码来源:OsiamUserApprovalHandler.java

示例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;
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:8,代码来源:DefaultUserApprovalHandler.java

示例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.&lt;scopename&gt;</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;
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:50,代码来源:ApprovalStoreUserApprovalHandler.java


注:本文中的org.springframework.security.oauth2.provider.AuthorizationRequest.getApprovalParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。