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.value;
021    
022    
023    import java.util.Set;
024    
025    import javax.security.auth.kerberos.KerberosPrincipal;
026    
027    import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
028    import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
029    
030    
031    /**
032     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033     * @version $Rev: 590715 $, $Date: 2007-10-31 16:23:32 +0100 (Wed, 31 Oct 2007) $
034     */
035    public class RequestBodyModifier
036    {
037        private KerberosPrincipalModifier clientModifier = new KerberosPrincipalModifier(); //optional in TgsReq only
038        private KerberosPrincipalModifier serverModifier = new KerberosPrincipalModifier();
039        private KdcOptions kdcOptions;
040        private KerberosTime from; //optional
041        private KerberosTime till;
042        private KerberosTime rtime; //optional
043        private int nonce;
044        private Set<EncryptionType> eType;
045        private HostAddresses addresses; //optional
046        private EncryptedData encAuthorizationData; //optional
047        private Ticket[] additionalTickets; //optional
048    
049    
050        /**
051         * Returns the {@link RequestBody}.
052         *
053         * @return The {@link RequestBody}.
054         */
055        public RequestBody getRequestBody()
056        {
057            KerberosPrincipal clientPrincipal = clientModifier.getKerberosPrincipal();
058            KerberosPrincipal serverPrincipal = serverModifier.getKerberosPrincipal();
059    
060            return new RequestBody( kdcOptions, clientPrincipal, serverPrincipal, from, till, rtime, nonce, eType,
061                addresses, encAuthorizationData, additionalTickets );
062        }
063    
064    
065        /**
066         * Sets the client {@link PrincipalName}.
067         *
068         * @param clientName
069         */
070        public void setClientName( PrincipalName clientName )
071        {
072            clientModifier.setPrincipalName( clientName );
073        }
074    
075    
076        /**
077         * Sets the server {@link PrincipalName}.
078         *
079         * @param serverName
080         */
081        public void setServerName( PrincipalName serverName )
082        {
083            serverModifier.setPrincipalName( serverName );
084        }
085    
086    
087        /**
088         * Sets the realm.
089         *
090         * @param realm
091         */
092        public void setRealm( String realm )
093        {
094            clientModifier.setRealm( realm );
095            serverModifier.setRealm( realm );
096        }
097    
098    
099        /**
100         * Sets additional {@link Ticket}s.
101         *
102         * @param tickets
103         */
104        public void setAdditionalTickets( Ticket[] tickets )
105        {
106            additionalTickets = tickets;
107        }
108    
109    
110        /**
111         * Sets the {@link HostAddresses}.
112         *
113         * @param addresses
114         */
115        public void setAddresses( HostAddresses addresses )
116        {
117            this.addresses = addresses;
118        }
119    
120    
121        /**
122         * Sets the encrypted authorization data.
123         *
124         * @param authorizationData
125         */
126        public void setEncAuthorizationData( EncryptedData authorizationData )
127        {
128            encAuthorizationData = authorizationData;
129        }
130    
131    
132        /**
133         * Sets the requested {@link EncryptionType}s.
134         *
135         * @param type
136         */
137        public void setEType( Set<EncryptionType> type )
138        {
139            eType = type;
140        }
141    
142    
143        /**
144         * Sets the from {@link KerberosTime}.
145         *
146         * @param from
147         */
148        public void setFrom( KerberosTime from )
149        {
150            this.from = from;
151        }
152    
153    
154        /**
155         * Sets the {@link KdcOptions}.
156         *
157         * @param options
158         */
159        public void setKdcOptions( KdcOptions options )
160        {
161            kdcOptions = options;
162        }
163    
164    
165        /**
166         * Sets the nonce.
167         *
168         * @param nonce
169         */
170        public void setNonce( int nonce )
171        {
172            this.nonce = nonce;
173        }
174    
175    
176        /**
177         * Sets the "R" {@link KerberosTime}.
178         *
179         * @param rtime
180         */
181        public void setRtime( KerberosTime rtime )
182        {
183            this.rtime = rtime;
184        }
185    
186    
187        /**
188         * Sets the till {@link KerberosTime}.
189         *
190         * @param till
191         */
192        public void setTill( KerberosTime till )
193        {
194            this.till = till;
195        }
196    }