Revision 0d0522eb
Added by Andreas Kohlbecker over 6 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/permission/CdmAuthority.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
23 | 23 |
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl; |
24 |
import sun.security.provider.PolicyParser.ParsingException; |
|
25 | 24 |
|
26 | 25 |
/** |
27 | 26 |
* A <code>CdmAuthority</code> consists basically of two parts which are separated |
... | ... | |
125 | 124 |
} |
126 | 125 |
} |
127 | 126 |
|
128 |
private CdmAuthority (String authority) throws ParsingException{ |
|
127 |
private CdmAuthority (String authority) throws CdmAuthorityParsingException{
|
|
129 | 128 |
|
130 | 129 |
String[] tokens = parse(authority); |
131 | 130 |
// className must never be null |
... | ... | |
133 | 132 |
try { |
134 | 133 |
permissionClass = CdmPermissionClass.valueOf(tokens[0]); |
135 | 134 |
} catch (IllegalArgumentException e) { |
136 |
throw new ParsingException(authority); |
|
135 |
throw new CdmAuthorityParsingException(authority);
|
|
137 | 136 |
} |
138 | 137 |
property = tokens[1]; |
139 | 138 |
|
... | ... | |
142 | 141 |
operation = Operation.fromString(tokens[2]); |
143 | 142 |
} catch (IllegalArgumentException e) { |
144 | 143 |
logger.warn("cannot parse Operation " + tokens[2]); |
145 |
throw new ParsingException(authority); |
|
144 |
throw new CdmAuthorityParsingException(authority);
|
|
146 | 145 |
} |
147 | 146 |
} |
148 | 147 |
if(tokens[3] != null){ |
... | ... | |
190 | 189 |
* </ol> |
191 | 190 |
* @param authority |
192 | 191 |
* @return an array of tokens |
193 |
* @throws ParsingException |
|
192 |
* @throws CdmAuthorityParsingException
|
|
194 | 193 |
*/ |
195 |
protected String[] parse(String authority) throws ParsingException { |
|
194 |
protected String[] parse(String authority) throws CdmAuthorityParsingException {
|
|
196 | 195 |
// |
197 | 196 |
// regex pattern explained: |
198 | 197 |
// (\\w*) -> classname |
... | ... | |
217 | 216 |
} |
218 | 217 |
} else { |
219 | 218 |
logger.debug("no match"); |
220 |
throw new ParsingException("Unsupported authority string: '" + authority + "'"); |
|
219 |
throw new CdmAuthorityParsingException("Unsupported authority string: '" + authority + "'");
|
|
221 | 220 |
} |
222 | 221 |
|
223 | 222 |
return tokens; |
... | ... | |
267 | 266 |
* instances per <code>GrantedAuthority</code> string in a map. |
268 | 267 |
* |
269 | 268 |
* @param authority |
270 |
* @throws ParsingException |
|
269 |
* @throws CdmAuthorityParsingException
|
|
271 | 270 |
*/ |
272 |
public static CdmAuthority fromGrantedAuthority(GrantedAuthority authority) throws ParsingException { |
|
271 |
public static CdmAuthority fromGrantedAuthority(GrantedAuthority authority) throws CdmAuthorityParsingException {
|
|
273 | 272 |
CdmAuthority cdmAuthority = grantedAuthorityCache.get(authority.getAuthority()); |
274 | 273 |
if(cdmAuthority == null){ |
275 | 274 |
cdmAuthority = new CdmAuthority(authority.getAuthority()); |
... | ... | |
280 | 279 |
|
281 | 280 |
|
282 | 281 |
@Override |
283 |
public GrantedAuthorityImpl asNewGrantedAuthority() throws ParsingException { |
|
282 |
public GrantedAuthorityImpl asNewGrantedAuthority() throws CdmAuthorityParsingException {
|
|
284 | 283 |
GrantedAuthorityImpl grantedAuthority = GrantedAuthorityImpl.NewInstance(getAuthority()); |
285 | 284 |
return grantedAuthority; |
286 | 285 |
} |
287 | 286 |
|
288 | 287 |
|
289 |
|
|
290 | 288 |
} |
Also available in: Unified diff
intoducing CdmAuthorityParsingException to avoid invalid use of non api sun.security.provider.PolicyParser.ParsingException