]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.core/src/org/argeo/security/NodeAuthenticationToken.java
[maven-release-plugin] prepare release argeo-commons-2.1.12
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / security / NodeAuthenticationToken.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.security;
17
18 import org.springframework.security.GrantedAuthority;
19 import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
20
21 /** Credentials required for the authentication to a node. */
22 public class NodeAuthenticationToken extends
23 UsernamePasswordAuthenticationToken {
24 private static final long serialVersionUID = 1955222132884795213L;
25 private final String url;
26
27 /** Non authenticated local constructor */
28 public NodeAuthenticationToken(Object principal, Object credentials) {
29 super(principal, credentials);
30 this.url = null;
31 }
32
33 /** Non authenticated remote constructor */
34 public NodeAuthenticationToken(Object principal, Object credentials,
35 String url) {
36 super(principal, credentials);
37 this.url = url;
38 }
39
40 /** Authenticated constructor */
41 public NodeAuthenticationToken(NodeAuthenticationToken sat,
42 GrantedAuthority[] authorities) {
43 super(sat.getPrincipal(), sat.getCredentials(), authorities);
44 this.url = sat.getUrl();
45 }
46
47 public String getUrl() {
48 return url;
49 }
50
51 public Boolean isRemote() {
52 return url != null;
53 }
54 }