Class JettyLib


  • public class JettyLib
    extends java.lang.Object
    Helpers for working with Jetty.

    SecurityHandler

         UserStore userStore = JettyLib.makeUserStore(...);
         SecurityHandler securityHandler = JettyLib.makeSecurityHandler(String pathSpec, String realm, UserStore userStore);
      
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static AuthScheme authMode
      Current auth mode
      static AuthScheme dftAuthMode
      Digest requires an extra round trip so it is unfriendly to API or scripts that stream.
    • Constructor Summary

      Constructors 
      Constructor Description
      JettyLib()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addHandler​(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.Handler handler)
      Add or append a Handler to a Jetty Server.
      static void addPathConstraint​(org.eclipse.jetty.security.ConstraintSecurityHandler securityHandler, java.lang.String pathSpec)  
      static void addPathConstraint​(org.eclipse.jetty.security.ConstraintSecurityHandler securityHandler, java.lang.String pathSpec, java.lang.String role)  
      static org.eclipse.jetty.security.UserStore addUser​(org.eclipse.jetty.security.UserStore userStore, java.lang.String user, java.lang.String password)  
      static org.eclipse.jetty.security.UserStore addUser​(org.eclipse.jetty.security.UserStore userStore, java.lang.String user, java.lang.String password, java.lang.String role)
      Make a UserStore for a single user,password,role
      static org.eclipse.jetty.server.HttpConfiguration httpConfiguration()
      HTTP configuration with setting for Fuseki workload.
      static org.eclipse.jetty.security.ConstraintSecurityHandler makeSecurityHandler​(java.lang.String realm, org.eclipse.jetty.security.UserStore userStore)
      Create a Jetty SecurityHandler for basic authentication.
      static org.eclipse.jetty.security.ConstraintSecurityHandler makeSecurityHandler​(java.lang.String realm, org.eclipse.jetty.security.UserStore userStore, java.lang.String role, AuthScheme authMode)
      Create a Jetty SecurityHandler for basic authentication.
      static org.eclipse.jetty.security.ConstraintSecurityHandler makeSecurityHandler​(java.lang.String realm, org.eclipse.jetty.security.UserStore userStore, AuthScheme authMode)
      Create a Jetty SecurityHandler for basic authentication.
      static org.eclipse.jetty.security.SecurityHandler makeSecurityHandlerForPathspec​(java.lang.String pathSpec, java.lang.String realm, org.eclipse.jetty.security.UserStore userStore)
      Create a Jetty SecurityHandler for a specific pathSpace, e.g /database.
      static org.eclipse.jetty.security.UserStore makeUserStore​(java.lang.String passwordFile)
      Make a UserStore from a password file.
      static org.eclipse.jetty.security.UserStore makeUserStore​(java.lang.String user, java.lang.String password)
      Make a UserStore for a single user,password in any role.
      static org.eclipse.jetty.security.UserStore makeUserStore​(java.lang.String user, java.lang.String password, java.lang.String role)
      Make a UserStore for a single user,password,role
      static void setMimeTypes​(org.eclipse.jetty.servlet.ServletContextHandler context)
      Add the RDF MIME Type mappins
      static org.apache.http.impl.client.HttpClientBuilder trustLocalhostUnsigned()
      Create an HttpClientBuilder that trusts self-signed, localhost https connections.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • dftAuthMode

        public static final AuthScheme dftAuthMode
        Digest requires an extra round trip so it is unfriendly to API or scripts that stream.
      • authMode

        public static AuthScheme authMode
        Current auth mode
    • Constructor Detail

      • JettyLib

        public JettyLib()
    • Method Detail

      • makeSecurityHandlerForPathspec

        public static org.eclipse.jetty.security.SecurityHandler makeSecurityHandlerForPathspec​(java.lang.String pathSpec,
                                                                                                java.lang.String realm,
                                                                                                org.eclipse.jetty.security.UserStore userStore)
        Create a Jetty SecurityHandler for a specific pathSpace, e.g /database.
      • makeSecurityHandler

        public static org.eclipse.jetty.security.ConstraintSecurityHandler makeSecurityHandler​(java.lang.String realm,
                                                                                               org.eclipse.jetty.security.UserStore userStore)
        Create a Jetty SecurityHandler for basic authentication. See addPathConstraint(ConstraintSecurityHandler, String) for adding the pathspec to apply it to.
      • makeSecurityHandler

        public static org.eclipse.jetty.security.ConstraintSecurityHandler makeSecurityHandler​(java.lang.String realm,
                                                                                               org.eclipse.jetty.security.UserStore userStore,
                                                                                               AuthScheme authMode)
        Create a Jetty SecurityHandler for basic authentication. See addPathConstraint(ConstraintSecurityHandler, String) for adding the pathspec to apply it to.
      • makeSecurityHandler

        public static org.eclipse.jetty.security.ConstraintSecurityHandler makeSecurityHandler​(java.lang.String realm,
                                                                                               org.eclipse.jetty.security.UserStore userStore,
                                                                                               java.lang.String role,
                                                                                               AuthScheme authMode)
        Create a Jetty SecurityHandler for basic authentication. See addPathConstraint(ConstraintSecurityHandler, String) for adding the pathspec to apply it to.
      • addPathConstraint

        public static void addPathConstraint​(org.eclipse.jetty.security.ConstraintSecurityHandler securityHandler,
                                             java.lang.String pathSpec)
      • addPathConstraint

        public static void addPathConstraint​(org.eclipse.jetty.security.ConstraintSecurityHandler securityHandler,
                                             java.lang.String pathSpec,
                                             java.lang.String role)
      • makeUserStore

        public static org.eclipse.jetty.security.UserStore makeUserStore​(java.lang.String passwordFile)
        Make a UserStore from a password file. PropertyUserStore for details.
      • makeUserStore

        public static org.eclipse.jetty.security.UserStore makeUserStore​(java.lang.String user,
                                                                         java.lang.String password)
        Make a UserStore for a single user,password in any role.
      • makeUserStore

        public static org.eclipse.jetty.security.UserStore makeUserStore​(java.lang.String user,
                                                                         java.lang.String password,
                                                                         java.lang.String role)
        Make a UserStore for a single user,password,role
      • addUser

        public static org.eclipse.jetty.security.UserStore addUser​(org.eclipse.jetty.security.UserStore userStore,
                                                                   java.lang.String user,
                                                                   java.lang.String password)
      • addUser

        public static org.eclipse.jetty.security.UserStore addUser​(org.eclipse.jetty.security.UserStore userStore,
                                                                   java.lang.String user,
                                                                   java.lang.String password,
                                                                   java.lang.String role)
        Make a UserStore for a single user,password,role
      • addHandler

        public static void addHandler​(org.eclipse.jetty.server.Server server,
                                      org.eclipse.jetty.server.Handler handler)
        Add or append a Handler to a Jetty Server.
      • setMimeTypes

        public static void setMimeTypes​(org.eclipse.jetty.servlet.ServletContextHandler context)
        Add the RDF MIME Type mappins
      • httpConfiguration

        public static org.eclipse.jetty.server.HttpConfiguration httpConfiguration()
        HTTP configuration with setting for Fuseki workload. No "secure" settings.
      • trustLocalhostUnsigned

        public static org.apache.http.impl.client.HttpClientBuilder trustLocalhostUnsigned()
        Create an HttpClientBuilder that trusts self-signed, localhost https connections.