本文整理了Java中org.acegisecurity.Authentication.isAuthenticated()
方法的一些代码示例,展示了Authentication.isAuthenticated()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authentication.isAuthenticated()
方法的具体详情如下:
包路径:org.acegisecurity.Authentication
类名称:Authentication
方法名:isAuthenticated
[英]Used to indicate to AbstractSecurityInterceptor
whether it should present the authentication token to the AuthenticationManager
. Typically an AuthenticationManager
(or, more often, one of its AuthenticationProvider
s) will return an immutable authentication token after successful authentication, in which case that token can safely return true
to this method. Returning true
will improve performance, as calling the AuthenticationManager
for every request will no longer be necessary.
For security reasons, implementations of this interface should be very careful about returning true
to this method unless they are either immutable, or have some way of ensuring the properties have not been changed since original creation.
[中]用于向AbstractSecurityInterceptor
指示是否应向AuthenticationManager
提供身份验证令牌。通常,AuthenticationManager
(或者更常见的是,它的AuthenticationProvider
之一)在成功身份验证后将返回一个不可变的身份验证令牌,在这种情况下,该令牌可以安全地将true
返回到此方法。返回true
将提高性能,因为不再需要为每个请求调用AuthenticationManager
。
出于安全原因,此接口的实现在将true
返回到此方法时应非常小心,除非它们是不可变的,或者有某种方法确保自原始创建以来属性未被更改。
代码示例来源:origin: jenkinsci/jenkins
@Exported
public boolean isAuthenticated() {
return auth().isAuthenticated();
}
代码示例来源:origin: jenkinsci/jenkins
if(existingAuth == null || !existingAuth.isAuthenticated()) {
return true;
代码示例来源:origin: org.mule.modules/mule-module-acegi
public boolean isAuthenticated()
{
return delegate.isAuthenticated();
}
代码示例来源:origin: org.jenkins-ci.plugins/collabnet
/**
* If the user is authenticated, return true.
*
* @param a current authentication.
* @param p permission to check
*
* @return true if the user should have the permission.
*/
@Override
public boolean hasPermission(Authentication a, Permission p) {
return a.isAuthenticated();
}
}
代码示例来源:origin: org.jasig.portal/uportal3-impl
public boolean isUserAuthenticated() {
SecurityContext securityContext=getSecurityContext();
if(securityContext!=null) {
Authentication authentication=securityContext.getAuthentication();
if(authentication!=null) {
return authentication.isAuthenticated();
} else {
logger.error("isUserAuthenticated() - unable to acquire authentication from a valid SecureContext", null);
}
}
return false;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Exported
public boolean isAuthenticated() {
return auth().isAuthenticated();
}
代码示例来源:origin: com.marvelution.atlassian.suite.plugins/atlassian-sonarqube-common
@Override
public boolean isAuthenticated() {
return SecurityContextHolder.getContext().getAuthentication().isAuthenticated();
}
代码示例来源:origin: org.acegisecurity/acegi-security
private boolean authenticationIsRequired(String username) {
// Only reauthenticate if username doesn't match SecurityContextHolder and user isn't authenticated
// (see SEC-53)
Authentication existingAuth = SecurityContextHolder.getContext().getAuthentication();
if(existingAuth == null || !existingAuth.isAuthenticated()) {
return true;
}
// Limit username comparison to providers which use usernames (ie UsernamePasswordAuthenticationToken)
// (see SEC-348)
if (existingAuth instanceof UsernamePasswordAuthenticationToken && !existingAuth.getName().equals(username)) {
return true;
}
// Handle unusual condition where an AnonymousAuthenticationToken is already present
// This shouldn't happen very often, as BasicProcessingFitler is meant to be earlier in the filter
// chain than AnonymousProcessingFilter. Nevertheless, presence of both an AnonymousAuthenticationToken
// together with a BASIC authentication request header should indicate reauthentication using the
// BASIC protocol is desirable. This behaviour is also consistent with that provided by form and digest,
// both of which force re-authentication if the respective header is detected (and in doing so replace
// any existing AnonymousAuthenticationToken). See SEC-610.
if (existingAuth instanceof AnonymousAuthenticationToken) {
return true;
}
return false;
}
代码示例来源:origin: org.jasig.portal/uportal3-impl
this.previousAuthenticationState=new Boolean(authentication.isAuthenticated());
throw new PortalUserNotFoundException(principal);
} else if(this.previousAuthenticationState.booleanValue()!=authentication.isAuthenticated()) {
this.previousAuthenticationState=new Boolean(authentication.isAuthenticated());
distributeAuthenticationChangedEvent(req);
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
if(existingAuth == null || !existingAuth.isAuthenticated()) {
return true;
代码示例来源:origin: org.jvnet.hudson.plugins/favorite
@Override
public List<TopLevelItem> filter(List<TopLevelItem> added, List<TopLevelItem> all, View filteringView) {
List<TopLevelItem> filtered = new ArrayList<TopLevelItem>(added);
Authentication authentication = Hudson.getAuthentication();
String name = authentication.getName();
if (authentication.isAuthenticated()) {
User user = Hudson.getInstance().getUser(name);
FavoriteUserProperty fup = user.getProperty(FavoriteUserProperty.class);
for (TopLevelItem item : all) {
if (fup == null || !fup.isJobFavorite(item.getName())) {
filtered.remove(item);
}
}
}
return filtered;
}
代码示例来源:origin: org.acegisecurity/acegi-security
if (!SecurityContextHolder.getContext().getAuthentication().isAuthenticated() || alwaysReauthenticate) {
try {
authenticated = this.authenticationManager.authenticate(SecurityContextHolder.getContext()
代码示例来源:origin: mocleiri/github-oauth-plugin
if (!a.isAuthenticated())
return false;
代码示例来源:origin: org.jenkins-ci.plugins/collabnet
if (!auth.isAuthenticated() || auth.getPrincipal().equals("anonymous")) {
loginHudsonUsingCTFSSO((CollabNetSecurityRealm)securityRealm, httpRequest);
代码示例来源:origin: org.acegisecurity/acegi-security
public void securityCheck(Acl acl, int changeType) {
if ((SecurityContextHolder.getContext() == null)
|| (SecurityContextHolder.getContext().getAuthentication() == null)
|| !SecurityContextHolder.getContext().getAuthentication().isAuthenticated()) {
throw new AccessDeniedException("Authenticated principal required to operate with ACLs");
内容来源于网络,如有侵权,请联系作者删除!