• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GrantedAuthorityImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: authenticate

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Override
public Authentication authenticate(Authentication authenticationRequest)
		throws AuthenticationException {
	GrantedAuthority[] authorities = new GrantedAuthorityImpl[authenticationRequest.getAuthorities().length + 1];
	authorities[0] = new GrantedAuthorityImpl(AUTHENTICATED_AUTHORITY_NAME);
	int i = 1;
	for(GrantedAuthority originalAuth : authenticationRequest.getAuthorities()){
		authorities[i] = new GrantedAuthorityImpl(originalAuth.getAuthority());
		i += 1;
	}
	
	UsernamePasswordAuthenticationToken authenticationOutcome = new UsernamePasswordAuthenticationToken(authenticationRequest.getPrincipal(), 
			authenticationRequest.getCredentials(), authorities);
	authenticationOutcome.setDetails(authenticationRequest.getDetails());
	return authenticationOutcome;
}
 
开发者ID:Rospaccio,项目名称:pentaho-authentication-ext,代码行数:17,代码来源:ExtensionAuthenticationProvider.java


示例2: authenticateUser

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
private void authenticateUser(String requestingUserName, HttpServletRequest request) throws UserNotFoundException
{
	IPentahoUser user = getUserRoleDao().getUser(null, requestingUserName);
	if (user == null)
	{
		// TODO: implement alternative behavior if needed, e.g. create the
		// user if it does not exist
		throw new UserNotFoundException("User '" + requestingUserName
				+ "' not found in the current system using the default UserRoleDao bean");
	}

	List<IPentahoRole> roles = getUserRoleDao().getUserRoles(null, requestingUserName);
	GrantedAuthority[] authorities = new GrantedAuthority[roles.size()];
	int index = 0;
	for (IPentahoRole role : roles)
	{
		authorities[index] = new GrantedAuthorityImpl(role.getName());
	}
	ExtensionAuthenticationToken authRequestToken = new ExtensionAuthenticationToken(requestingUserName, null,
			authorities);
	authRequestToken.setDetails(new WebAuthenticationDetails(request));
	Authentication authenticationOutcome = getAuthenticationManager().authenticate(authRequestToken);

	// TODO: manage possible errors (authenticationOutcome == null,
	// Exception, etc...)
	SecurityContextHolder.getContext().setAuthentication(authenticationOutcome);
}
 
开发者ID:Rospaccio,项目名称:pentaho-authentication-ext,代码行数:28,代码来源:AuthenticationExtensionFilter.java


示例3: getGrantedAuthorities

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
private GrantedAuthority[] getGrantedAuthorities(Admin admin) {
	Set<GrantedAuthority> grantedAuthorities = new HashSet<GrantedAuthority>();
	for (Role role : admin.getRoleSet()) {
		for (String authority : role.getAuthorityList()) {
			grantedAuthorities.add(new GrantedAuthorityImpl(authority));
		}
	}
	return grantedAuthorities.toArray(new GrantedAuthority[grantedAuthorities.size()]);
}
 
开发者ID:wangko27,项目名称:SelfSoftShop,代码行数:10,代码来源:AdminDetailsServiceImpl.java


