本文整理汇总了Java中org.osiam.resources.scim.User.isActive方法的典型用法代码示例。如果您正苦于以下问题:Java User.isActive方法的具体用法?Java User.isActive怎么用?Java User.isActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osiam.resources.scim.User
的用法示例。
在下文中一共展示了User.isActive方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateActive
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
private void updateActive(User user, UserEntity userEntity, Set<String> attributes) {
if (attributes.contains("active")) {
userEntity.setActive(null);
}
if (user.isActive() != null) {
userEntity.setActive(user.isActive());
}
}
示例2: authenticate
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
@Override
public Authentication authenticate(Authentication authentication) {
Preconditions.checkArgument(authentication instanceof InternalAuthentication,
"InternalAuthenticationProvider only supports InternalAuthentication.");
String username = authentication.getName();
String password = (String) authentication.getCredentials();
if (Strings.isNullOrEmpty(username)) {
throw new BadCredentialsException("InternalAuthenticationProvider: Empty Username");
}
if (Strings.isNullOrEmpty(password)) {
throw new BadCredentialsException("InternalAuthenticationProvider: Empty Password");
}
assertUserNotLocked(username);
// Determine username
User user = resourceServerConnector.getUserByUsername(username);
if (user == null) {
throw new BadCredentialsException("The user with the username '" + username + "' doesn't exist!");
}
if (user.isActive() != Boolean.TRUE) {
throw new DisabledException("The user with the username '" + username + "' is disabled!");
}
String hashedPassword = passwordEncoder.encodePassword(password, user.getId());
if (resourceServerConnector.searchUserByUserNameAndPassword(username, hashedPassword) == null) {
throw new BadCredentialsException("Bad credentials");
}
User authUser = new User.Builder(username).setId(user.getId()).build();
List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
for (Role role : user.getRoles()) {
grantedAuthorities.add(new SimpleGrantedAuthority(role.getValue()));
}
return new InternalAuthentication(authUser, password, grantedAuthorities);
}
示例3: authenticate
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
@Override
public Authentication authenticate(Authentication authentication) {
Preconditions.checkArgument(authentication instanceof OsiamLdapAuthentication,
"OsiamLdapAuthenticationProvider only supports OsiamLdapAuthentication.");
final OsiamLdapAuthentication userToken = (OsiamLdapAuthentication) authentication;
String username = userToken.getName();
String password = (String) authentication.getCredentials();
if (Strings.isNullOrEmpty(username)) {
throw new BadCredentialsException("OsiamLdapAuthenticationProvider: Empty Username");
}
if (Strings.isNullOrEmpty(password)) {
throw new BadCredentialsException("OsiamLdapAuthenticationProvider: Empty Password");
}
User user = resourceServerConnector.getUserByUsername(username);
checkIfInternalUserExists(user);
DirContextOperations userData = doAuthentication(userToken);
// TODO: check if the next call is needed for it's side effects
osiamLdapUserContextMapper.mapUserFromContext(userData, authentication.getName(),
loadUserAuthorities(userData, authentication.getName(), (String) authentication.getCredentials()));
user = synchronizeLdapData(userData, user);
if (!user.isActive()) {
throw new DisabledException("The user with the username '" + username + "' is disabled!");
}
User authUser = new User.Builder(username).setId(user.getId()).build();
List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
for (Role role : user.getRoles()) {
grantedAuthorities.add(new SimpleGrantedAuthority(role.getValue()));
}
UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(authUser, null,
grantedAuthorities);
result.setDetails(authentication.getDetails());
return result;
}
示例4: fromScim
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
@Override
public UserEntity fromScim(User user) {
if (user == null) {
return null;
}
UserEntity userEntity = new UserEntity();
if (user.getPassword() != null && !user.getPassword().isEmpty()) {
userEntity.setPassword(user.getPassword());
}
if (user.isActive() != null) {
userEntity.setActive(user.isActive());
}
userEntity.setDisplayName(user.getDisplayName());
userEntity.setNickName(user.getNickName());
userEntity.setExternalId(user.getExternalId() == null ? null : user.getExternalId().isEmpty() ? null : user
.getExternalId()); // Due to uniqueness in databases
userEntity.setPreferredLanguage(user.getPreferredLanguage());
userEntity.setLocale(user.getLocale());
userEntity.setProfileUrl(user.getProfileUrl());
userEntity.setTimezone(user.getTimezone());
userEntity.setTitle(user.getTitle());
userEntity.setUserName(user.getUserName());
userEntity.setUserType(user.getUserType());
userEntity.setName(nameConverter.fromScim(user.getName()));
Set<AddressEntity> addresses = convertMultiValueFromScim(addressConverter, new HashSet<>(user.getAddresses()));
for (AddressEntity addressEntity : addresses) {
userEntity.addAddress(addressEntity);
}
Set<EmailEntity> emails = convertMultiValueFromScim(emailConverter, new HashSet<>(user.getEmails()));
for (EmailEntity emailEntity : emails) {
userEntity.addEmail(emailEntity);
}
Set<EntitlementEntity> entitlements = convertMultiValueFromScim(entitlementConverter,
new HashSet<>(user.getEntitlements()));
for (EntitlementEntity entitlementEntity : entitlements) {
userEntity.addEntitlement(entitlementEntity);
}
Set<ImEntity> ims = convertMultiValueFromScim(imConverter, new HashSet<>(user.getIms()));
for (ImEntity imEntity : ims) {
userEntity.addIm(imEntity);
}
Set<PhoneNumberEntity> phoneNumbers = convertMultiValueFromScim(phoneNumberConverter,
new HashSet<>(user.getPhoneNumbers()));
for (PhoneNumberEntity phoneNumberEntity : phoneNumbers) {
userEntity.addPhoneNumber(phoneNumberEntity);
}
Set<PhotoEntity> photos = convertMultiValueFromScim(photoConverter, new HashSet<>(user.getPhotos()));
for (PhotoEntity photoEntity : photos) {
userEntity.addPhoto(photoEntity);
}
Set<RoleEntity> roles = convertMultiValueFromScim(roleConverter, new HashSet<>(user.getRoles()));
for (RoleEntity roleEntity : roles) {
userEntity.addRole(roleEntity);
}
Set<X509CertificateEntity> x509Certificates = convertMultiValueFromScim(x509CertificateConverter,
new HashSet<>(user.getX509Certificates()));
for (X509CertificateEntity x509CertificateEntity : x509Certificates) {
userEntity.addX509Certificate(x509CertificateEntity);
}
Set<ExtensionFieldValueEntity> fieldValues = extensionConverter.fromScim(new HashSet<>(user.getExtensions()
.values()));
for (ExtensionFieldValueEntity fieldValue : fieldValues) {
userEntity.addOrUpdateExtensionValue(fieldValue);
}
return userEntity;
}
示例5: checkAndHandleDeactivation
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
private void checkAndHandleDeactivation(String id, User updateUser) {
if (updateUser.isActive() != null && !updateUser.isActive()) {
tokenService.revokeAllTokensOfUser(id);
}
}
示例6: authenticate
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
@Override
public Authentication authenticate(Authentication authentication) {
Preconditions.checkArgument(authentication instanceof InternalAuthentication,
"InternalAuthenticationProvider only supports InternalAuthentication.");
String username = authentication.getName();
String password = (String) authentication.getCredentials();
if (Strings.isNullOrEmpty(username)) {
throw new BadCredentialsException("InternalAuthenticationProvider: Empty Username");
}
if (Strings.isNullOrEmpty(password)) {
throw new BadCredentialsException("InternalAuthenticationProvider: Empty Password");
}
assertUserNotLocked(username);
User user;
try {
user = userProvisioning.getByUsernameWithPassword(username);
} catch (ResourceNotFoundException rnfe) {
throw new BadCredentialsException("The user with the username '" + username + "' doesn't exist!", rnfe);
}
if (user.isActive() != Boolean.TRUE) {
throw new DisabledException("The user with the username '" + username + "' is disabled!");
}
if (!bCryptPasswordEncoder.matches(password, user.getPassword())) {
if (shaPasswordEncoder.isPasswordValid(user.getPassword(), password, user.getId())) {
User replaceUser = new User.Builder(user).setPassword(password).build();
userProvisioning.replace(user.getId(), replaceUser);
} else {
throw new BadCredentialsException("Bad credentials");
}
}
User authUser = new User.Builder(username).setId(user.getId()).build();
List<GrantedAuthority> grantedAuthorities = user.getRoles().stream()
.map(role -> new SimpleGrantedAuthority(role.getValue()))
.collect(Collectors.toList());
return new InternalAuthentication(authUser, password, grantedAuthorities);
}
示例7: authenticate
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
@Override
public Authentication authenticate(Authentication authentication) {
Preconditions.checkArgument(authentication instanceof OsiamLdapAuthentication,
"OsiamLdapAuthenticationProvider only supports OsiamLdapAuthentication.");
final OsiamLdapAuthentication userToken = (OsiamLdapAuthentication) authentication;
String username = userToken.getName();
String password = (String) authentication.getCredentials();
if (Strings.isNullOrEmpty(username)) {
throw new BadCredentialsException("OsiamLdapAuthenticationProvider: Empty Username");
}
if (Strings.isNullOrEmpty(password)) {
throw new BadCredentialsException("OsiamLdapAuthenticationProvider: Empty Password");
}
User user = null;
try {
user = userProvisioning.getByUsername(username);
} catch (ResourceNotFoundException e) {
// If the user does not exists, it's fine and we just move on. This complies to the
// semantics of the code that was there before. Should be refactored sometimes.
}
checkIfInternalUserExists(user);
DirContextOperations userData = doAuthentication(userToken);
// TODO: check if the next call is needed for it's side effects
osiamLdapUserContextMapper.mapUserFromContext(userData, authentication.getName(),
loadUserAuthorities(userData, authentication.getName(), (String) authentication.getCredentials()));
user = synchronizeLdapData(userData, user);
if (!user.isActive()) {
throw new DisabledException("The user with the username '" + username + "' is disabled!");
}
User authUser = new User.Builder(username).setId(user.getId()).build();
List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
for (Role role : user.getRoles()) {
grantedAuthorities.add(new SimpleGrantedAuthority(role.getValue()));
}
UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(authUser, null,
grantedAuthorities);
result.setDetails(authentication.getDetails());
return result;
}
示例8: fromScim
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
@Override
public UserEntity fromScim(User user) {
if (user == null) {
return null;
}
UserEntity userEntity = new UserEntity();
if (user.getPassword() != null && !user.getPassword().isEmpty()) {
userEntity.setPassword(user.getPassword());
}
if(user.isActive() != null) {
userEntity.setActive(user.isActive());
}
userEntity.setDisplayName(user.getDisplayName());
userEntity.setNickName(user.getNickName());
userEntity.setExternalId(user.getExternalId() == null ? null : user.getExternalId().isEmpty() ? null : user
.getExternalId()); // Due to uniqueness in databases
userEntity.setPreferredLanguage(user.getPreferredLanguage());
userEntity.setLocale(user.getLocale());
userEntity.setProfileUrl(user.getProfileUrl());
userEntity.setTimezone(user.getTimezone());
userEntity.setTitle(user.getTitle());
userEntity.setUserName(user.getUserName());
userEntity.setUserType(user.getUserType());
userEntity.setName(nameConverter.fromScim(user.getName()));
Set<AddressEntity> addresses = convertMultiValueFromScim(addressConverter, new HashSet<>(user.getAddresses()));
for (AddressEntity addressEntity : addresses) {
userEntity.addAddress(addressEntity);
}
Set<EmailEntity> emails = convertMultiValueFromScim(emailConverter, new HashSet<>(user.getEmails()));
for (EmailEntity emailEntity : emails) {
userEntity.addEmail(emailEntity);
}
Set<EntitlementEntity> entitlements = convertMultiValueFromScim(entitlementConverter,
new HashSet<>(user.getEntitlements()));
for (EntitlementEntity entitlementEntity : entitlements) {
userEntity.addEntitlement(entitlementEntity);
}
Set<ImEntity> ims = convertMultiValueFromScim(imConverter, new HashSet<>(user.getIms()));
for (ImEntity imEntity : ims) {
userEntity.addIm(imEntity);
}
Set<PhoneNumberEntity> phoneNumbers = convertMultiValueFromScim(phoneNumberConverter,
new HashSet<>(user.getPhoneNumbers()));
for (PhoneNumberEntity phoneNumberEntity : phoneNumbers) {
userEntity.addPhoneNumber(phoneNumberEntity);
}
Set<PhotoEntity> photos = convertMultiValueFromScim(photoConverter, new HashSet<>(user.getPhotos()));
for (PhotoEntity photoEntity : photos) {
userEntity.addPhoto(photoEntity);
}
Set<RoleEntity> roles = convertMultiValueFromScim(roleConverter, new HashSet<>(user.getRoles()));
for (RoleEntity roleEntity : roles) {
userEntity.addRole(roleEntity);
}
Set<X509CertificateEntity> x509Certificates = convertMultiValueFromScim(x509CertificateConverter,
new HashSet<>(user.getX509Certificates()));
for (X509CertificateEntity x509CertificateEntity : x509Certificates) {
userEntity.addX509Certificate(x509CertificateEntity);
}
Set<ExtensionFieldValueEntity> fieldValues = extensionConverter.fromScim(new HashSet<>(user.getExtensions()
.values()));
for (ExtensionFieldValueEntity fieldValue : fieldValues) {
userEntity.addOrUpdateExtensionValue(fieldValue);
}
return userEntity;
}
示例9: checkAndHandleDeactivation
import org.osiam.resources.scim.User; //导入方法依赖的package包/类
private void checkAndHandleDeactivation(String id, User updateUser, HttpServletRequest request) {
if (updateUser.isActive() != null && !updateUser.isActive()) {
revokeAccessTokens(id, request);
}
}