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


Java LdapUserDetails类代码示例

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


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

示例1: onApplicationEvent

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void onApplicationEvent(InteractiveAuthenticationSuccessEvent event) {
	LdapUserDetails userDetails = (LdapUserDetails) event.getAuthentication().getPrincipal();
	log.info("Login Successful: {}", userDetails.getUsername());
	
	Proprietario proprietario = proprietarioRepository.findByUsuarioIgnoreCase(userDetails.getUsername());
	if (proprietario == null) {
		log.debug("Primeiro acesso de {}", userDetails.getUsername());

		proprietario = new Proprietario();
		proprietario.setUsuario(userDetails.getUsername());

		completarComNome(proprietario, userDetails);
	}

	proprietario.setDataLogin(new Date());
	proprietarioRepository.save(proprietario);

}
 
开发者ID:gustajz,项目名称:parking-api,代码行数:21,代码来源:LoginListener.java

示例2: getPassword

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
/**
 * Get the current user password. Note to work the authentication manager
 * has to set property erase-credentials="false" in spring application context xml file
 *
 * @return the current user's password or empty string
 */
public static String getPassword() {
    String result = "";

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();

    if (auth != null) {
        Object principal = auth.getPrincipal();
        if (principal instanceof LdapUserDetails) {
            result = DigestUtils.shaHex(auth.getCredentials().toString());
        }
        else if (principal instanceof UserDetails) {
            result = ((UserDetails) principal).getPassword();
        }
    }

    return result;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:24,代码来源:UserContext.java

示例3: getClearPassword

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
/**
 * Get the current user clear password. Note to work the authentication manager
 * has to set property erase-credentials="false" in spring application context xml file
 *
 * @return the current user's clear password or empty string
 */
public static String getClearPassword() {
    String result = "";

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();

    if (auth != null) {
        Object principal = auth.getPrincipal();
        if (principal instanceof LdapUserDetails) {
            result = auth.getCredentials().toString();
        }
        else if (principal instanceof UserDetails) {
            result = ((UserWithId) principal).getClearPassword();
        }
    }

    return result;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:24,代码来源:UserContext.java

示例4: view

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
@RequestMapping("/accounts/my")
public String view(Model model) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if(authentication == null) {
        throw new IllegalStateException("authentication cannot be null. Make sure you are logged in.");
    }
    Object principal = userDetailsService.loadUserByUsername(authentication.getName());
    model.addAttribute("user", principal);
    model.addAttribute("isLdapUserDetails", principal instanceof LdapUserDetails);
    model.addAttribute("isLdapPerson", principal instanceof Person);
    model.addAttribute("isLdapInetOrgPerson", principal instanceof InetOrgPerson);
    return "accounts/show";
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:14,代码来源:AccountController.java

示例5: view

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
@RequestMapping("/accounts/my")
public String view(Model model) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if(authentication == null) {
        throw new IllegalStateException("authentication cannot be null. Make sure you are logged in.");
    }
    Object principal = authentication.getPrincipal();
    model.addAttribute("user", principal);
    model.addAttribute("isLdapUserDetails", principal instanceof LdapUserDetails);
    model.addAttribute("isLdapPerson", principal instanceof Person);
    model.addAttribute("isLdapInetOrgPerson", principal instanceof InetOrgPerson);
    return "accounts/show";
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:14,代码来源:AccountController.java

示例6: mapUserFromContext

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
@Override
public UserDetails mapUserFromContext( DirContextOperations ctx, String username,
		Collection<? extends GrantedAuthority> authorities ) {
	LdapUserDetails ldap
			= LdapUserDetails.class.cast( super.mapUserFromContext( ctx, username,
							authorities ) );

	SemossEssence essence = new SemossUser.SemossEssence( ldap );
	SemossUser user = essence.createUserDetails();

	user.setProperty( UserProperty.USER_EMAIL, ctx.getStringAttribute( "mail" ) );
	user.setProperty( UserProperty.USER_FULLNAME, ctx.getStringAttribute( "cn" ) );

	return user;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:16,代码来源:SemossDetailsMapper.java

示例7: LdapUser

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
public LdapUser(LdapUserDetails details, String name, String email) {
    this.details = details;
    this.name = name;
    this.email = email;
    this.userName = details.getUsername();
    AllocatorEntityService allocatorService = new AllocatorEntityService();
    if(allocatorService.searchAllocator(this.userName)!=null){
   	 this.setAllocator(true);
    }else{
   	 this.setAllocator(false);
    }
    
}
 
开发者ID:AuScope,项目名称:igsn30,代码行数:14,代码来源:LdapUser.java

示例8: mapUserFromContext

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
@Override
public UserDetails mapUserFromContext(DirContextOperations ctx, String username,
		Collection<? extends GrantedAuthority> authorities) {
	UserDetails userDetails= super.mapUserFromContext(ctx,username,authorities);
	String fullName = ctx.getStringAttribute("givenName");
	String email = ctx.getStringAttribute("mail");
	return new LdapUser((LdapUserDetails)userDetails,fullName,email);
}
 
开发者ID:AuScope,项目名称:igsn30,代码行数:9,代码来源:UserDetailsContextMapperImpl.java

示例9: getCurrentUser

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
private User getCurrentUser(Authentication auth, UserManager userManager) {
    User currentUser;
    if (auth.getPrincipal() instanceof LdapUserDetails) {
        LdapUserDetails ldapDetails = (LdapUserDetails) auth.getPrincipal();
        String username = ldapDetails.getUsername();
        currentUser = userManager.getUserByUsername(username);
    } else if (auth.getPrincipal() instanceof UserDetails) {
        currentUser = (User) auth.getPrincipal();
    } else if (auth.getDetails() instanceof UserDetails) {
        currentUser = (User) auth.getDetails();
    } else {
        throw new AccessDeniedException("User not properly authenticated.");
    }
    return currentUser;
}
 
开发者ID:SMVBE,项目名称:ldadmin,代码行数:16,代码来源:UserSecurityAdvice.java

示例10: LdapUser

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
public LdapUser(LdapUserDetails details, String name, String email) {
    this.details = details;
    this.name = name;
    this.email = email;
    this.userName = details.getUsername();
  
}
 
开发者ID:AuScope,项目名称:IGSN,代码行数:8,代码来源:LdapUser.java

示例11: mapUserFromContext

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
@Override
public UserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection<? extends GrantedAuthority> authorities) {
    // Default details
    LdapUserDetails userDetails = (LdapUserDetails) super.mapUserFromContext(ctx, username, authorities);
    return extendUserDetails(ctx, userDetails);

}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:8,代码来源:ConfigurableUserDetailsContextMapper.java

示例12: SemossEssence

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
public SemossEssence( LdapUserDetails copyMe ) {
	super( copyMe );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:4,代码来源:SemossUser.java

示例13: extendUserDetails

import org.springframework.security.ldap.userdetails.LdapUserDetails; //导入依赖的package包/类
protected UserDetails extendUserDetails(DirContextOperations ctx, LdapUserDetails userDetails) {
    // Full name
    String fullNameAttribute = settings.getFullNameAttribute();
    if (StringUtils.isBlank(fullNameAttribute)) {
        fullNameAttribute = "cn";
    }
    String fullName = ctx.getStringAttribute(fullNameAttribute);
    // Email
    String emailAttribute = settings.getEmailAttribute();
    if (StringUtils.isBlank(emailAttribute)) {
        emailAttribute = "email";
    }
    String email = ctx.getStringAttribute(emailAttribute);
    // Groups
    String groupAttribute = settings.getGroupAttribute();
    if (StringUtils.isBlank(groupAttribute)) {
        groupAttribute = "memberOf";
    }
    String groupFilter = settings.getGroupFilter();
    String[] groups = ctx.getStringAttributes(groupAttribute);
    Set<String> parsedGroups;
    if (groups != null && groups.length > 0) {
        parsedGroups = Arrays.asList(groups).stream()
                // Parsing of the group
                .map(DistinguishedName::new)
                        // Filter on OU
                .filter(dn -> {
                    String ou = getValue(dn, "OU");
                    return StringUtils.isBlank(groupFilter) || StringUtils.equalsIgnoreCase(ou, groupFilter);
                })
                        // Getting the common name
                .map(dn -> getValue(dn, "CN"))
                        // Keeps only the groups being filled in
                .filter(StringUtils::isNotBlank)
                        // As a set
                .collect(Collectors.toSet());
    } else {
        parsedGroups = Collections.emptySet();
    }
    // OK
    return new ExtendedLDAPUserDetails(userDetails, fullName, email, parsedGroups);
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:43,代码来源:ConfigurableUserDetailsContextMapper.java


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