You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by pd...@apache.org on 2015/05/13 18:03:09 UTC
[47/56] [abbrv] [partial] incubator-openaz git commit: Merging
re-factoring with PMD work
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/obligation/RedactionObligationHandler.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/obligation/RedactionObligationHandler.java
index 6c9de1a,0000000..dc42c78
mode 100644,000000..100644
--- a/openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/obligation/RedactionObligationHandler.java
+++ b/openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/obligation/RedactionObligationHandler.java
@@@ -1,58 -1,0 +1,58 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std.test.obligation;
+
+import junit.framework.Assert;
+
+import org.apache.openaz.pepapi.Obligation;
+import org.apache.openaz.pepapi.ObligationHandler;
+import org.apache.openaz.pepapi.ObligationStore;
+
+import java.util.Map;
+import java.util.Set;
+
+public class RedactionObligationHandler implements ObligationHandler {
+
+ private ObligationStore obligationStore;
+
+ public void enforce() {
+ Set<Obligation> obligationSet = obligationStore.getHandlerObligations(this.getClass());
- if(obligationSet.size() == 1) {
- for(Obligation obligation: obligationSet) {
++ if (obligationSet.size() == 1) {
++ for (Obligation obligation : obligationSet) {
+ Assert.assertEquals("urn:oasis:names:tc:xacml:2.0:obligation:obligation-2",
+ obligation.getId());
+ }
+ } else {
+ Assert.assertFalse(true);
+ }
+ }
+
+ @Override
+ public boolean match(Obligation obligation) {
+ Map<String, Object[]> map = obligation.getAttributeMap();
+ return map.containsKey("urn:oasis:names:tc:xacml:1.0:subject:age");
+ }
+
+ @Override
+ public void setObligationStore(ObligationStore obligationStore) {
+ this.obligationStore = obligationStore;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/util/AzInvoker.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/util/AzInvoker.java
index f71647e,0000000..05e3679
mode 100644,000000..100644
--- a/openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/util/AzInvoker.java
+++ b/openaz-pep/src/test/java/org/apache/openaz/pepapi/std/test/util/AzInvoker.java
@@@ -1,73 -1,0 +1,73 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std.test.util;
+
+import org.apache.openaz.pepapi.PepAgent;
+import org.apache.openaz.pepapi.PepResponse;
+
+import java.util.concurrent.Callable;
+
-
+public class AzInvoker implements Callable<String> {
+
+ private final PepAgent pepAgent;
+
+ private final Object subject;
+
+ private final Object action;
+
+ private final Object resource;
+
+ private final long sleepDuration;
+
+ private final HasResult handler;
+
- public AzInvoker(PepAgent pepAgent, Object subject, Object action,
- Object resource, HasResult handler, long sleepDuration) {
++ public AzInvoker(PepAgent pepAgent, Object subject, Object action, Object resource, HasResult handler,
++ long sleepDuration) {
+ this.pepAgent = pepAgent;
+ this.subject = subject;
+ this.action = action;
+ this.resource = resource;
+ this.handler = handler;
+ this.sleepDuration = sleepDuration;
+ }
+
- private String invoke()throws InterruptedException {
++ private String invoke() throws InterruptedException {
+ PepResponse response = pepAgent.decide(subject, action, resource);
- if(response != null) {
++ if (response != null) {
+ response.allowed();
+ }
+ Thread.sleep(this.sleepDuration);
+ return handler.getResult();
+ }
+
++ @Override
+ public String call() throws Exception {
+ return invoke();
+ }
+
+ public long getSleepDuration() {
+ return sleepDuration;
+ }
+
+ public HasResult getPep() {
+ return handler;
+ }
+}