Skip to content

Commit

Permalink
Spotless code formatting (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
magestacks authored Sep 3, 2023
1 parent 4fa248e commit 2b11fac
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public LdapContextSource contextSource() {
contextSource.setBase(base);
contextSource.setUserDn(username);
contextSource.setPassword(password);
// fix garbled characters
// fix garbled characters
config.put("java.naming.ldap.attributes.binary", "objectGUID");

contextSource.setPooled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ public LdapAuthenticationFilter(AuthenticationManager authenticationManager) {
*/
private boolean postOnly = true;


/**
* filter obtains the username and password of LDAP and assembles it on the token.
* Then give the token for authorization
*/
@Override
public Authentication attemptAuthentication(HttpServletRequest request
, HttpServletResponse response) throws AuthenticationException {
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
if (postOnly && !"POST".equals(request.getMethod())) {
throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Ldap service.
*/
public interface LdapService {

/**
* Login ldap
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public LdapServiceImpl(LdapTemplate ldapTemplate) {
public void login(String username, String password) {
try {
ldapTemplate.authenticate(LdapQueryBuilder.query()
.where(accountAttribute).is(username)
.and(query().where("objectClass").is(objectClassName))
, password);
.where(accountAttribute).is(username)
.and(query().where("objectClass").is(objectClassName)), password);
log.debug("{} ldap Login successful", username);
} catch (EmptyResultDataAccessException e) {
throw new UsernameNotFoundException("ldap Can't find the user information ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundEx
ldapService.login(userName, loginUser.getPassword());
// By querying the data inventory this user does not exist
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
if (Objects.isNull(userInfo)) {
userInfo = new UserInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundEx
LoginUser loginUser = (LoginUser) request.getAttribute("loginUser");
String loginPassword = loginUser.getPassword();
UserInfo userInfo = userMapper.selectOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getUserName, userName)
);
.eq(UserInfo::getUserName, userName));
if (Objects.isNull(userInfo)) {
throw new UsernameNotFoundException(userName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

import cn.hippo4j.common.toolkit.Assert;
Expand Down

0 comments on commit 2b11fac

Please sign in to comment.