mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 05:58:05 +01:00
Update to dropwizard 2.x
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package org.whispersystems.websocket;
|
||||
|
||||
import org.whispersystems.websocket.session.ContextPrincipal;
|
||||
import org.whispersystems.websocket.session.WebSocketSessionContext;
|
||||
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import java.security.Principal;
|
||||
|
||||
public class WebSocketSecurityContext implements SecurityContext {
|
||||
|
||||
private final ContextPrincipal principal;
|
||||
|
||||
public WebSocketSecurityContext(ContextPrincipal principal) {
|
||||
this.principal = principal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return (Principal)principal.getContext().getAuthenticated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String role) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return principal != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthenticationScheme() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public WebSocketSessionContext getSessionContext() {
|
||||
return principal.getContext();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user