mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 23:18:05 +01:00
Use SPDX-License-Identifier copyright notices and apply consistently to source throughout the repo. This covers all modules except service. That one will be updated in a subsequent commit.
45 lines
1006 B
Java
45 lines
1006 B
Java
/*
|
|
* Copyright 2013-2020 Signal Messenger, LLC
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
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();
|
|
}
|
|
}
|