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


Java SAMLCredential.getAttributeAsString方法代码示例

本文整理汇总了Java中org.springframework.security.saml.SAMLCredential.getAttributeAsString方法的典型用法代码示例。如果您正苦于以下问题:Java SAMLCredential.getAttributeAsString方法的具体用法?Java SAMLCredential.getAttributeAsString怎么用?Java SAMLCredential.getAttributeAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.saml.SAMLCredential的用法示例。


在下文中一共展示了SAMLCredential.getAttributeAsString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGrantedAuthorities

import org.springframework.security.saml.SAMLCredential; //导入方法依赖的package包/类
private List<GrantedAuthority> getGrantedAuthorities(SAMLCredential credential) {
    String rolesClaim = credential.getAttributeAsString("http://wso2.org/claims/role");
    List<GrantedAuthority> authorities = new ArrayList<>();
    if (StringUtils.isNotBlank(rolesClaim)) {
        String[] splitRolesClaim = StringUtils.split(rolesClaim, ",");
        for (String roleClaim : splitRolesClaim) {
            RoleId roleId = RoleId.valueById(roleClaim);
            if (roleId != null) {
                authorities.add(new SimpleGrantedAuthority(roleId.getId()));
            }
        }
    }

    // fallback in case the IdP did not provide any role claims
    if (authorities.isEmpty()) {
        authorities.add(new SimpleGrantedAuthority(RoleId.USER_ROLE_ID.getId()));
    }

    return Collections.unmodifiableList(authorities);
}
 
开发者ID:chrludwig,项目名称:websec-saml2sp,代码行数:21,代码来源:SAMLUserDetailsServiceImpl.java

示例2: loadUserBySAML

import org.springframework.security.saml.SAMLCredential; //导入方法依赖的package包/类
@Override
public Object loadUserBySAML(SAMLCredential credential)
		throws UsernameNotFoundException {
	String usersId = credential.getAttributeAsString("USERS_ID");
	String displayName = credential.getAttributeAsString("DISPLAY_NAME");
	String loginName = credential.getAttributeAsString("LOGIN_NAME");
	String[] groupIds = credential.getAttributeAsStringArray("GROUP_IDS");
	String[] groupNames = credential.getAttributeAsStringArray("GROUPS");
	//String activeFlag = credential.getAttributeAsString("ACTIVE_FLAG");
	String primaryIpAddress =  credential.getAttributeAsString("PRIMARY_IP_ADDRESS");
	String primaryMemberGroupId =  credential.getAttributeAsString("PRIMARY_MEMBER_GROUP_ID");

       Users user = new Users();
       IpAddress ip = new IpAddress();
       ip.setIpAddress(primaryIpAddress);
       
       user.setUsersId(Integer.parseInt(usersId));
       user.setDisplayName(displayName);
       user.setLoginName(displayName);
       user.setFromDb(false);
       //user.setActiveFlag(activeFlag != null && activeFlag.equals("1") ? true : false);
       user.setPrimaryIpAddress(ip);
       user.setPrimaryMemberGroupId(Integer.parseInt(primaryMemberGroupId));
       
       Map<Integer, String> groups = new HashMap<Integer, String>();
       
       for(int i = 0; i < groupIds.length; i++){
       	groups.put(Integer.parseInt(groupIds[i]), groupNames[i]);
       }
       
       user.setMemberGroups(groups);
       
       return user;
}
 
开发者ID:ZFGCCP,项目名称:ZFGC3,代码行数:35,代码来源:SamlUsersDetailsServiceImpl.java

示例3: loadUserBySAML

