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     */
020    package org.apache.directory.server.kerberos.shared.messages.components;
021    
022    
023    import javax.security.auth.kerberos.KerberosPrincipal;
024    
025    import org.apache.directory.server.kerberos.shared.messages.value.AuthorizationData;
026    import org.apache.directory.server.kerberos.shared.messages.value.Checksum;
027    import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
028    import org.apache.directory.server.kerberos.shared.messages.value.KerberosPrincipalModifier;
029    import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
030    import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
031    
032    
033    /**
034     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035     * @version $Rev: 547131 $, $Date: 2007-06-14 07:41:06 +0200 (Thu, 14 Jun 2007) $
036     */
037    public class AuthenticatorModifier
038    {
039        private int versionNumber;
040        private KerberosPrincipalModifier clientModifier = new KerberosPrincipalModifier();
041        private KerberosPrincipal clientPrincipal;
042        private Checksum checksum;
043        private int clientMicroSecond;
044        private KerberosTime clientTime;
045        private EncryptionKey subSessionKey;
046        private int sequenceNumber;
047        private AuthorizationData authorizationData;
048    
049    
050        /**
051         * Returns the {@link Authenticator}.
052         *
053         * @return The {@link Authenticator}.
054         */
055        public Authenticator getAuthenticator()
056        {
057            if ( clientPrincipal == null )
058            {
059                clientPrincipal = clientModifier.getKerberosPrincipal();
060            }
061    
062            return new Authenticator( versionNumber, clientPrincipal, checksum, clientMicroSecond, clientTime,
063                subSessionKey, sequenceNumber, authorizationData );
064        }
065    
066    
067        /**
068         * Sets the version number.
069         *
070         * @param versionNumber
071         */
072        public void setVersionNumber( int versionNumber )
073        {
074            this.versionNumber = versionNumber;
075        }
076    
077    
078        /**
079         * Sets the client {@link PrincipalName}.
080         *
081         * @param name
082         */
083        public void setClientName( PrincipalName name )
084        {
085            clientModifier.setPrincipalName( name );
086        }
087    
088    
089        /**
090         * Sets the client realm.
091         *
092         * @param realm
093         */
094        public void setClientRealm( String realm )
095        {
096            clientModifier.setRealm( realm );
097        }
098    
099    
100        /**
101         * Sets the client {@link KerberosPrincipal}.
102         *
103         * @param clientPrincipal
104         */
105        public void setClientPrincipal( KerberosPrincipal clientPrincipal )
106        {
107            this.clientPrincipal = clientPrincipal;
108        }
109    
110    
111        /**
112         * Sets the {@link AuthorizationData}.
113         *
114         * @param data
115         */
116        public void setAuthorizationData( AuthorizationData data )
117        {
118            authorizationData = data;
119        }
120    
121    
122        /**
123         * Sets the {@link Checksum}.
124         *
125         * @param checksum
126         */
127        public void setChecksum( Checksum checksum )
128        {
129            this.checksum = checksum;
130        }
131    
132    
133        /**
134         * Sets the client microsecond.
135         *
136         * @param microSecond
137         */
138        public void setClientMicroSecond( int microSecond )
139        {
140            clientMicroSecond = microSecond;
141        }
142    
143    
144        /**
145         * Sets the client {@link KerberosTime}.
146         *
147         * @param time
148         */
149        public void setClientTime( KerberosTime time )
150        {
151            clientTime = time;
152        }
153    
154    
155        /**
156         * Sets the sequence number.
157         *
158         * @param number
159         */
160        public void setSequenceNumber( int number )
161        {
162            sequenceNumber = number;
163        }
164    
165    
166        /**
167         * Sets the sub-session {@link EncryptionKey}.
168         *
169         * @param sessionKey
170         */
171        public void setSubSessionKey( EncryptionKey sessionKey )
172        {
173            subSessionKey = sessionKey;
174        }
175    }