1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 /* 17 * Copyright (c) 2017, The Linux Foundation. 18 */ 19 20 /* 21 * Copyright 2012 Giesecke & Devrient GmbH. 22 * 23 * Licensed under the Apache License, Version 2.0 (the "License"); 24 * you may not use this file except in compliance with the License. 25 * You may obtain a copy of the License at 26 * 27 * http://www.apache.org/licenses/LICENSE-2.0 28 * 29 * Unless required by applicable law or agreed to in writing, software 30 * distributed under the License is distributed on an "AS IS" BASIS, 31 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 32 * See the License for the specific language governing permissions and 33 * limitations under the License. 34 */ 35 package com.android.se.security.gpac; 36 37 /** Matches the Tags for the data object */ 38 public class Response_DO_Factory { 39 40 /** Creates and interprets the bytes into the respective types */ createDO(byte[] data)41 public static BerTlv createDO(byte[] data) throws ParserException { 42 43 BerTlv tempTlv = BerTlv.decode(data, 0); 44 45 BerTlv retTlv = null; 46 47 switch (tempTlv.getTag()) { 48 case Response_RefreshTag_DO.TAG: 49 retTlv = 50 new Response_RefreshTag_DO(data, tempTlv.getValueIndex(), 51 tempTlv.getValueLength()); 52 break; 53 case Response_ARAC_AID_DO.TAG: 54 retTlv = new Response_ARAC_AID_DO(data, tempTlv.getValueIndex(), 55 tempTlv.getValueLength()); 56 break; 57 58 case Response_ALL_AR_DO.TAG: 59 retTlv = new Response_ALL_AR_DO(data, tempTlv.getValueIndex(), 60 tempTlv.getValueLength()); 61 break; 62 case Response_AR_DO.TAG: 63 retTlv = new Response_AR_DO(data, tempTlv.getValueIndex(), 64 tempTlv.getValueLength()); 65 break; 66 default: 67 retTlv = tempTlv; 68 } 69 70 retTlv.interpret(); 71 72 return retTlv; 73 } 74 } 75