Class GlobusNamespacesParser
- java.lang.Object
-
- eu.emi.security.authn.x509.helpers.ns.GlobusNamespacesParser
-
- All Implemented Interfaces:
NamespacesParser
public class GlobusNamespacesParser extends java.lang.Object implements NamespacesParser
Parses a single .signing_policy file and returnsNamespacePolicy
object. Only the simplified parsing of the EACL format is implemented, in a similar way is in case of a native Globus implementation. However there are differences. First of all the format of this file is defined in a very imprecise way.The parsing is done in the following way:
- as a whitespace the space and tab characters are used; a separator may contain an arbitrary number of those, below only one space was used for clarity.
- all empty lines, whitespace only lines and lines beginning with '#' are ignored
- the first line like this is searched: access_id_CA X509 'ANY_STRING' other are ignored. Line with the access_id_CA prefix and other ending causes an error.
- after this line it is expected that the next significant line is : pos_rights globus CA:sign
- next the line in the format: cond_subjects globus '"ANY_STRING" ["ANY_STRING"]' is expected. The trailing string need not to be enclosed in '' and in "", but if it is then the order of quotation must be preserved.
- go to step 3.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GlobusNamespacesParser.InvalidPolicyFilenameException
static class
GlobusNamespacesParser.PolicySyntaxException
private static class
GlobusNamespacesParser.Token
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACCESS_ID_CA
static java.lang.String
CONDITION_SUBJECT
static java.lang.String
DEF_AUTH_GLOBUS
static java.lang.String
DEF_AUTH_X509
private java.lang.String
filePath
private java.lang.String
hash
private java.lang.String
issuer
static java.lang.String
NS_REGEXP
static java.lang.String
POS_RIGHTS
private java.util.List<NamespacePolicy>
ret
static java.lang.String
VALUE_CA_SIGN
-
Constructor Summary
Constructors Constructor Description GlobusNamespacesParser(java.lang.String filePath)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addPermitted(java.lang.String permitted)
private int
eatSpaces(char[] string, int offset, boolean atLeastOne)
private int
getQuoted(char[] string, int offset, char quoteChar, java.lang.StringBuilder ret)
private void
handleAuthEntry(java.lang.String line, java.io.BufferedReader reader)
private void
handleCABlock(java.lang.String line, java.io.BufferedReader reader)
private void
handlePermitEntry(java.lang.String line, java.io.BufferedReader reader)
private boolean
isValid(java.lang.String line)
static java.lang.String
makeRegexpClassicWildcard(java.lang.String pattern)
Converts wildcard string to Java regexp, ensuring that literal sequences are correctly escaped.static java.lang.String
normalize(java.lang.String dn)
java.util.List<NamespacePolicy>
parse()
private GlobusNamespacesParser.Token
parseNextTokenUntil(char[] string, int offset, char delimiter)
-
-
-
Field Detail
-
ACCESS_ID_CA
public static java.lang.String ACCESS_ID_CA
-
DEF_AUTH_X509
public static java.lang.String DEF_AUTH_X509
-
DEF_AUTH_GLOBUS
public static java.lang.String DEF_AUTH_GLOBUS
-
POS_RIGHTS
public static java.lang.String POS_RIGHTS
-
CONDITION_SUBJECT
public static java.lang.String CONDITION_SUBJECT
-
VALUE_CA_SIGN
public static java.lang.String VALUE_CA_SIGN
-
NS_REGEXP
public static final java.lang.String NS_REGEXP
- See Also:
- Constant Field Values
-
filePath
private java.lang.String filePath
-
hash
private java.lang.String hash
-
issuer
private java.lang.String issuer
-
ret
private java.util.List<NamespacePolicy> ret
-
-
Method Detail
-
parse
public java.util.List<NamespacePolicy> parse() throws java.io.IOException
- Specified by:
parse
in interfaceNamespacesParser
- Throws:
java.io.IOException
-
handleCABlock
private void handleCABlock(java.lang.String line, java.io.BufferedReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
handleAuthEntry
private void handleAuthEntry(java.lang.String line, java.io.BufferedReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
handlePermitEntry
private void handlePermitEntry(java.lang.String line, java.io.BufferedReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
addPermitted
private void addPermitted(java.lang.String permitted) throws java.io.IOException
- Throws:
java.io.IOException
-
getQuoted
private int getQuoted(char[] string, int offset, char quoteChar, java.lang.StringBuilder ret) throws java.io.IOException
- Throws:
java.io.IOException
-
isValid
private boolean isValid(java.lang.String line)
-
eatSpaces
private int eatSpaces(char[] string, int offset, boolean atLeastOne) throws java.io.IOException
- Throws:
java.io.IOException
-
parseNextTokenUntil
private GlobusNamespacesParser.Token parseNextTokenUntil(char[] string, int offset, char delimiter) throws GlobusNamespacesParser.PolicySyntaxException
-
normalize
public static java.lang.String normalize(java.lang.String dn)
-
makeRegexpClassicWildcard
public static java.lang.String makeRegexpClassicWildcard(java.lang.String pattern)
Converts wildcard string to Java regexp, ensuring that literal sequences are correctly escaped.- Parameters:
pattern
- input wildcard- Returns:
- Java regular expression
-
-