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


Java ApprovalStatus类代码示例

本文整理汇总了Java中org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus的典型用法代码示例。如果您正苦于以下问题:Java ApprovalStatus类的具体用法?Java ApprovalStatus怎么用?Java ApprovalStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ApprovalStatus类属于org.springframework.security.oauth2.provider.approval.Approval包,在下文中一共展示了ApprovalStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddApprovals

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
public void testAddApprovals() {
	assertThatThrownBy(() -> {
		approvalStore.addApprovals(null);
	}).isInstanceOf(NullPointerException.class);
	when(approvalRepository.findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("read")))
			.thenReturn(new UserOAuth2ClientApprovalEntity()
					.setUser(new UserEntity().setId("1"))
					.setClient(new OAuth2ClientEntity().setId("2"))
					.setScope("read")
					.setApprovalStatus(ApprovalStatus.APPROVED));
	approvalStore.addApprovals(Arrays.asList(new Approval("1", "2", "read", new Date(), ApprovalStatus.APPROVED)));
	verify(approvalRepository).findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("read"));
	when(approvalRepository.findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("write")))
			.thenReturn(null);
	approvalStore.addApprovals(Arrays.asList(new Approval("1", "2", "write", new Date(), ApprovalStatus.APPROVED)));
	verify(approvalRepository).findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("write"));
	verify(approvalRepository, times(2)).save(any(UserOAuth2ClientApprovalEntity.class));
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:20,代码来源:UserOauth2ClientApprovalStoreTest.java

示例2: testRevokeApprovals

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
public void testRevokeApprovals() {
	assertThatThrownBy(() -> {
		approvalStore.revokeApprovals(null);
	}).isInstanceOf(NullPointerException.class);
	when(approvalRepository.findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("read")))
			.thenReturn(new UserOAuth2ClientApprovalEntity()
					.setUser(new UserEntity().setId("1"))
					.setClient(new OAuth2ClientEntity().setId("2"))
					.setScope("read")
					.setApprovalStatus(ApprovalStatus.APPROVED));
	when(approvalRepository.findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("write"))).thenReturn(null);
	List<Approval> approvals = new ArrayList<>();
	approvals.add(new Approval("", "", "write", new Date(), ApprovalStatus.APPROVED));
	for (int i = 0; i < 3; i++) {
		approvals.add(new Approval("", "", "read", new Date(), ApprovalStatus.APPROVED));
	}
	approvalStore.revokeApprovals(approvals);
	verify(approvalRepository, times(1)).findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("write"));
	verify(approvalRepository, times(3)).findByUserUsernameAndClientIdAndScope(anyString(), anyString(), eq("read"));
	verify(approvalRepository, times(3)).delete(any(UserOAuth2ClientApprovalEntity.class));
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:23,代码来源:UserOauth2ClientApprovalStoreTest.java

