Home | History | Annotate | Download | only in supl_auth_resp
      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 package android.location.cts.asn1.supl2.supl_auth_resp;
     18 
     19 /*
     20  */
     21 
     22 
     23 //
     24 //
     25 import android.location.cts.asn1.base.Asn1Null;
     26 import android.location.cts.asn1.base.Asn1Object;
     27 import android.location.cts.asn1.base.Asn1Sequence;
     28 import android.location.cts.asn1.base.Asn1Tag;
     29 import android.location.cts.asn1.base.BitStream;
     30 import android.location.cts.asn1.base.BitStreamReader;
     31 import android.location.cts.asn1.base.SequenceComponent;
     32 import android.location.cts.asn1.supl2.ver2_ulp_components.SPCSETKey;
     33 import android.location.cts.asn1.supl2.ver2_ulp_components.SPCSETKeylifetime;
     34 import android.location.cts.asn1.supl2.ver2_ulp_components.SPCTID;
     35 import com.google.common.collect.ImmutableList;
     36 import java.util.Collection;
     37 import javax.annotation.Nullable;
     38 
     39 
     40 /**
     41 */
     42 public  class SUPLAUTHRESP extends Asn1Sequence {
     43   //
     44 
     45   private static final Asn1Tag TAG_SUPLAUTHRESP
     46       = Asn1Tag.fromClassAndNumber(-1, -1);
     47 
     48   public SUPLAUTHRESP() {
     49     super();
     50   }
     51 
     52   @Override
     53   @Nullable
     54   protected Asn1Tag getTag() {
     55     return TAG_SUPLAUTHRESP;
     56   }
     57 
     58   @Override
     59   protected boolean isTagImplicit() {
     60     return true;
     61   }
     62 
     63   public static Collection<Asn1Tag> getPossibleFirstTags() {
     64     if (TAG_SUPLAUTHRESP != null) {
     65       return ImmutableList.of(TAG_SUPLAUTHRESP);
     66     } else {
     67       return Asn1Sequence.getPossibleFirstTags();
     68     }
     69   }
     70 
     71   /**
     72    * Creates a new SUPLAUTHRESP from encoded stream.
     73    */
     74   public static SUPLAUTHRESP fromPerUnaligned(byte[] encodedBytes) {
     75     SUPLAUTHRESP result = new SUPLAUTHRESP();
     76     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
     77     return result;
     78   }
     79 
     80   /**
     81    * Creates a new SUPLAUTHRESP from encoded stream.
     82    */
     83   public static SUPLAUTHRESP fromPerAligned(byte[] encodedBytes) {
     84     SUPLAUTHRESP result = new SUPLAUTHRESP();
     85     result.decodePerAligned(new BitStreamReader(encodedBytes));
     86     return result;
     87   }
     88 
     89 
     90 
     91   @Override protected boolean isExtensible() {
     92     return true;
     93   }
     94 
     95   @Override public boolean containsExtensionValues() {
     96     for (SequenceComponent extensionComponent : getExtensionComponents()) {
     97       if (extensionComponent.isExplicitlySet()) return true;
     98     }
     99     return false;
    100   }
    101 
    102 
    103   private SPCSETKey sPCSETKey_;
    104   public SPCSETKey getSPCSETKey() {
    105     return sPCSETKey_;
    106   }
    107   /**
    108    * @throws ClassCastException if value is not a SPCSETKey
    109    */
    110   public void setSPCSETKey(Asn1Object value) {
    111     this.sPCSETKey_ = (SPCSETKey) value;
    112   }
    113   public SPCSETKey setSPCSETKeyToNewInstance() {
    114     sPCSETKey_ = new SPCSETKey();
    115     return sPCSETKey_;
    116   }
    117 
    118   private SPCTID sPCTID_;
    119   public SPCTID getSPCTID() {
    120     return sPCTID_;
    121   }
    122   /**
    123    * @throws ClassCastException if value is not a SPCTID
    124    */
    125   public void setSPCTID(Asn1Object value) {
    126     this.sPCTID_ = (SPCTID) value;
    127   }
    128   public SPCTID setSPCTIDToNewInstance() {
    129     sPCTID_ = new SPCTID();
    130     return sPCTID_;
    131   }
    132 
    133   private SPCSETKeylifetime sPCSETKeylifetime_;
    134   public SPCSETKeylifetime getSPCSETKeylifetime() {
    135     return sPCSETKeylifetime_;
    136   }
    137   /**
    138    * @throws ClassCastException if value is not a SPCSETKeylifetime
    139    */
    140   public void setSPCSETKeylifetime(Asn1Object value) {
    141     this.sPCSETKeylifetime_ = (SPCSETKeylifetime) value;
    142   }
    143   public SPCSETKeylifetime setSPCSETKeylifetimeToNewInstance() {
    144     sPCSETKeylifetime_ = new SPCSETKeylifetime();
    145     return sPCSETKeylifetime_;
    146   }
    147 
    148 
    149 
    150 
    151 
    152 
    153   @Override public Iterable<? extends SequenceComponent> getComponents() {
    154     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
    155 
    156     builder.add(new SequenceComponent() {
    157           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 0);
    158 
    159           @Override public boolean isExplicitlySet() {
    160             return getSPCSETKey() != null;
    161           }
    162 
    163           @Override public boolean hasDefaultValue() {
    164             return false;
    165           }
    166 
    167           @Override public boolean isOptional() {
    168             return false;
    169           }
    170 
    171           @Override public Asn1Object getComponentValue() {
    172             return getSPCSETKey();
    173           }
    174 
    175           @Override public void setToNewInstance() {
    176             setSPCSETKeyToNewInstance();
    177           }
    178 
    179           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    180             return tag == null ? SPCSETKey.getPossibleFirstTags() : ImmutableList.of(tag);
    181           }
    182 
    183           @Override
    184           public Asn1Tag getTag() {
    185             return tag;
    186           }
    187 
    188           @Override
    189           public boolean isImplicitTagging() {
    190             return true;
    191           }
    192 
    193           @Override public String toIndentedString(String indent) {
    194                 return "sPCSETKey : "
    195                     + getSPCSETKey().toIndentedString(indent);
    196               }
    197         });
    198 
    199     builder.add(new SequenceComponent() {
    200           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 1);
    201 
    202           @Override public boolean isExplicitlySet() {
    203             return getSPCTID() != null;
    204           }
    205 
    206           @Override public boolean hasDefaultValue() {
    207             return false;
    208           }
    209 
    210           @Override public boolean isOptional() {
    211             return false;
    212           }
    213 
    214           @Override public Asn1Object getComponentValue() {
    215             return getSPCTID();
    216           }
    217 
    218           @Override public void setToNewInstance() {
    219             setSPCTIDToNewInstance();
    220           }
    221 
    222           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    223             return tag == null ? SPCTID.getPossibleFirstTags() : ImmutableList.of(tag);
    224           }
    225 
    226           @Override
    227           public Asn1Tag getTag() {
    228             return tag;
    229           }
    230 
    231           @Override
    232           public boolean isImplicitTagging() {
    233             return true;
    234           }
    235 
    236           @Override public String toIndentedString(String indent) {
    237                 return "sPCTID : "
    238                     + getSPCTID().toIndentedString(indent);
    239               }
    240         });
    241 
    242     builder.add(new SequenceComponent() {
    243           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 2);
    244 
    245           @Override public boolean isExplicitlySet() {
    246             return getSPCSETKeylifetime() != null;
    247           }
    248 
    249           @Override public boolean hasDefaultValue() {
    250             return false;
    251           }
    252 
    253           @Override public boolean isOptional() {
    254             return true;
    255           }
    256 
    257           @Override public Asn1Object getComponentValue() {
    258             return getSPCSETKeylifetime();
    259           }
    260 
    261           @Override public void setToNewInstance() {
    262             setSPCSETKeylifetimeToNewInstance();
    263           }
    264 
    265           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    266             return tag == null ? SPCSETKeylifetime.getPossibleFirstTags() : ImmutableList.of(tag);
    267           }
    268 
    269           @Override
    270           public Asn1Tag getTag() {
    271             return tag;
    272           }
    273 
    274           @Override
    275           public boolean isImplicitTagging() {
    276             return true;
    277           }
    278 
    279           @Override public String toIndentedString(String indent) {
    280                 return "sPCSETKeylifetime : "
    281                     + getSPCSETKeylifetime().toIndentedString(indent);
    282               }
    283         });
    284 
    285     return builder.build();
    286   }
    287 
    288   @Override public Iterable<? extends SequenceComponent>
    289                                                     getExtensionComponents() {
    290     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
    291 
    292       return builder.build();
    293     }
    294 
    295 
    296 
    297 
    298 
    299 
    300 
    301 
    302 
    303 
    304 
    305   @Override public Iterable<BitStream> encodePerUnaligned() {
    306     return super.encodePerUnaligned();
    307   }
    308 
    309   @Override public Iterable<BitStream> encodePerAligned() {
    310     return super.encodePerAligned();
    311   }
    312 
    313   @Override public void decodePerUnaligned(BitStreamReader reader) {
    314     super.decodePerUnaligned(reader);
    315   }
    316 
    317   @Override public void decodePerAligned(BitStreamReader reader) {
    318     super.decodePerAligned(reader);
    319   }
    320 
    321   @Override public String toString() {
    322     return toIndentedString("");
    323   }
    324 
    325   public String toIndentedString(String indent) {
    326     StringBuilder builder = new StringBuilder();
    327     builder.append("SUPLAUTHRESP = {\n");
    328     final String internalIndent = indent + "  ";
    329     for (SequenceComponent component : getComponents()) {
    330       if (component.isExplicitlySet()) {
    331         builder.append(internalIndent)
    332             .append(component.toIndentedString(internalIndent));
    333       }
    334     }
    335     if (isExtensible()) {
    336       builder.append(internalIndent).append("...\n");
    337       for (SequenceComponent component : getExtensionComponents()) {
    338         if (component.isExplicitlySet()) {
    339           builder.append(internalIndent)
    340               .append(component.toIndentedString(internalIndent));
    341         }
    342       }
    343     }
    344     builder.append(indent).append("};\n");
    345     return builder.toString();
    346   }
    347 }
    348