Search in sources :

Example 1 with SimplePrincipal

use of org.everrest.core.tools.SimplePrincipal in project che by eclipse.

the class ServerContainerInitializeListener method createSecurityContext.

protected SecurityContext createSecurityContext(final HandshakeRequest req) {
    //todo: get somehow from request
    final boolean isSecure = false;
    final String authType = "BASIC";
    final Subject subject = EnvironmentContext.getCurrent().getSubject();
    final Principal principal = new SimplePrincipal(subject.getUserName());
    return new SecurityContext() {

        @Override
        public Principal getUserPrincipal() {
            return principal;
        }

        @Override
        public boolean isUserInRole(String role) {
            return false;
        }

        @Override
        public boolean isSecure() {
            return isSecure;
        }

        @Override
        public String getAuthenticationScheme() {
            return authType;
        }
    };
}
Also used : SecurityContext(javax.ws.rs.core.SecurityContext) SimpleSecurityContext(org.everrest.core.tools.SimpleSecurityContext) Subject(org.eclipse.che.commons.subject.Subject) SimplePrincipal(org.everrest.core.tools.SimplePrincipal) Principal(java.security.Principal) SimplePrincipal(org.everrest.core.tools.SimplePrincipal)

Aggregations

Principal (java.security.Principal)1 SecurityContext (javax.ws.rs.core.SecurityContext)1 Subject (org.eclipse.che.commons.subject.Subject)1 SimplePrincipal (org.everrest.core.tools.SimplePrincipal)1 SimpleSecurityContext (org.everrest.core.tools.SimpleSecurityContext)1