Adding support for explicitly configuring policySets
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@797356 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
99924a5a8d
commit
d7899fb929
2 changed files with 176 additions and 73 deletions
|
@ -68,57 +68,111 @@ public class LDAPRealmAuthenticationImplementationPolicyProvider implements Poli
|
|||
*/
|
||||
private List<LDAPRealmAuthenticationPolicy> findAuthenticationPolicies(Operation op) {
|
||||
List<LDAPRealmAuthenticationPolicy> polices = new ArrayList<LDAPRealmAuthenticationPolicy>();
|
||||
if (implementation instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop != null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (LDAPRealmAuthenticationPolicy.class.isInstance(p)) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check explicity added policies first
|
||||
ConfiguredOperation configuredOperation = findOperation(op);
|
||||
if (configuredOperation!= null && configuredOperation.getPolicySets().size() > 0) {
|
||||
for ( PolicySet ps : configuredOperation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof LDAPRealmAuthenticationPolicy) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = component.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (LDAPRealmAuthenticationPolicy.class.isInstance(p)) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
// otherwise find applicable policySets
|
||||
if ( polices.size() == 0) {
|
||||
|
||||
if (implementation instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop != null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (LDAPRealmAuthenticationPolicy.class.isInstance(p)) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = component.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (LDAPRealmAuthenticationPolicy.class.isInstance(p)) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return polices;
|
||||
}
|
||||
|
||||
private List<AuthorizationPolicy> findAuthorizationPolicies(Operation op) {
|
||||
List<AuthorizationPolicy> polices = new ArrayList<AuthorizationPolicy>();
|
||||
if (implementation instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop != null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (AuthorizationPolicy.class.isInstance(p)) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check explicity added policies first
|
||||
ConfiguredOperation configuredOperation = findOperation(op);
|
||||
if (configuredOperation!= null && configuredOperation.getPolicySets().size() > 0) {
|
||||
for ( PolicySet ps : configuredOperation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof AuthorizationPolicy) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = component.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (AuthorizationPolicy.class.isInstance(p)) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
// otherwise find applicable policySets
|
||||
if ( polices.size() == 0) {
|
||||
|
||||
if (implementation instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop != null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (AuthorizationPolicy.class.isInstance(p)) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = component.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (AuthorizationPolicy.class.isInstance(p)) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return polices;
|
||||
}
|
||||
|
||||
|
||||
private ConfiguredOperation findOperation(Operation operation) {
|
||||
ConfiguredOperation configuredOperation = null;
|
||||
|
||||
for (ConfiguredOperation cOperation : ((OperationsConfigurator)component).getConfiguredOperations()) {
|
||||
if(cOperation.getName().equals(operation.getName())) {
|
||||
configuredOperation = cOperation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return configuredOperation;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,45 +81,64 @@ public class LDAPRealmAuthenticationServicePolicyProvider implements PolicyProvi
|
|||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Find applicable authorization policySets
|
||||
* It first check if any explicitly policySet was identified
|
||||
* Otherwise it look into the list of applicablePolicySets
|
||||
* @param op
|
||||
* @return
|
||||
*/
|
||||
private List<LDAPRealmAuthenticationPolicy> findAuthenticationPolicies(Operation op) {
|
||||
List<LDAPRealmAuthenticationPolicy> polices = new ArrayList<LDAPRealmAuthenticationPolicy>();
|
||||
// FIXME: How do we get a list of effective policySets for a given operation?
|
||||
for(Operation operation : operations) {
|
||||
if (operation!= null && operation.getName() != null && operation.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : operation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (LDAPRealmAuthenticationPolicy.class.isInstance(p)) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
|
||||
// check explicity added policies first
|
||||
ConfiguredOperation configuredOperation = findOperation(op);
|
||||
if (configuredOperation!= null && configuredOperation.getPolicySets().size() > 0) {
|
||||
for ( PolicySet ps : configuredOperation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof LDAPRealmAuthenticationPolicy) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (service instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)service;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop!= null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getApplicablePolicySets()) {
|
||||
|
||||
// otherwise find applicable policySets
|
||||
if ( polices.size() == 0) {
|
||||
// FIXME: How do we get a list of effective policySets for a given operation?
|
||||
for(Operation operation : operations) {
|
||||
if (operation!= null && operation.getName() != null && operation.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : operation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (LDAPRealmAuthenticationPolicy.class.isInstance(p)) {
|
||||
if (p instanceof LDAPRealmAuthenticationPolicy) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = service.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (LDAPRealmAuthenticationPolicy.class.isInstance(p)) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
if (service instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)service;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop!= null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getApplicablePolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof LDAPRealmAuthenticationPolicy) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = service.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof LDAPRealmAuthenticationPolicy) {
|
||||
polices.add((LDAPRealmAuthenticationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,50 +147,80 @@ public class LDAPRealmAuthenticationServicePolicyProvider implements PolicyProvi
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Find applicable authorization policySets
|
||||
* It first check if any explicitly policySet was identified
|
||||
* Otherwise it look into the list of applicablePolicySets
|
||||
* @param op
|
||||
* @return
|
||||
*/
|
||||
private List<AuthorizationPolicy> findAuthorizationPolicies(Operation op) {
|
||||
List<AuthorizationPolicy> polices = new ArrayList<AuthorizationPolicy>();
|
||||
// FIXME: How do we get a list of effective policySets for a given operation?
|
||||
for(Operation operation : operations) {
|
||||
if (operation!= null && operation.getName() != null && operation.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : operation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (AuthorizationPolicy.class.isInstance(p)) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
|
||||
// check explicity added policies first
|
||||
ConfiguredOperation configuredOperation = findOperation(op);
|
||||
if (configuredOperation!= null && configuredOperation.getPolicySets().size() > 0) {
|
||||
for ( PolicySet ps : configuredOperation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof AuthorizationPolicy) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (service instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)service;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop != null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getApplicablePolicySets()) {
|
||||
|
||||
// otherwise find applicable policySets
|
||||
if ( polices.size() == 0) {
|
||||
// FIXME: How do we get a list of effective policySets for a given operation?
|
||||
for(Operation operation : operations) {
|
||||
if (operation!= null && operation.getName() != null && operation.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : operation.getPolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (AuthorizationPolicy.class.isInstance(p)) {
|
||||
if (p instanceof AuthorizationPolicy) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = service.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (AuthorizationPolicy.class.isInstance(p)) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
if (service instanceof OperationsConfigurator) {
|
||||
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)service;
|
||||
for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
|
||||
if (cop != null && cop.getName() != null && cop.getName().equals(op.getName())) {
|
||||
for (PolicySet ps : cop.getApplicablePolicySets()) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof AuthorizationPolicy) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PolicySet> policySets = service.getPolicySets();
|
||||
for (PolicySet ps : policySets) {
|
||||
for (Object p : ps.getPolicies()) {
|
||||
if (p instanceof AuthorizationPolicy) {
|
||||
polices.add((AuthorizationPolicy)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return polices;
|
||||
}
|
||||
|
||||
private ConfiguredOperation findOperation(Operation operation) {
|
||||
ConfiguredOperation configuredOperation = null;
|
||||
|
||||
for (ConfiguredOperation cOperation : ((OperationsConfigurator)component).getConfiguredOperations()) {
|
||||
if(cOperation.getName().equals(operation.getName())) {
|
||||
configuredOperation = cOperation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return configuredOperation;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue