diff options
author | Brett Porter <brett@apache.org> | 2009-03-20 16:35:02 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-03-20 16:35:02 +0000 |
commit | 34c163502bd8d1f564dd6583cc02147935760fd6 (patch) | |
tree | a7b0c7adc676fdd05b315f5c63908a5948d494fc | |
parent | 66815814265b114792546da22d2d6ba1104ca584 (diff) | |
download | archiva-34c163502bd8d1f564dd6583cc02147935760fd6.tar.gz archiva-34c163502bd8d1f564dd6583cc02147935760fd6.zip |
fix test problems
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@756587 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 17 insertions, 4 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java index d99c9d7bc..7ec8af4bf 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java @@ -46,7 +46,7 @@ public class AuditLog StringBuffer msg = new StringBuffer(); msg.append( checkNull( event.getRepositoryId() ) ).append( DELIM ); msg.append( event.getUserId() ).append( DELIM ); - msg.append( event.getRemoteIP() ).append( DELIM ); + msg.append( checkNull( event.getRemoteIP() ) ).append( DELIM ); msg.append( '\"' ).append( checkNull( event.getResource() ) ).append( '\"' ).append( DELIM ); msg.append( '\"' ).append( event.getAction() ).append( '\"' ); diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java index a12f4d72c..317631825 100644 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java @@ -40,6 +40,11 @@ public final class ArchivaXworkUser public static String getActivePrincipal( Map<String, ?> sessionMap ) { + if ( sessionMap == null ) + { + return UserManager.GUEST_USERNAME; + } + SecuritySession securitySession = (SecuritySession) sessionMap.get( SecuritySystemConstants.SECURITY_SESSION_KEY ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java index 8780aba44..03ea5274d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java @@ -23,6 +23,8 @@ import java.util.ArrayList; import java.util.List;
import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.maven.archiva.repository.audit.AuditEvent;
import org.apache.maven.archiva.repository.audit.AuditListener;
import org.apache.maven.archiva.repository.audit.Auditable;
@@ -75,7 +77,7 @@ public abstract class PlexusActionSupport protected void triggerAuditEvent( String repositoryId, String resource, String action )
{
AuditEvent event = new AuditEvent( repositoryId, getPrincipal(), resource, action );
- event.setRemoteIP( ServletActionContext.getRequest().getRemoteAddr() );
+ event.setRemoteIP( getRemoteAddr() );
for ( AuditListener listener : auditListeners )
{
@@ -86,7 +88,7 @@ public abstract class PlexusActionSupport protected void triggerAuditEvent( String resource, String action )
{
AuditEvent event = new AuditEvent( getPrincipal(), resource, action );
- event.setRemoteIP( ServletActionContext.getRequest().getRemoteAddr() );
+ event.setRemoteIP( getRemoteAddr() );
for ( AuditListener listener : auditListeners )
{
@@ -97,7 +99,7 @@ public abstract class PlexusActionSupport protected void triggerAuditEvent( String action )
{
AuditEvent event = new AuditEvent( getPrincipal(), action );
- event.setRemoteIP( ServletActionContext.getRequest().getRemoteAddr() );
+ event.setRemoteIP( getRemoteAddr() );
for ( AuditListener listener : auditListeners )
{
@@ -105,6 +107,12 @@ public abstract class PlexusActionSupport }
}
+ private String getRemoteAddr()
+ {
+ HttpServletRequest request = ServletActionContext.getRequest();
+ return request != null ? request.getRemoteAddr() : null;
+ }
+
@SuppressWarnings( "unchecked" )
protected String getPrincipal()
{
|