View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.kerberos.credentials.cache;
21  
22  
23  import org.apache.directory.api.util.Base64;
24  
25  
26  /**
27   * This is a sample credentials cache generated using MIT KRB5 kinit command.
28   * SAMPLE_CACHE_CONTENT is the content of the sample cache encoded in base64.
29   * It's not just for unit test, but also for development, so better to maintain it here,
30   * instead of just as resource file.
31   * 
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public class SampleCredentialsCacheResource
35  {
36      /**
37       * klist
38       * Ticket cache: FILE:/tmp/krb5cc_0
39       * Default principal: apacheds@SH.INTEL.COM
40       *
41       * Valid starting     Expires            Service principal
42       * 09/06/13 01:54:10  09/06/13 11:54:10  krbtgt/SH.INTEL.COM@SH.INTEL.COM
43       * renew until 09/07/13 01:54:07
44       * 09/06/13 01:54:11  09/06/13 11:54:10  host/hadoop-nn.sh.intel.com@SH.INTEL.COM
45       * renew until 09/07/13 01:54:07
46       */
47      private static final String SAMPLE_CACHE_CONTENT = "BQQADAABAAgAAAAAAAAAAAAAAAEAAAABAAAADFNILklOVEVMLkNPTQAAAAhhcGFjaGVkcwAAAAEA"
48          +
49          "AAABAAAADFNILklOVEVMLkNPTQAAAAhhcGFjaGVkcwAAAAIAAAACAAAADFNILklOVEVMLkNPTQAA" +
50          "AAZrcmJ0Z3QAAAAMU0guSU5URUwuQ09NAAEAAAAI3H/4OE/NpCpSKGeiUihnolIo9EJSKbkfAEDh" +
51          "AAAAAAAAAAAAAAAAAUFhggE9MIIBOaADAgEFoQ4bDFNILklOVEVMLkNPTaIhMB+gAwIBAqEYMBYb" +
52          "BmtyYnRndBsMU0guSU5URUwuQ09No4H+MIH7oAMCARehAwIBAaKB7gSB6/v51fFhnp/E2uto2e9I" +
53          "9+RUk2grlKW9pYQUc4lAV602hdP6I80s1KU1rNtezbmf8plmxdZ48yogt0KwzAoGoFWCiZk4S1dR" +
54          "zzvl/TmNtk9q1gFuVycoP1EvScPYWhdTPAR4/t1Si1DKrYY19eegYmv6PfKoisdAADatLOjqJsVc" +
55          "Ntl/cUU4qUJfm181X1b+mguIdAX4jKzWbEc52pYQr8UIDl3TNT8OIzmQC0Wjn93ocOpKwOGsclbN" +
56          "OoxSfqpxvARjg+uE5HSm5tX7nUsccjhKMJ76Uy78CEULXkg6ySPYiim5wKVvgwxI7/AAAAAAAAAA" +
57          "AQAAAAEAAAAMU0guSU5URUwuQ09NAAAACGFwYWNoZWRzAAAAAAAAAAMAAAAMWC1DQUNIRUNPTkY6" +
58          "AAAAFWtyYjVfY2NhY2hlX2NvbmZfZGF0YQAAAApmYXN0X2F2YWlsAAAAIGtyYnRndC9TSC5JTlRF" +
59          "TC5DT01AU0guSU5URUwuQ09NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" +
60          "eWVzAAAAAAAAAAEAAAABAAAADFNILklOVEVMLkNPTQAAAAhhcGFjaGVkcwAAAAMAAAACAAAADFNI" +
61          "LklOVEVMLkNPTQAAAARob3N0AAAAFmhhZG9vcC1ubi5zaC5pbnRlbC5jb20AAQAAAAgsx5ub9wI0" +
62          "01IoZ6JSKGemUij0QlIpuR8AQKkAAAAAAAAAAAAAAAABX2GCAVswggFXoAMCAQWhDhsMU0guSU5U" +
63          "RUwuQ09NoikwJ6ADAgEDoSAwHhsEaG9zdBsWaGFkb29wLW5uLnNoLmludGVsLmNvbaOCARMwggEP" +
64          "oAMCARehAwIBB6KCAQEEgf7Z6Xz1bYJ9uE4e2Buyrp2aflcqgVoh9YUVAZyIiqpsrMa71wMuZFUl" +
65          "FD+S58Q3T39pZ9vIfXENNoKje1Y5kyImPHC1D/eHIeUN9v5kmDPJP9U31di8dOi3TbHUQWWLbB6k" +
66          "+uQE25GAP2hQg0vm5WtU3Fjo0ysXQTMpe+FSwe9ca9V3soPSbDhmlEt8WjAY05iXD8Fe6o/aY/PJ" +
67          "nElmCwQayRT87vENJI9LeMVEzhIjxBmg124G4nGnjUCaf++G03kJ04mLFZDB9kS8sA7V8AT1IF00" +
68          "ehpt7c9KbUM1Iz/S3Ni5hq8IfdOTSWMjGdNIsUMhJmivYFzQ0PRBzSBxbAAAAAA=";
69  
70      private static final String SAMPLE_PRINCIPAL = "apacheds";
71      private static final String SAMPLE_REALM = "SH.INTEL.COM";
72      private static final String[] SAMPLE_SERVERS = new String[]
73          { "krbtgt/SH.INTEL.COM", "host/hadoop-nn.sh.intel.com" };
74  
75  
76      public static byte[] getCacheContent()
77      {
78          return Base64.decode( SampleCredentialsCacheResource.SAMPLE_CACHE_CONTENT.toCharArray() );
79      }
80  
81  
82      /**
83       * @return the primary principal name contained in the sample cache
84       */
85      public static String getSamplePrincipal()
86      {
87          return SAMPLE_PRINCIPAL;
88      }
89  
90  
91      /**
92       * @return the realm contained in the sample cache
93       */
94      public static String getSampleRealm()
95      {
96          return SAMPLE_REALM;
97      }
98  
99  
100     /**
101      * Get the servers in the tickets contained in the sample cache
102      * 
103      * @return The sample servers
104      */
105     public static String[] getSampleServers()
106     {
107         return SAMPLE_SERVERS;
108     }
109 
110 
111     /**
112      * Get the tickets count in the sample cache
113      * 
114      * @return Always 2
115      */
116     public static int getSampleTicketsCount()
117     {
118         return 2;
119     }
120 }