View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.security.jaspi;
20  
21  import java.util.Map;
22  
23  import javax.security.auth.Subject;
24  import javax.security.auth.message.AuthException;
25  import javax.security.auth.message.MessageInfo;
26  import javax.security.auth.message.config.ServerAuthConfig;
27  import javax.security.auth.message.config.ServerAuthContext;
28  
29  public class SimpleAuthConfig implements ServerAuthConfig
30  {
31      public static final String HTTP_SERVLET = "HttpServlet";
32  
33      private final String _appContext;
34  
35      private final ServerAuthContext _serverAuthContext;
36  
37      public SimpleAuthConfig(String appContext, ServerAuthContext serverAuthContext)
38      {
39          this._appContext = appContext;
40          this._serverAuthContext = serverAuthContext;
41      }
42  
43      public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException
44      {
45          return _serverAuthContext;
46      }
47  
48      // supposed to be of form host-name<space>context-path
49      public String getAppContext()
50      {
51          return _appContext;
52      }
53  
54      // not used yet
55      public String getAuthContextID(MessageInfo messageInfo) throws IllegalArgumentException
56      {
57          return null;
58      }
59  
60      public String getMessageLayer()
61      {
62          return HTTP_SERVLET;
63      }
64  
65      public boolean isProtected()
66      {
67          return true;
68      }
69  
70      public void refresh() 
71      {
72      }
73  }