forked from spring-projects/spring-security
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
91 additions
and
15 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
core/src/main/java/org/springframework/security/core/userdetails/UserAuthorities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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 org.springframework.security.core.userdetails; | ||
|
||
import java.io.Serializable; | ||
import java.util.Collection; | ||
|
||
import org.springframework.security.core.GrantedAuthority; | ||
|
||
/** | ||
* Represents user authorities. This interface is mostly intended for scenarios where a | ||
* password is not need, like X509, CAS, Passkeys, One Time Tokens and others. | ||
* | ||
* @author Marcus da Coregio | ||
* @since 6.4 | ||
* @see UserAuthoritiesRepository | ||
* @see UserDetails | ||
*/ | ||
public interface UserAuthorities extends Serializable { | ||
|
||
/** | ||
* Returns the authorities granted to the user. Cannot return <code>null</code>. | ||
* @return the authorities, sorted by natural key (never <code>null</code>) | ||
*/ | ||
Collection<? extends GrantedAuthority> getAuthorities(); | ||
|
||
/** | ||
* Returns the username used to authenticate the user. Cannot return | ||
* <code>null</code>. | ||
* @return the username (never <code>null</code>) | ||
*/ | ||
String getUsername(); | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...rc/main/java/org/springframework/security/core/userdetails/UserAuthoritiesRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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 org.springframework.security.core.userdetails; | ||
|
||
/** | ||
* Repository interface for accessing user authorities. | ||
* | ||
* @author Marcus da Coregio | ||
* @since 6.4 | ||
* @see UserAuthorities | ||
*/ | ||
public interface UserAuthoritiesRepository { | ||
|
||
/** | ||
* Finds the authorities associated with the given username. | ||
* @param username the username for which to find authorities | ||
* @return the {@link UserAuthorities} object containing authorities associated with | ||
* the specified username, or {@code null} if no authorities are found | ||
*/ | ||
UserAuthorities findAuthoritiesByUsername(String username); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters