-
Notifications
You must be signed in to change notification settings - Fork 785
using authorization stacks instead of a list #1525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
328aa85
using authorization stacks instead of a list
tulinkry 3fe807e
role -> flag globally
tulinkry 6b0b10f
always invoke the set plugin method
tulinkry 807497f
do not share instances of plugins in the stack
tulinkry 29b3e55
documenting the authorization classes
tulinkry 8b1918b
fixing javadoc
tulinkry 18c99e4
ensuring thread safe framework reload
tulinkry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/org/opensolaris/opengrok/authorization/AuthControlFlag.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* CDDL HEADER START | ||
* | ||
* The contents of this file are subject to the terms of the | ||
* Common Development and Distribution License (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* See LICENSE.txt included in this distribution for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing Covered Code, include this CDDL HEADER in each | ||
* file and include the License file at LICENSE.txt. | ||
* If applicable, add the following below this CDDL HEADER, with the | ||
* fields enclosed by brackets "[]" replaced with your own identifying | ||
* information: Portions Copyright [yyyy] [name of copyright owner] | ||
* | ||
* CDDL HEADER END | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. | ||
*/ | ||
package org.opensolaris.opengrok.authorization; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Enum for avaliable authorization roles. | ||
* | ||
* @author Krystof Tulinger | ||
*/ | ||
public enum AuthControlFlag { | ||
/** | ||
* Failure of such a plugin will ultimately lead to the authorization | ||
* framework returning failure but only after the remaining plugins have | ||
* been invoked. | ||
* | ||
*/ | ||
REQUIRED("required"), | ||
/** | ||
* Like required, however, in the case that such a plugin returns a failure, | ||
* control is directly returned to the application. The return value is that | ||
* associated with the first required or requisite plugin to fail. | ||
* | ||
*/ | ||
REQUISITE("requisite"), | ||
/** | ||
* If such a plugin succeeds and no prior required plugin has failed the | ||
* authorization framework returns success to the application immediately | ||
* without calling any further plugins in the stack. A failure of a | ||
* sufficient plugin is ignored and processing of the plugin list continues | ||
* unaffected. | ||
*/ | ||
SUFFICIENT("sufficient"); | ||
|
||
private final String flag; | ||
|
||
private AuthControlFlag(String flag) { | ||
this.flag = flag; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.flag; | ||
} | ||
|
||
public boolean isRequired() { | ||
return REQUIRED.equals(this); | ||
} | ||
|
||
public boolean isRequisite() { | ||
return REQUISITE.equals(this); | ||
} | ||
|
||
public boolean isSufficient() { | ||
return SUFFICIENT.equals(this); | ||
} | ||
|
||
/** | ||
* Get the enum value for the string parameter. | ||
* | ||
* @param flag parameter describing the desired enum value | ||
* @return the flag representing the parameter value | ||
* | ||
* @throws IllegalArgumentException when there is no such value in the enum | ||
*/ | ||
public static AuthControlFlag get(String flag) throws IllegalArgumentException { | ||
try { | ||
return AuthControlFlag.valueOf(flag.toUpperCase()); | ||
} catch (IllegalArgumentException ex) { | ||
// flag does not exist -> add some more info about which flags do exist | ||
throw new IllegalArgumentException( | ||
String.format("No control flag \"%s\", available flags are [%s]. %s", | ||
flag, | ||
Arrays.asList(AuthControlFlag.values()) | ||
.stream() | ||
.map(AuthControlFlag::toString) | ||
.collect(Collectors.joining(", ")), | ||
ex.getLocalizedMessage()), ex); | ||
} | ||
} | ||
} |
155 changes: 0 additions & 155 deletions
155
src/org/opensolaris/opengrok/authorization/AuthorizationCheck.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is refactored from the
AuthorizationCheck.java
class