2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.security
;
18 import java
.util
.Collection
;
20 import org
.springframework
.security
.authentication
.UsernamePasswordAuthenticationToken
;
21 import org
.springframework
.security
.core
.GrantedAuthority
;
23 /** Credentials required for the authentication to a node. */
24 public class NodeAuthenticationToken
extends
25 UsernamePasswordAuthenticationToken
{
26 private static final long serialVersionUID
= 1955222132884795213L;
27 private final String url
;
29 /** Non authenticated local constructor */
30 public NodeAuthenticationToken(Object principal
, Object credentials
) {
31 super(principal
, credentials
);
35 /** Non authenticated remote constructor */
36 public NodeAuthenticationToken(Object principal
, Object credentials
,
38 super(principal
, credentials
);
42 /** Authenticated constructor */
43 public NodeAuthenticationToken(NodeAuthenticationToken sat
,
44 Collection
<?
extends GrantedAuthority
> authorities
) {
45 super(sat
.getPrincipal(), sat
.getCredentials(), authorities
);
46 this.url
= sat
.getUrl();
49 public String
getUrl() {
53 public Boolean
isRemote() {
57 public String
toString() {
58 String username
= getName();
59 StringBuilder buf
= new StringBuilder("groups=");
60 for (GrantedAuthority ga
: getAuthorities()) {
61 if (!ga
.getAuthority().equals(username
)) {
62 buf
.append(ga
.getAuthority());
66 buf
.deleteCharAt(buf
.length() - 1);
67 return "uid=" + getName() + " " + buf
.toString();