import org.springframework.security.saml.SAMLCredential; //导入方法依赖的package包/类
@Override
public Object loadUserBySAML(SAMLCredential samlCredential) throws UsernameNotFoundException {
    final String userEmail = samlCredential.getAttributeAsString("email");
    logger.debug("samlCredential.email:" + userEmail);
    final String userName = userEmail.substring(0, userEmail.indexOf("@"));

    UserDetails userDetails = null;
    try {
        userDetails = ldapUserDetailsService.loadUserByUsername(userName);
    } catch (org.springframework.security.core.userdetails.UsernameNotFoundException e) {
        logger.error("User not found in LDAP, check whether he/she has been added to the groups.", e);
    }
    logger.debug("userDeail by search ldap with '" + userName + "' is: " + userDetails);
    return userDetails;
}
 
开发者ID:apache,项目名称:kylin,代码行数:16,代码来源:SAMLUserDetailsService.java

示例4: loadUserBySAML

import org.springframework.security.saml.SAMLCredential; //导入方法依赖的package包/类
@Override
public SamlUser loadUserBySAML(SAMLCredential credential) throws UsernameNotFoundException {

    /**
     * Test-environment response with nordea details. name | friendlyname | value
     http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName | firstName | Portaalia Nordea
     urn:oid:1.2.246.517.2002.2.7 | VakinainenKotimainenLahiosoitePostitoimipaikkaS | Helsinki
     urn:oid:2.16.840.1.113730.3.1.241 | displayName | Nordea
     urn:oid:1.2.246.517.3002.111.2 | null | true
     urn:oid:1.2.246.517.2002.2.6 | VakinainenKotimainenLahiosoitePostinumero | 00120
     urn:oid:2.5.4.42 | givenName | Nordea
     urn:oid:1.2.246.517.2002.2.19 | KotikuntaKuntaS | Helsinki
     urn:oid:2.5.4.3 | cn | Testaaja Portaalia Nordea
     urn:oid:2.5.4.4 | sn | Testaaja
     urn:oid:1.2.246.517.2002.2.18 | KotikuntaKuntanumero | 019
     urn:oid:1.2.246.517.2002.2.4 | VakinainenKotimainenLahiosoiteS | Nordeatie 2
     urn:oid:1.2.246.21 | nationalIdentificationNumber | 210281-9988
     */

    String municipalityNameFi = firstNotEmpty(
            credential.getAttributeAsString("urn:oid:1.2.246.517.2002.2.19") // Finnish city
    ).orElse(MISSING_MUNICIPALITY_FI);
    String municipalityNameSv = firstNotEmpty(
            credential.getAttributeAsString("urn:oid:1.2.246.517.2002.2.20"), // Swedish city
            credential.getAttributeAsString("urn:oid:1.2.246.517.2002.2.19") // Finnish city
    ).orElse(MISSING_MUNICIPALITY_SV);

    String firstNames = credential.getAttributeAsString("http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName");
    String lastName = credential.getAttributeAsString("urn:oid:2.5.4.4");

    String ssn = credential.getAttributeAsString("urn:oid:1.2.246.21");

    String finnishCitizen = credential.getAttributeAsString("urn:oid:1.2.246.517.2002.2.26");

    String address = "";

    return new SamlUser(User.validateSSN(ssn), address, firstNames, lastName, municipalityNameFi, municipalityNameSv, FINNISH_CITIZEN_FLAG.equals(finnishCitizen));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:39,代码来源:SamlUserLoader.java

示例5: loadUserBySAML

import org.springframework.security.saml.SAMLCredential; //导入方法依赖的package包/类
@Override
public Object loadUserBySAML(SAMLCredential cred) throws UsernameNotFoundException {
        // https://www.incommon.org/federation/attributesummary.html
        return cred.getAttributeAsString("urn:oid:1.3.6.1.4.1.5923.1.1.1.6");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:6,代码来源:EppnSamlFilter.java

示例6: loadUserBySAML

import org.springframework.security.saml.SAMLCredential; //导入方法依赖的package包/类
@Override
public Object loadUserBySAML(SAMLCredential cred) throws UsernameNotFoundException {
        // https://www.incommon.org/federation/attributesummary.html	
        return cred.getAttributeAsString("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:6,代码来源:UpnSamlFilter.java


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