View Javadoc
1   /*
2    * Copyright 2012-2017 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.helper;
17  
18  import javax.annotation.PostConstruct;
19  
20  import org.codelibs.fess.mylasta.direction.FessConfig;
21  import org.codelibs.fess.util.ComponentUtil;
22  
23  import jcifs.smb.SID;
24  
25  public class SambaHelper {
26  
27      public static final int SID_TYPE_ALIAS = 4;
28  
29      public static final int SID_TYPE_DELETED = 6;
30  
31      public static final int SID_TYPE_DOM_GRP = 2;
32  
33      public static final int SID_TYPE_DOMAIN = 3;
34  
35      public static final int SID_TYPE_INVALID = 7;
36  
37      public static final int SID_TYPE_UNKNOWN = 8;
38  
39      public static final int SID_TYPE_USE_NONE = 0;
40  
41      public static final int SID_TYPE_USER = 1;
42  
43      public static final int SID_TYPE_WKN_GRP = 5;
44  
45      private FessConfig fessConfig;
46  
47      @PostConstruct
48      public void init() {
49          fessConfig = ComponentUtil.getFessConfig();
50      }
51  
52      public String getAccountId(final SID sid) {
53          if (fessConfig.isAvailableSmbSidType(sid.getType())) {
54              return createSearchRole(sid.getType(), sid.getAccountName());
55          }
56          return null;
57      }
58  
59      protected String createSearchRole(final int type, final String name) {
60          return type + name;
61      }
62  }