View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.kerberos.shared.messages.components;
21  
22  
23  import javax.security.auth.kerberos.KerberosPrincipal;
24  
25  import org.apache.directory.server.kerberos.shared.messages.value.AuthorizationData;
26  import org.apache.directory.server.kerberos.shared.messages.value.Checksum;
27  import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
28  import org.apache.directory.server.kerberos.shared.messages.value.KerberosPrincipalModifier;
29  import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
30  import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
31  
32  
33  /**
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   * @version $Rev: 547131 $, $Date: 2007-06-14 07:41:06 +0200 (Do, 14 Jun 2007) $
36   */
37  public class AuthenticatorModifier
38  {
39      private int versionNumber;
40      private KerberosPrincipalModifier clientModifier = new KerberosPrincipalModifier();
41      private KerberosPrincipal clientPrincipal;
42      private Checksum checksum;
43      private int clientMicroSecond;
44      private KerberosTime clientTime;
45      private EncryptionKey subSessionKey;
46      private int sequenceNumber;
47      private AuthorizationData authorizationData;
48  
49  
50      /**
51       * Returns the {@link Authenticator}.
52       *
53       * @return The {@link Authenticator}.
54       */
55      public Authenticator getAuthenticator()
56      {
57          if ( clientPrincipal == null )
58          {
59              clientPrincipal = clientModifier.getKerberosPrincipal();
60          }
61  
62          return new Authenticator( versionNumber, clientPrincipal, checksum, clientMicroSecond, clientTime,
63              subSessionKey, sequenceNumber, authorizationData );
64      }
65  
66  
67      /**
68       * Sets the version number.
69       *
70       * @param versionNumber
71       */
72      public void setVersionNumber( int versionNumber )
73      {
74          this.versionNumber = versionNumber;
75      }
76  
77  
78      /**
79       * Sets the client {@link PrincipalName}.
80       *
81       * @param name
82       */
83      public void setClientName( PrincipalName name )
84      {
85          clientModifier.setPrincipalName( name );
86      }
87  
88  
89      /**
90       * Sets the client realm.
91       *
92       * @param realm
93       */
94      public void setClientRealm( String realm )
95      {
96          clientModifier.setRealm( realm );
97      }
98  
99  
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 }