Skip to content

Commit

Permalink
Fixed security handler bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mondain committed May 11, 2016
1 parent bad528b commit 593da81
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/main/java/org/red5/server/scope/BasicScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ public boolean isValid() {
* {@inheritDoc}
*/
public boolean isConnectionAllowed(IConnection conn) {
if (log.isDebugEnabled()) {
log.debug("isConnectionAllowed: {}", conn);
}
if (securityHandlers != null) {
if (log.isDebugEnabled()) {
log.debug("securityHandlers: {}", securityHandlers);
}
// loop through the handlers
for (IScopeSecurityHandler handler : securityHandlers) {
// if allowed continue to the next handler
Expand All @@ -234,6 +240,9 @@ public boolean isConnectionAllowed(IConnection conn) {
* {@inheritDoc}
*/
public boolean isScopeAllowed(IScope scope) {
if (log.isDebugEnabled()) {
log.debug("isScopeAllowed: {}", scope);
}
if (securityHandlers != null) {
// loop through the handlers
for (IScopeSecurityHandler handler : securityHandlers) {
Expand All @@ -257,7 +266,11 @@ public void setSecurityHandlers(Set<IScopeSecurityHandler> handlers) {
if (securityHandlers == null) {
securityHandlers = new CopyOnWriteArraySet<>();
}
securityHandlers.addAll(securityHandlers);
// add the specified set of security handlers
securityHandlers.addAll(handlers);
if (log.isDebugEnabled()) {
log.debug("securityHandlers: {}", securityHandlers);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

package org.red5.server.scope;

import org.red5.logging.Red5LoggerFactory;
import org.red5.server.api.IConnection;
import org.red5.server.api.scope.IScope;
import org.red5.server.api.scope.IScopeSecurityHandler;
import org.slf4j.Logger;

/**
* Scope security handler providing positive results to any allow request.
Expand All @@ -29,17 +31,21 @@
*/
public class ScopeSecurityHandler implements IScopeSecurityHandler {

private Logger log = Red5LoggerFactory.getLogger(this.getClass());

protected boolean connectionAllowed = true;

protected boolean scopeAllowed = true;

@Override
public boolean allowed(IConnection conn) {
log.debug("Allowing: {} connection: {}", connectionAllowed, conn);
return connectionAllowed;
}

@Override
public boolean allowed(IScope conn) {
public boolean allowed(IScope scope) {
log.debug("Allowing: {} scope: {}", scopeAllowed, scope);
return scopeAllowed;
}

Expand Down

0 comments on commit 593da81

Please sign in to comment.