Spotless code formatting (#1442)

pull/1445/head
magestack 1 year ago committed by GitHub
parent 4fa248e4ec
commit 2b11fac5f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,7 +54,7 @@ public class LdapConfiguration {
contextSource.setBase(base); contextSource.setBase(base);
contextSource.setUserDn(username); contextSource.setUserDn(username);
contextSource.setPassword(password); contextSource.setPassword(password);
// fix garbled characters // fix garbled characters
config.put("java.naming.ldap.attributes.binary", "objectGUID"); config.put("java.naming.ldap.attributes.binary", "objectGUID");
contextSource.setPooled(true); contextSource.setPooled(true);

@ -73,14 +73,12 @@ public class LdapAuthenticationFilter extends UsernamePasswordAuthenticationFilt
*/ */
private boolean postOnly = true; private boolean postOnly = true;
/** /**
* filter obtains the username and password of LDAP and assembles it on the token. * filter obtains the username and password of LDAP and assembles it on the token.
* Then give the token for authorization * Then give the token for authorization
*/ */
@Override @Override
public Authentication attemptAuthentication(HttpServletRequest request public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
, HttpServletResponse response) throws AuthenticationException {
if (postOnly && !"POST".equals(request.getMethod())) { if (postOnly && !"POST".equals(request.getMethod())) {
throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
} else { } else {

@ -1,3 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.auth.model; package cn.hippo4j.auth.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;

@ -21,6 +21,7 @@ package cn.hippo4j.auth.service;
* Ldap service. * Ldap service.
*/ */
public interface LdapService { public interface LdapService {
/** /**
* Login ldap * Login ldap
*/ */

@ -52,9 +52,8 @@ public class LdapServiceImpl implements LdapService {
public void login(String username, String password) { public void login(String username, String password) {
try { try {
ldapTemplate.authenticate(LdapQueryBuilder.query() ldapTemplate.authenticate(LdapQueryBuilder.query()
.where(accountAttribute).is(username) .where(accountAttribute).is(username)
.and(query().where("objectClass").is(objectClassName)) .and(query().where("objectClass").is(objectClassName)), password);
, password);
log.debug("{} ldap Login successful", username); log.debug("{} ldap Login successful", username);
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
throw new UsernameNotFoundException("ldap Can't find the user information "); throw new UsernameNotFoundException("ldap Can't find the user information ");

@ -70,8 +70,7 @@ public class LdapUserDetailsServiceImpl implements UserDetailsService {
ldapService.login(userName, loginUser.getPassword()); ldapService.login(userName, loginUser.getPassword());
// By querying the data inventory this user does not exist // By querying the data inventory this user does not exist
UserInfo userInfo = userMapper.selectOne(Wrappers.lambdaQuery(UserInfo.class) UserInfo userInfo = userMapper.selectOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getUserName, userName) .eq(UserInfo::getUserName, userName));
);
// the database does not, create a ROLE_USER permission to the default user, password is empty // the database does not, create a ROLE_USER permission to the default user, password is empty
if (Objects.isNull(userInfo)) { if (Objects.isNull(userInfo)) {
userInfo = new UserInfo(); userInfo = new UserInfo();

@ -64,8 +64,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
LoginUser loginUser = (LoginUser) request.getAttribute("loginUser"); LoginUser loginUser = (LoginUser) request.getAttribute("loginUser");
String loginPassword = loginUser.getPassword(); String loginPassword = loginUser.getPassword();
UserInfo userInfo = userMapper.selectOne(Wrappers.lambdaQuery(UserInfo.class) UserInfo userInfo = userMapper.selectOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getUserName, userName) .eq(UserInfo::getUserName, userName));
);
if (Objects.isNull(userInfo)) { if (Objects.isNull(userInfo)) {
throw new UsernameNotFoundException(userName); throw new UsernameNotFoundException(userName);
} }

@ -1,3 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.auth.toolkit; package cn.hippo4j.auth.toolkit;
import cn.hippo4j.common.toolkit.Assert; import cn.hippo4j.common.toolkit.Assert;

Loading…
Cancel
Save