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.server.kerberos.kdc.authentication;
021
022
023import org.apache.directory.server.kerberos.kdc.KdcContext;
024import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
025import org.apache.directory.shared.kerberos.components.EncryptionKey;
026import org.apache.directory.shared.kerberos.messages.Ticket;
027
028
029/**
030 * A context used to store and manage Authentication elements
031 * 
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 */
034public class AuthenticationContext extends KdcContext
035{
036    private static final long serialVersionUID = -2249170923251265359L;
037
038    /** The Kerberos Ticket associated to this context */
039    private Ticket ticket;
040
041    /** The client key */
042    private EncryptionKey clientKey;
043
044    /** The client entry */
045    private PrincipalStoreEntry clientEntry;
046
047    /** The server entry */
048    private PrincipalStoreEntry serverEntry;
049
050    /** Tell if we have had a pre-authentication */
051    private boolean isPreAuthenticated;
052
053
054    /**
055     * @return Returns the serverEntry.
056     */
057    public PrincipalStoreEntry getServerEntry()
058    {
059        return serverEntry;
060    }
061
062
063    /**
064     * @param serverEntry The serverEntry to set.
065     */
066    public void setServerEntry( PrincipalStoreEntry serverEntry )
067    {
068        this.serverEntry = serverEntry;
069    }
070
071
072    /**
073     * @return Returns the clientEntry.
074     */
075    public PrincipalStoreEntry getClientEntry()
076    {
077        return clientEntry;
078    }
079
080
081    /**
082     * @param clientEntry The clientEntry to set.
083     */
084    public void setClientEntry( PrincipalStoreEntry clientEntry )
085    {
086        this.clientEntry = clientEntry;
087    }
088
089
090    /**
091     * @return Returns the checksumEngines.
092     *
093    public Map getChecksumEngines()
094    {
095        return checksumEngines;
096    }
097    */
098
099    /**
100     * @param checksumEngines The checksumEngines to set.
101     *
102    public void setChecksumEngines( Map checksumEngines )
103    {
104        this.checksumEngines = checksumEngines;
105    }
106    */
107
108    /**
109     * @return Returns the clientKey.
110     */
111    public EncryptionKey getClientKey()
112    {
113        return clientKey;
114    }
115
116
117    /**
118     * @param clientKey The clientKey to set.
119     */
120    public void setClientKey( EncryptionKey clientKey )
121    {
122        this.clientKey = clientKey;
123    }
124
125
126    /**
127     * @return Returns the ticket.
128     */
129    public Ticket getTicket()
130    {
131        return ticket;
132    }
133
134
135    /**
136     * @param ticket The ticket to set.
137     */
138    public void setTicket( Ticket ticket )
139    {
140        this.ticket = ticket;
141    }
142
143
144    /**
145     * @return true if the client used pre-authentication.
146     */
147    public boolean isPreAuthenticated()
148    {
149        return isPreAuthenticated;
150    }
151
152
153    /**
154     * @param isPreAuthenticated Whether the client used pre-authentication.
155     */
156    public void setPreAuthenticated( boolean isPreAuthenticated )
157    {
158        this.isPreAuthenticated = isPreAuthenticated;
159    }
160
161
162    /**
163     * @see Object#toString()
164     */
165    @Override
166    public String toString()
167    {
168        StringBuilder sb = new StringBuilder();
169
170        sb.append( "AuthenticationContext \n" );
171        sb.append( super.toString() ).append( '\n' );
172        sb.append( "PreAuth : " ).append( isPreAuthenticated ).append( "\n" );
173        sb.append( "Client Entry : " ).append( clientEntry ).append( "\n" );
174
175        return sb.toString();
176    }
177}