001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.kerberos.credentials.cache; 021 022 023import org.apache.directory.api.util.Base64; 024 025 026/** 027 * This is a sample credentials cache generated using MIT KRB5 kinit command. 028 * SAMPLE_CACHE_CONTENT is the content of the sample cache encoded in base64. 029 * It's not just for unit test, but also for development, so better to maintain it here, 030 * instead of just as resource file. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public class SampleCredentialsCacheResource 035{ 036 /** 037 * klist 038 * Ticket cache: FILE:/tmp/krb5cc_0 039 * Default principal: apacheds@SH.INTEL.COM 040 * 041 * Valid starting Expires Service principal 042 * 09/06/13 01:54:10 09/06/13 11:54:10 krbtgt/SH.INTEL.COM@SH.INTEL.COM 043 * renew until 09/07/13 01:54:07 044 * 09/06/13 01:54:11 09/06/13 11:54:10 host/hadoop-nn.sh.intel.com@SH.INTEL.COM 045 * renew until 09/07/13 01:54:07 046 */ 047 private static final String SAMPLE_CACHE_CONTENT = "BQQADAABAAgAAAAAAAAAAAAAAAEAAAABAAAADFNILklOVEVMLkNPTQAAAAhhcGFjaGVkcwAAAAEA" 048 + 049 "AAABAAAADFNILklOVEVMLkNPTQAAAAhhcGFjaGVkcwAAAAIAAAACAAAADFNILklOVEVMLkNPTQAA" + 050 "AAZrcmJ0Z3QAAAAMU0guSU5URUwuQ09NAAEAAAAI3H/4OE/NpCpSKGeiUihnolIo9EJSKbkfAEDh" + 051 "AAAAAAAAAAAAAAAAAUFhggE9MIIBOaADAgEFoQ4bDFNILklOVEVMLkNPTaIhMB+gAwIBAqEYMBYb" + 052 "BmtyYnRndBsMU0guSU5URUwuQ09No4H+MIH7oAMCARehAwIBAaKB7gSB6/v51fFhnp/E2uto2e9I" + 053 "9+RUk2grlKW9pYQUc4lAV602hdP6I80s1KU1rNtezbmf8plmxdZ48yogt0KwzAoGoFWCiZk4S1dR" + 054 "zzvl/TmNtk9q1gFuVycoP1EvScPYWhdTPAR4/t1Si1DKrYY19eegYmv6PfKoisdAADatLOjqJsVc" + 055 "Ntl/cUU4qUJfm181X1b+mguIdAX4jKzWbEc52pYQr8UIDl3TNT8OIzmQC0Wjn93ocOpKwOGsclbN" + 056 "OoxSfqpxvARjg+uE5HSm5tX7nUsccjhKMJ76Uy78CEULXkg6ySPYiim5wKVvgwxI7/AAAAAAAAAA" + 057 "AQAAAAEAAAAMU0guSU5URUwuQ09NAAAACGFwYWNoZWRzAAAAAAAAAAMAAAAMWC1DQUNIRUNPTkY6" + 058 "AAAAFWtyYjVfY2NhY2hlX2NvbmZfZGF0YQAAAApmYXN0X2F2YWlsAAAAIGtyYnRndC9TSC5JTlRF" + 059 "TC5DT01AU0guSU5URUwuQ09NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + 060 "eWVzAAAAAAAAAAEAAAABAAAADFNILklOVEVMLkNPTQAAAAhhcGFjaGVkcwAAAAMAAAACAAAADFNI" + 061 "LklOVEVMLkNPTQAAAARob3N0AAAAFmhhZG9vcC1ubi5zaC5pbnRlbC5jb20AAQAAAAgsx5ub9wI0" + 062 "01IoZ6JSKGemUij0QlIpuR8AQKkAAAAAAAAAAAAAAAABX2GCAVswggFXoAMCAQWhDhsMU0guSU5U" + 063 "RUwuQ09NoikwJ6ADAgEDoSAwHhsEaG9zdBsWaGFkb29wLW5uLnNoLmludGVsLmNvbaOCARMwggEP" + 064 "oAMCARehAwIBB6KCAQEEgf7Z6Xz1bYJ9uE4e2Buyrp2aflcqgVoh9YUVAZyIiqpsrMa71wMuZFUl" + 065 "FD+S58Q3T39pZ9vIfXENNoKje1Y5kyImPHC1D/eHIeUN9v5kmDPJP9U31di8dOi3TbHUQWWLbB6k" + 066 "+uQE25GAP2hQg0vm5WtU3Fjo0ysXQTMpe+FSwe9ca9V3soPSbDhmlEt8WjAY05iXD8Fe6o/aY/PJ" + 067 "nElmCwQayRT87vENJI9LeMVEzhIjxBmg124G4nGnjUCaf++G03kJ04mLFZDB9kS8sA7V8AT1IF00" + 068 "ehpt7c9KbUM1Iz/S3Ni5hq8IfdOTSWMjGdNIsUMhJmivYFzQ0PRBzSBxbAAAAAA="; 069 070 private static final String SAMPLE_PRINCIPAL = "apacheds"; 071 private static final String SAMPLE_REALM = "SH.INTEL.COM"; 072 private static final String[] SAMPLE_SERVERS = new String[] 073 { "krbtgt/SH.INTEL.COM", "host/hadoop-nn.sh.intel.com" }; 074 075 076 public static byte[] getCacheContent() 077 { 078 return Base64.decode( SampleCredentialsCacheResource.SAMPLE_CACHE_CONTENT.toCharArray() ); 079 } 080 081 082 /** 083 * @return the primary principal name contained in the sample cache 084 */ 085 public static String getSamplePrincipal() 086 { 087 return SAMPLE_PRINCIPAL; 088 } 089 090 091 /** 092 * @return the realm contained in the sample cache 093 */ 094 public static String getSampleRealm() 095 { 096 return SAMPLE_REALM; 097 } 098 099 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}