示例4: shouldSetAdministratorIfUserIsAdministrator

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldSetAdministratorIfUserIsAdministrator() throws Exception {
    securityContext.setAuthentication(
            new TestingAuthenticationToken("jez", "badger",
                    new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_SUPERVISOR.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.ADMINISTRATOR), is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:10,代码来源:GoVelocityViewTest.java


示例5: shouldSetTemplateAdministratorIfUserIsTemplateAdministrator

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldSetTemplateAdministratorIfUserIsTemplateAdministrator() throws Exception {
    securityContext.setAuthentication(
            new TestingAuthenticationToken("jez", "badger",
                    new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_TEMPLATE_SUPERVISOR.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.TEMPLATE_ADMINISTRATOR), is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:10,代码来源:GoVelocityViewTest.java


示例6: shouldSetTemplateViewUserRightsForTemplateViewUser

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldSetTemplateViewUserRightsForTemplateViewUser() throws Exception {
    securityContext.setAuthentication(
            new TestingAuthenticationToken("templateView", "badger",
                    new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_TEMPLATE_VIEW_USER.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.TEMPLATE_VIEW_USER), is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:10,代码来源:GoVelocityViewTest.java


示例7: shouldSetViewAdministratorRightsIfUserHasAnyLevelOfAdministratorRights

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldSetViewAdministratorRightsIfUserHasAnyLevelOfAdministratorRights() throws Exception {
    securityContext.setAuthentication(new TestingAuthenticationToken("jez", "badger", new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_TEMPLATE_SUPERVISOR.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.VIEW_ADMINISTRATOR_RIGHTS), is(true));

    securityContext.setAuthentication(new TestingAuthenticationToken("jez", "badger", new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_GROUP_SUPERVISOR.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.VIEW_ADMINISTRATOR_RIGHTS), is(true));

    securityContext.setAuthentication(new TestingAuthenticationToken("jez", "badger", new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_SUPERVISOR.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.VIEW_ADMINISTRATOR_RIGHTS), is(true));

    securityContext.setAuthentication(new TestingAuthenticationToken("jez", "badger", new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_TEMPLATE_VIEW_USER.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.VIEW_ADMINISTRATOR_RIGHTS), is(true));

    securityContext.setAuthentication(new TestingAuthenticationToken("jez", "badger", new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_USER.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.VIEW_ADMINISTRATOR_RIGHTS), is(nullValue()));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:28,代码来源:GoVelocityViewTest.java


示例8: shouldSetGroupAdministratorIfUserIsAPipelineGroupAdministrator

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldSetGroupAdministratorIfUserIsAPipelineGroupAdministrator() throws Exception {
    securityContext.setAuthentication(
            new TestingAuthenticationToken("jez", "badger",
                    new GrantedAuthority[]{new GrantedAuthorityImpl(GoAuthority.ROLE_GROUP_SUPERVISOR.toString())}));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.ADMINISTRATOR), is(nullValue()));
    assertThat(velocityContext.get(GoVelocityView.GROUP_ADMINISTRATOR), is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:GoVelocityViewTest.java


示例9: principalIsTheUsernameWhenNothingElseAvailable

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void principalIsTheUsernameWhenNothingElseAvailable() throws Exception {
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    securityContext.setAuthentication(
            new TestingAuthenticationToken(
                    new User("Test User", "pwd", true, new GrantedAuthority[]{new GrantedAuthorityImpl("nowt")}),
                    null, null));
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.PRINCIPAL), is("Test User"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:GoVelocityViewTest.java


示例10: shouldReturnUserDetailsWithCorrectAuthorityIfAgentCertificateHasOu

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldReturnUserDetailsWithCorrectAuthorityIfAgentCertificateHasOu() {
    X509Certificate agentCertificate = new X509CertificateGenerator().createCertificateWithDn(
            "CN=hostname, OU=agent").getFirstCertificate();
    UserDetails userDetails = populator.getUserDetails(agentCertificate);
    GrantedAuthority[] actual = userDetails.getAuthorities();
    GrantedAuthority expected = new GrantedAuthorityImpl(ROLE_AGENT);
    assertThat(actual.length, is(1));
    assertThat(actual[0], is(expected));
    assertThat(userDetails.getUsername(), is("_go_agent_hostname"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:12,代码来源:X509AuthoritiesPopulatorTest.java


示例11: setUserAttributeWithRole

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
private void setUserAttributeWithRole(final String role) {
    final UserAttribute initialAttribute = new UserAttribute();
    initialAttribute.setPassword("anonymousUser");
    initialAttribute.setAuthorities(new ArrayList() {
        {
            add(new GrantedAuthorityImpl(role));
        }
    });
    setUserAttribute(initialAttribute);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:AnonymousProcessingFilter.java


示例12: getUserDetails

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
public UserDetails getUserDetails(X509Certificate clientCert) throws AuthenticationException {
    X500Principal principal = clientCert.getSubjectX500Principal();
    Matcher cnMatcher = CN_PATTERN.matcher(principal.getName());
    Matcher ouMatcher = OU_PATTERN.matcher(principal.getName());
    if (cnMatcher.find() && ouMatcher.find()) {
        GrantedAuthorityImpl agentAuthority = new GrantedAuthorityImpl(role);
        return new User("_go_agent_" + cnMatcher.group(1), "", true, true, true, true, new GrantedAuthority[]{agentAuthority});
    }
    throw new BadCredentialsException("Couldn't find CN and/or OU for the certificate");
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:X509AuthoritiesPopulator.java


示例13: getAdditionalRoles

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
/**
 *
 * This function returns a list of roles from the given set of groups
 * based on the value of the <code>groupToRoleMap</code> property.
 * 
 * @return a {@link java.util.Set} object.
 */
@Override
protected Set<GrantedAuthority> getAdditionalRoles(final DirContextOperations user, final String username) {
	final String userDn = user.getNameInNamespace();
	final Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();

	if (super.getGroupSearchBase() == null) {
		return authorities;
	}

	if (logger.isDebugEnabled()) {
		logger.debug("Searching for roles for user '" + username + "', DN = " + "'" + userDn + "', with filter "
				+ this.groupSearchFilter + " in search base '" + super.getGroupSearchBase() + "'");
	}

	@SuppressWarnings("unchecked")
	final Set<String> userRoles = ldapTemplate.searchForSingleAttributeValues(
			super.getGroupSearchBase(), 
			this.groupSearchFilter,
			new String[]{userDn, username}, 
			this.groupRoleAttribute
	);

	for(String group : userRoles) {
		final List<String> rolesForGroup = this.groupToRoleMap.get(group);
		logger.debug("Checking " + group + " for an associated role");
		if (rolesForGroup != null) {
			for(String role : rolesForGroup) {
				authorities.add(new GrantedAuthorityImpl(role));
				logger.debug("Added role: " + role + " based on group " + group);
			}
		}
	}

	return authorities;
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:43,代码来源:UserGroupLdapAuthoritiesPopulator.java


示例14: makeAuthentication

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
/**
 * Construct a token with the given id, password, and role
 */
public static Authentication makeAuthentication( String user, String password, String role ) {
    return new TestingAuthenticationToken( user, password,
        new GrantedAuthority[] { new GrantedAuthorityImpl( role ) } );
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:8,代码来源:TestAuthenticationManager.java


示例15: shouldReturnTrueWhenCheckIsAgentIfGrantedAuthorityContainsAgentRole

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldReturnTrueWhenCheckIsAgentIfGrantedAuthorityContainsAgentRole() {
    TestingAuthenticationToken authentication = new TestingAuthenticationToken(null, null,
            new GrantedAuthorityImpl[]{new GrantedAuthorityImpl("ROLE_AGENT")});
    assertThat(UserHelper.matchesRole(authentication, X509AuthoritiesPopulator.ROLE_AGENT), is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:UserHelperTest.java


示例16: shouldReturnFalseWhenCheckIsAgentIfGrantedAuthorityNotContainsAgentRole

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldReturnFalseWhenCheckIsAgentIfGrantedAuthorityNotContainsAgentRole() {
    TestingAuthenticationToken authentication = new TestingAuthenticationToken(null, null,
            new GrantedAuthorityImpl[]{new GrantedAuthorityImpl("anything")});
    assertThat(UserHelper.matchesRole(authentication, X509AuthoritiesPopulator.ROLE_AGENT), is(false));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:UserHelperTest.java


示例17: shouldGetDisplayNameForAPasswordFileUser

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
@Test
public void shouldGetDisplayNameForAPasswordFileUser() {
    GrantedAuthority[] authorities = {new GrantedAuthorityImpl("anything")};
    TestingAuthenticationToken authentication = new TestingAuthenticationToken(new GoUserPrinciple("user", "Full Name", "password", true, true, true, true, authorities), null, authorities);
    assertThat(UserHelper.getUserName(authentication), is(new Username(new CaseInsensitiveString("user"), "Full Name")));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:UserHelperTest.java


示例18: EgovUserDetails

import org.springframework.security.GrantedAuthorityImpl; //导入依赖的package包/类
/**
 * EgovUserDetails 생성자
 * @param username
 * @param password
 * @param enabled
 * @param egovVO
 * @throws IllegalArgumentException
 */
public EgovUserDetails(String username, String password, boolean enabled,
        Object egovVO) throws IllegalArgumentException {
    this(username, password, enabled, true, true, true,
        new GrantedAuthority[] {new GrantedAuthorityImpl("HOLDER") },
        egovVO);
}
 
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:15,代码来源:EgovUserDetails.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActivitiObjectNotFoundException类代码示例发布时间:2022-05-23
下一篇:
Java TableCell类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap