This project has retired. For details please refer to its Attic page.
DefaultSecuritySession xref
View Javadoc

1   package org.apache.archiva.redback.system;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.archiva.redback.users.User;
23  import org.apache.archiva.redback.authentication.AuthenticationResult;
24  import org.springframework.stereotype.Service;
25  
26  import java.io.Serializable;
27  
28  /**
29   * @author Jason van Zyl
30   */
31  @Service( "securitySession" )
32  public class DefaultSecuritySession
33      implements SecuritySession, Serializable
34  {
35      private AuthenticationResult authenticationResult;
36  
37      private User user;
38  
39      // TODO: ambiguity between this authenticated and authentication result's authenticated is dangerous
40      private boolean authenticated;
41  
42      public DefaultSecuritySession()
43      {
44          this.authenticationResult = new AuthenticationResult();
45          this.user = null;
46          this.authenticated = false;
47      }
48  
49      public DefaultSecuritySession( AuthenticationResult authResult )
50      {
51          this.authenticationResult = authResult;
52          this.user = null;
53          this.authenticated = false;
54      }
55  
56      public DefaultSecuritySession( AuthenticationResult authenticationResult, User user )
57      {
58          this.authenticationResult = authenticationResult;
59          this.user = user;
60          this.authenticated = true;
61      }
62  
63      public AuthenticationResult getAuthenticationResult()
64      {
65          return authenticationResult;
66      }
67  
68      public User getUser()
69      {
70          return user;
71      }
72  
73      public boolean isAuthenticated()
74      {
75          return ( ( user != null ) && authenticated );
76      }
77  }