TokenIterator.java
2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.NodeIterator
* javax.jcr.RepositoryException
*/
package com.day.crx.security.token.impl.helper;
import com.day.crx.security.token.impl.helper.Token;
import com.day.crx.security.token.impl.helper.TokenHelper;
import java.util.Iterator;
import java.util.NoSuchElementException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class TokenIterator
implements Iterator<Token> {
static final String NODE_TOKENS = ".tokens";
private final Node userNode;
private String userName;
private NodeIterator tokenNodes;
private Token nextToken;
public TokenIterator(Node userNode) {
this.userNode = userNode;
try {
if (userNode.hasNode(".tokens")) {
Node tokensNode = userNode.getNode(".tokens");
this.tokenNodes = tokensNode.getNodes();
this.nextToken = this.seek();
}
}
catch (RepositoryException re) {
// empty catch block
}
}
@Override
public boolean hasNext() {
return this.nextToken != null;
}
@Override
public Token next() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
Token result = this.nextToken;
this.nextToken = this.seek();
return result;
}
@Override
public void remove() {
throw new UnsupportedOperationException("remove");
}
public String getUserName() throws RepositoryException {
if (this.userName == null) {
this.userName = TokenHelper.getUserName(this.userNode);
}
return this.userName;
}
public String getUserIdentifier() throws RepositoryException {
return this.userNode.getIdentifier();
}
private Token seek() {
if (this.tokenNodes.hasNext()) {
return new Token(this.tokenNodes.nextNode());
}
return null;
}
}