Commit fbb2a21c authored by Raj Shah's avatar Raj Shah
Browse files

Release 3.2.51

parent 7f5e9d2c
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -142,7 +142,7 @@ public class AuthorizationDecision extends Ind2uceEntity { ...@@ -142,7 +142,7 @@ public class AuthorizationDecision extends Ind2uceEntity {
*/ */
public static final AuthorizationDecision getDecisionAllow() { public static final AuthorizationDecision getDecisionAllow() {
return new AuthorizationDecision(DECISION_ALLOW); return new AuthorizationDecision(DECISION_ALLOW);
} }
/** /**
...@@ -152,7 +152,7 @@ public class AuthorizationDecision extends Ind2uceEntity { ...@@ -152,7 +152,7 @@ public class AuthorizationDecision extends Ind2uceEntity {
*/ */
public static final AuthorizationDecision getDecisionInhibit() { public static final AuthorizationDecision getDecisionInhibit() {
return new AuthorizationDecision(DECISION_INHIBIT); return new AuthorizationDecision(DECISION_INHIBIT);
} }
/** /**
...@@ -293,7 +293,7 @@ public class AuthorizationDecision extends Ind2uceEntity { ...@@ -293,7 +293,7 @@ public class AuthorizationDecision extends Ind2uceEntity {
public void setAuthorizationActionNames(List<String> authorizationActionNames) { public void setAuthorizationActionNames(List<String> authorizationActionNames) {
this.authorizationActionNames = authorizationActionNames; this.authorizationActionNames = authorizationActionNames;
} }
/** /**
* Sets how much the event should be delayed. * Sets how much the event should be delayed.
* *
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
/*-
* =================================LICENSE_START=================================
* IND2UCE
* %%
* Copyright (C) 2017 Fraunhofer IESE (www.iese.fraunhofer.de)
* %%
* Licensed 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.
* =================================LICENSE_END=================================
*/
package de.fraunhofer.iese.ind2uce.api.policy;
public interface IPolicyValidator {
public boolean validateXMLSchema(String policyString) throws InvalidPolicyException;
boolean checkPolicySolution(Policy p) throws InvalidPolicyException;
}
/*-
* =================================LICENSE_START=================================
* IND2UCE
* %%
* Copyright (C) 2017 Fraunhofer IESE (www.iese.fraunhofer.de)
* %%
* Licensed 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.
* =================================LICENSE_END=================================
*/
package de.fraunhofer.iese.ind2uce.api.policy;
public interface ITimerValidator {
public boolean validateXMLSchema(String timerString) throws InvalidTimerException;
boolean checkTimerSolution(Timer t) throws InvalidTimerException;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* =================================LICENSE_START================================= * =================================LICENSE_START=================================
* IND2UCE * IND2UCE
* %% * %%
* Copyright (C) 2016 Fraunhofer IESE (www.iese.fraunhofer.de) * Copyright (C) 2017 Fraunhofer IESE (www.iese.fraunhofer.de)
* %% * %%
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -17,43 +17,16 @@ ...@@ -17,43 +17,16 @@
* limitations under the License. * limitations under the License.
* =================================LICENSE_END================================= * =================================LICENSE_END=================================
*/ */
package de.fraunhofer.iese.ind2uce.api.policy;
/** public class InvalidPolicyException extends Exception {
*
*/
package de.fraunhofer.iese.ind2uce.api.common;
/**
* Roles fpr the PMP.
*
* @author Bernd Peltzer-Bartels
*/
public enum Ind2uceRole {
SOLUTION_DEVELOPER("Developer"), ADMINISTRATOR("Admin"),
/**
* This role is not stored with user. It' for components, only.
*/
PDP("PDP"), CLIENT("CLIENT");
private final String text;
private Ind2uceRole(final String text) { public InvalidPolicyException(String string, Exception e) {
this.text = text; super(string, e);
} }
/** public InvalidPolicyException(String string) {
* To spring role. super(string);
* }
* @return the string
*/
public String toSpringRole() {
return "ROLE_" + this.name();
}
@Override
public String toString() {
return this.text;
}
} }
/*-
* =================================LICENSE_START=================================
* IND2UCE
* %%
* Copyright (C) 2017 Fraunhofer IESE (www.iese.fraunhofer.de)
* %%
* Licensed 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.
* =================================LICENSE_END=================================
*/
package de.fraunhofer.iese.ind2uce.api.policy;
public class InvalidTimerException extends Exception {
public InvalidTimerException(String string, Exception e) {
super(string, e);
}
public InvalidTimerException(String string) {
super(string);
}
}
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -151,7 +151,7 @@ public class PipRequest<T> extends Ind2uceEntity implements ParameterListProvide ...@@ -151,7 +151,7 @@ public class PipRequest<T> extends Ind2uceEntity implements ParameterListProvide
return false; return false;
} }
} catch (final NullPointerException e) { } catch (final NullPointerException e) {
String msg = "Param: " + curParam.getName() + " is NOT present."; final String msg = "Param: " + curParam.getName() + " is NOT present.";
LOG.debug(msg); LOG.debug(msg);
LOG.trace(msg, e); LOG.trace(msg, e);
return false; return false;
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -34,12 +34,12 @@ import java.util.HashMap; ...@@ -34,12 +34,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.CollectionTable; import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection; import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId; import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.Transient;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
...@@ -65,11 +65,28 @@ public class Policy { ...@@ -65,11 +65,28 @@ public class Policy {
@EmbeddedId @EmbeddedId
private PolicyId id; private PolicyId id;
@Transient
private boolean xmlValid = false;
@Transient
private boolean scopeValid = false;
public boolean isScopeValid() {
return this.scopeValid;
}
@Transient
private InvalidPolicyException invalidPolicyException;
/** /**
* The deployed. * The deployed.
*/ */
private boolean deployed; private boolean deployed;
public InvalidPolicyException getInvalidPolicyException() {
return this.invalidPolicyException;
}
/** /**
* The policy description. * The policy description.
*/ */
...@@ -103,12 +120,17 @@ public class Policy { ...@@ -103,12 +120,17 @@ public class Policy {
* *
* @param id the id * @param id the id
* @param policy the policy * @param policy the policy
* @deprecated
*/ */
@Deprecated @Deprecated
public Policy(PolicyId id, String policy) { public Policy(PolicyId id, String policy) {
super(); super();
this.id = id; this.id = id;
this.policy = policy; this.policy = policy;
this.validateXML();
this.validateScope();
} }
/** /**
...@@ -117,6 +139,7 @@ public class Policy { ...@@ -117,6 +139,7 @@ public class Policy {
* @param id the id * @param id the id
* @param policy the policy * @param policy the policy
* @param description the description * @param description the description
* @deprecated
*/ */
@Deprecated @Deprecated
public Policy(PolicyId id, String policy, String description) { public Policy(PolicyId id, String policy, String description) {
...@@ -124,18 +147,62 @@ public class Policy { ...@@ -124,18 +147,62 @@ public class Policy {
this.id = id; this.id = id;
this.policy = policy; this.policy = policy;
this.description = description; this.description = description;
this.validateXML();
this.validateScope();
} }
/** /**
* Instantiates a new policy. * Instantiates a new policy.
* *
* @param policy the policy * @param policy the policy
* @throws InvalidPolicyException
*/ */
public Policy(String policy) { public Policy(String policy) {
super(); super();
this.policy = policy; this.policy = policy;
this.id = new PolicyId(this.readAttribute("//policy/@id")); this.validateXML();
this.description = this.readAttribute("//policy/@description"); this.extractIdAndDescription();
this.validateScope();
}
public boolean isXmlValid() {
return this.xmlValid;
}
private boolean validateScope() {
try {
this.scopeValid = new PolicyValidator().checkPolicySolution(this);
} catch (final InvalidPolicyException e) {
this.scopeValid = false;
this.invalidPolicyException = e;
} catch (final Exception e) {
LOG.warn("Exception in method validateScope", e);
}
return this.scopeValid;
}
public void extractIdAndDescription() {
try {
this.id = new PolicyId(this.readAttribute("//policy/@id"));
this.description = this.readAttribute("//policy/@description");
} catch (final Exception e) {
LOG.error("Exception in method extractIdAndDescription", e);
}
}
public boolean validateXML() {
try {
this.xmlValid = new PolicyValidator().validateXMLSchema(this.policy);
} catch (final InvalidPolicyException e) {
this.xmlValid = false;
this.invalidPolicyException = e;
}
return this.xmlValid;
} }
/** /**
...@@ -143,10 +210,15 @@ public class Policy { ...@@ -143,10 +210,15 @@ public class Policy {
* *
* @param policy the policy * @param policy the policy
* @param description the description * @param description the description
* @throws InvalidPolicyException
*/ */
public Policy(String policy, String description) { public Policy(String policy, String description) {
this(policy); this.policy = policy;
this.description = description; this.description = description;
this.validateXML();
this.extractIdAndDescription();
this.validateScope();
} }
/** /**
...@@ -175,9 +247,9 @@ public class Policy { ...@@ -175,9 +247,9 @@ public class Policy {
return false; return false;
} }
final Policy policy = (Policy)o; final Policy thePolicy = (Policy)o;
return this.id != null ? this.id.equals(policy.id) : policy.id == null; return this.id != null ? this.id.equals(thePolicy.id) : thePolicy.id == null;
}