diff options
| author | 2019-10-31 20:06:00 +0000 | |
|---|---|---|
| committer | 2019-10-31 20:06:00 +0000 | |
| commit | a644b6e30f2d535ff0b251a31f5f2bc9c18387f8 (patch) | |
| tree | 5783772ec8a3fa031527f1306dfb1043c9031677 | |
| parent | c3d7e24dc1803f63a85675b01a6a1373f0e2261c (diff) | |
| parent | 7c56df6579a6b3195db5e4541d08798ca671f8dd (diff) | |
Merge "Create stubs for rule parsers and serializers"
6 files changed, 208 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/integrity/parser/RuleBinaryParser.java b/services/core/java/com/android/server/integrity/parser/RuleBinaryParser.java new file mode 100644 index 000000000000..c1567bc51474 --- /dev/null +++ b/services/core/java/com/android/server/integrity/parser/RuleBinaryParser.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * 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. + */ + +package com.android.server.integrity.parser; + +import com.android.server.integrity.model.Rule; + +import java.io.InputStream; + +/** A helper class to parse rules into the {@link Rule} model from Binary representation. */ +public class RuleBinaryParser implements RuleParser { + + @Override + public Rule parse(String ruleText) { + // TODO: Implement binary text parser. + return null; + } + + @Override + public Rule parse(InputStream inputStream) { + // TODO: Implement stream parser. + return null; + } +} diff --git a/services/core/java/com/android/server/integrity/parser/RuleParser.java b/services/core/java/com/android/server/integrity/parser/RuleParser.java new file mode 100644 index 000000000000..96ed5993cb06 --- /dev/null +++ b/services/core/java/com/android/server/integrity/parser/RuleParser.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * 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. + */ + +package com.android.server.integrity.parser; + +import com.android.server.integrity.model.Rule; + +import java.io.InputStream; + +/** A helper class to parse rules into the {@link Rule} model. */ +public interface RuleParser { + + /** Parse rules from a string. */ + Rule parse(String ruleText); + + /** Parse rules from an input stream. */ + Rule parse(InputStream inputStream); +} diff --git a/services/core/java/com/android/server/integrity/parser/RuleXmlParser.java b/services/core/java/com/android/server/integrity/parser/RuleXmlParser.java new file mode 100644 index 000000000000..8b1bec90f994 --- /dev/null +++ b/services/core/java/com/android/server/integrity/parser/RuleXmlParser.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * 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. + */ + +package com.android.server.integrity.parser; + +import com.android.server.integrity.model.Rule; + +import java.io.InputStream; + +/** A helper class to parse rules into the {@link Rule} model from Xml representation. */ +public final class RuleXmlParser implements RuleParser { + + @Override + public Rule parse(String ruleText) { + // TODO: Implement text parser. + return null; + } + + @Override + public Rule parse(InputStream inputStream) { + // TODO: Implement stream parser. + return null; + } +} diff --git a/services/core/java/com/android/server/integrity/serializer/RuleBinarySerializer.java b/services/core/java/com/android/server/integrity/serializer/RuleBinarySerializer.java new file mode 100644 index 000000000000..ecb00a4b7025 --- /dev/null +++ b/services/core/java/com/android/server/integrity/serializer/RuleBinarySerializer.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * 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. + */ + +package com.android.server.integrity.serializer; + +import com.android.server.integrity.model.Rule; + +import java.io.OutputStream; + +/** A helper class to serialize rules from the {@link Rule} model to Xml representation. */ +public class RuleBinarySerializer implements RuleSerializer { + + @Override + public void serialize(Rule rule, OutputStream outputStream) { + // TODO: Implement stream serializer. + } + + @Override + public String serialize(Rule rule) { + // TODO: Implement text serializer. + return null; + } +} diff --git a/services/core/java/com/android/server/integrity/serializer/RuleSerializer.java b/services/core/java/com/android/server/integrity/serializer/RuleSerializer.java new file mode 100644 index 000000000000..07a912f8aeab --- /dev/null +++ b/services/core/java/com/android/server/integrity/serializer/RuleSerializer.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * 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. + */ + +package com.android.server.integrity.serializer; + +import com.android.server.integrity.model.Rule; + +import java.io.OutputStream; + +/** A helper class to serialize rules from the {@link Rule} model. */ +public interface RuleSerializer { + + /** Serialize a rule to an output stream */ + void serialize(Rule rule, OutputStream outputStream); + + /** Serialize a rule to a string. */ + String serialize(Rule rule); +} diff --git a/services/core/java/com/android/server/integrity/serializer/RuleXmlSerializer.java b/services/core/java/com/android/server/integrity/serializer/RuleXmlSerializer.java new file mode 100644 index 000000000000..62973e2b026f --- /dev/null +++ b/services/core/java/com/android/server/integrity/serializer/RuleXmlSerializer.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * 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. + */ + +package com.android.server.integrity.serializer; + +import com.android.server.integrity.model.Rule; + +import java.io.OutputStream; + +/** A helper class to serialize rules from the {@link Rule} model to Xml representation. */ +public class RuleXmlSerializer implements RuleSerializer { + + @Override + public void serialize(Rule rule, OutputStream outputStream) { + // TODO: Implement stream serializer. + } + + @Override + public String serialize(Rule rule) { + // TODO: Implement text serializer. + return null; + } +} |