Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
- package org.apache.directory.kerberos.client;
- import java.io.File;
- import java.util.Collections;
- import org.apache.directory.server.kerberos.shared.keytab.Keytab;
- import org.apache.directory.server.kerberos.shared.keytab.KeytabEntry;
- import org.apache.directory.shared.kerberos.KerberosTime;
- import org.apache.directory.shared.kerberos.codec.types.PrincipalNameType;
- /**
- * Creates a Keytab from the TgTicket.
- *
- * @author <a href="mailto:kayyagari@keydap.com">Kiran Ayyagari</a>
- */
- public class KeytabMaker
- {
- public static void main( String[] args ) throws Exception
- {
- KdcConfig config = new KdcConfig();
- config.setKdcPort( 60088 );
- KdcConnection kdcCon = new KdcConnection( config );
- TgTicket tgt = kdcCon.getTgt( "hnelson@EXAMPLE.COM", "secret" );
- Keytab kt = new Keytab();
- KeytabEntry ke = new KeytabEntry( tgt.getClientName()+"@"+tgt.getRealm(), PrincipalNameType.KRB_NT_PRINCIPAL.getValue(),
- new KerberosTime( tgt.getStartTime() ), (byte)tgt.getSessionKey().getKeyVersion(), tgt.getSessionKey() );
- kt.setEntries( Collections.singletonList( ke ) );
- kt.write( new File("/tmp/apachedskeytab") );
- // KeytabEncoder encoder = new KeytabEncoder();
- // ByteBuffer buf = encoder.write( kt.getKeytabVersion(), kt.getEntries() );
- // System.out.println(Strings.dumpBytes( buf.array() ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement