blob: 9be21a2b861e80fd2acdb423339bdd6d5702a98c [file] [log] [blame]
/*
* 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.server.kerberos.kdc.authentication;
import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
import org.apache.directory.server.kerberos.shared.crypto.encryption.KeyUsage;
import org.apache.directory.server.kerberos.shared.messages.AuthServerReply;
import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
import org.apache.mina.common.IoSession;
import org.apache.mina.handler.chain.IoHandlerCommand;
/**
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class SealReply implements IoHandlerCommand
{
private String contextKey = "context";
public void execute( NextCommand next, IoSession session, Object message ) throws Exception
{
AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
AuthServerReply reply = ( AuthServerReply ) authContext.getReply();
EncryptionKey clientKey = authContext.getClientKey();
CipherTextHandler cipherTextHandler = authContext.getCipherTextHandler();
EncryptedData encryptedData = cipherTextHandler.seal( clientKey, reply, KeyUsage.NUMBER3 );
reply.setEncPart( encryptedData );
next.execute( session, message );
}
protected String getContextKey()
{
return ( this.contextKey );
}
}