示例3: testGetApprovals

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
@SuppressWarnings("serial")
public void testGetApprovals() {
	when(approvalRepository.findByUserUsernameAndClientId(anyString(), anyString()))
			.thenReturn(Arrays.asList(new UserOAuth2ClientApprovalEntity() {{ setCreatedDate(new Date()); }}
							.setApprovalStatus(ApprovalStatus.APPROVED)
							.setUser(new UserEntity())
							.setClient(new OAuth2ClientEntity()),
					new UserOAuth2ClientApprovalEntity() {{ setCreatedDate(new Date()); }}
							.setApprovalStatus(ApprovalStatus.DENIED)
							.setUser(new UserEntity())
							.setClient(new OAuth2ClientEntity())));
	List<Approval> approvals = new ArrayList<>(approvalStore.getApprovals("1", "2"));
	assertThat(approvals.size()).isEqualTo(2);
	assertThat(approvals.get(0).getStatus()).isEqualTo(ApprovalStatus.APPROVED);
	assertThat(approvals.get(1).getStatus()).isEqualTo(ApprovalStatus.DENIED);
	verify(approvalRepository).findByUserUsernameAndClientId(anyString(), anyString());
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:19,代码来源:UserOauth2ClientApprovalStoreTest.java

示例4: getAccessConfirmation

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@RequestMapping("/oauth/confirm_access")
public ModelAndView getAccessConfirmation(Map<String, Object> model, Principal principal) throws Exception {
	AuthorizationRequest clientAuth = (AuthorizationRequest) model.remove("authorizationRequest");
	ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
	model.put("auth_request", clientAuth);
	model.put("client", client);
	Map<String, String> scopes = new LinkedHashMap<String, String>();
	for (String scope : clientAuth.getScope()) {
		scopes.put(OAuth2Utils.SCOPE_PREFIX + scope, "false");
	}
	for (Approval approval : approvalStore.getApprovals(principal.getName(), client.getClientId())) {
		if (clientAuth.getScope().contains(approval.getScope())) {
			scopes.put(OAuth2Utils.SCOPE_PREFIX + approval.getScope(),
					approval.getStatus() == ApprovalStatus.APPROVED ? "true" : "false");
		}
	}
	model.put("scopes", scopes);
	return new ModelAndView("authorize", model);
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:20,代码来源:AccessConfirmationController.java

示例5: MongoApproval

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@PersistenceConstructor
public MongoApproval(final String id,
                     final String userId,
                     final String clientId,
                     final String scope,
                     final ApprovalStatus status,
                     final LocalDate expiresAt,
                     final LocalDate lastUpdatedAt) {
    this.id = id;
    this.userId = userId;
    this.clientId = clientId;
    this.scope = scope;
    this.status = status;
    this.expiresAt = expiresAt;
    this.lastUpdatedAt = lastUpdatedAt;
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:17,代码来源:MongoApproval.java

示例6: getApprovals

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
/**
 * Extract the implied approvals from any tokens associated with the user and client id supplied.
 * 
 * @see org.springframework.security.oauth2.provider.approval.ApprovalStore#getApprovals(java.lang.String,
 * java.lang.String)
 */
@Override
public Collection<Approval> getApprovals(String userId, String clientId) {
	Collection<Approval> result = new HashSet<Approval>();
	Collection<OAuth2AccessToken> tokens = store.findTokensByUserName(userId);
	for (OAuth2AccessToken token : tokens) {
		OAuth2Authentication authentication = store.readAuthentication(token);
		if (authentication != null && clientId.equals(authentication.getOAuth2Request().getClientId())) {
			Date expiresAt = token.getExpiration();
			for (String scope : token.getScope()) {
				result.add(new Approval(userId, clientId, scope, expiresAt, ApprovalStatus.APPROVED));
			}
		}
	}
	return result;
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:22,代码来源:TokenApprovalStore.java

示例7: testRevokeByExpiry

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
public void testRevokeByExpiry() {
	store.setHandleRevocationsAsExpiry(true);
	Approval approval1 = new Approval("user", "client", "read", 10000,
			ApprovalStatus.APPROVED);
	Approval approval2 = new Approval("user", "client", "write", 10000,
			ApprovalStatus.APPROVED);
	assertTrue(store.addApprovals(Arrays.<Approval> asList(approval1,
			approval2)));
	store.revokeApprovals(Arrays.asList(approval1));
	assertEquals(2, store.getApprovals("user", "client").size());
	assertEquals(
			new Integer(1),
			new JdbcTemplate(db)
					.queryForObject(
							"SELECT COUNT(*) from oauth_approvals where userId='user' AND expiresAt < ?",
							Integer.class,
							new Date(System.currentTimeMillis() + 1000)));
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:20,代码来源:JdbcApprovalStoreTests.java

示例8: getAccessConfirmation

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@RequestMapping("/oauth/confirm_access")
public ModelAndView getAccessConfirmation(Map<String, Object> model, Principal principal) throws Exception {
	AuthorizationRequest clientAuth = (AuthorizationRequest) model.remove("authorizationRequest");
	ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
	model.put("auth_request", clientAuth);
	model.put("client", client);
	Map<String, String> scopes = new LinkedHashMap<String, String>();
	for (String scope : clientAuth.getScope()) {
		scopes.put(OAuth2Utils.SCOPE_PREFIX + scope, "false");
	}
	for (Approval approval : approvalStore.getApprovals(principal.getName(), client.getClientId())) {
		if (clientAuth.getScope().contains(approval.getScope())) {
			scopes.put(OAuth2Utils.SCOPE_PREFIX + approval.getScope(),
					approval.getStatus() == ApprovalStatus.APPROVED ? "true" : "false");
		}
	}
	model.put("scopes", scopes);
	return new ModelAndView("access_confirmation", model);
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:20,代码来源:AccessConfirmationController.java

示例9: MongoApproval

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
public MongoApproval(final String id,
                     final String userId,
                     final String clientId,
                     final String scope,
                     final ApprovalStatus status,
                     final LocalDate expiresAt,
                     final LocalDate lastUpdatedAt) {
    this.id = id;
    this.userId = userId;
    this.clientId = clientId;
    this.scope = scope;
    this.status = status;
    this.expiresAt = expiresAt;
    this.lastUpdatedAt = lastUpdatedAt;
}
 
开发者ID:cloudade,项目名称:authorization-server-with-mongodb,代码行数:16,代码来源:MongoApproval.java

示例10: testAddDifferentScopes

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
public void testAddDifferentScopes() {
    assertTrue(addApprovals(
            Arrays.<Approval>asList(new Approval("user", "client", "read", 1000, ApprovalStatus.APPROVED),
                    new Approval("user", "client", "write", 1000, ApprovalStatus.APPROVED))));
    assertEquals(2, getApprovalStore().getApprovals("user", "client").size());
}
 
开发者ID:cedac-software,项目名称:spring-security-mongodb,代码行数:8,代码来源:AbstractTestApprovalStore.java

示例11: testIdempotentAdd

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
public void testIdempotentAdd() {
    assertTrue(addApprovals(
            Arrays.<Approval>asList(new Approval("user", "client", "read", 1000, ApprovalStatus.APPROVED),
                    new Approval("user", "client", "write", 1000, ApprovalStatus.APPROVED))));
    assertTrue(addApprovals(
            Arrays.<Approval>asList(new Approval("user", "client", "read", 1000, ApprovalStatus.APPROVED),
                    new Approval("user", "client", "write", 1000, ApprovalStatus.APPROVED))));
    assertEquals(2, getApprovalStore().getApprovals("user", "client").size());
}
 
开发者ID:cedac-software,项目名称:spring-security-mongodb,代码行数:11,代码来源:AbstractTestApprovalStore.java

示例12: testAddDifferentClients

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
public void testAddDifferentClients() {
    assertTrue(addApprovals(
            Arrays.<Approval>asList(new Approval("user", "client", "read", 1000, ApprovalStatus.APPROVED),
                    new Approval("user", "other", "write", 1000, ApprovalStatus.APPROVED))));
    assertEquals(1, getApprovalStore().getApprovals("user", "client").size());
    assertEquals(1, getApprovalStore().getApprovals("user", "other").size());
}
 
开发者ID:cedac-software,项目名称:spring-security-mongodb,代码行数:9,代码来源:AbstractTestApprovalStore.java

示例13: testVanillaRevoke

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Test
public void testVanillaRevoke() {
    Approval approval1 = new Approval("user", "client", "read", 1000, ApprovalStatus.APPROVED);
    Approval approval2 = new Approval("user", "client", "write", 1000, ApprovalStatus.APPROVED);
    assertTrue(addApprovals(Arrays.<Approval>asList(approval1, approval2)));
    getApprovalStore().revokeApprovals(Arrays.asList(approval1));
    assertEquals(getExpectedNumberOfApprovalsAfterRevoke(), getApprovalStore().getApprovals("user", "client").size());
}
 
开发者ID:cedac-software,项目名称:spring-security-mongodb,代码行数:9,代码来源:AbstractTestApprovalStore.java

示例14: updateAfterApproval

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的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

示例15: mapRow

import org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus; //导入依赖的package包/类
@Override
public Approval mapRow(ResultSet rs, int rowNum) throws SQLException {
	String userName = rs.getString(4);
	String clientId = rs.getString(5);
	String scope = rs.getString(6);
	Date expiresAt = rs.getTimestamp(1);
	String status = rs.getString(2);
	Date lastUpdatedAt = rs.getTimestamp(3);

	return new Approval(userName, clientId, scope, expiresAt, ApprovalStatus.valueOf(status), lastUpdatedAt);
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:12,代码来源:JdbcApprovalStore.java


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