@@ -21,7 +21,7 @@ public class RSAKey extends Key {
2121 private String dq ;
2222 private String di ;
2323 private String qi ;
24- private String key ;
24+ private RSAKey key ;
2525
2626 public RSAKey (String kty , String alg , String use , String kid , String x5c , String x5t , String x5u , Key key , String n ,
2727 String e , String d , String p , String q , String dp , String dq , String di , String qi , Map <String , String > args ) {
@@ -76,12 +76,12 @@ public void deserialize() throws DeserializationNotPossible {
7676 }
7777
7878 List <String > list = new ArrayList <>(Arrays .asList (this .n , this .e ));
79- if (this .d != null && !this .d .isEmpty ()) {
79+ if (this .d != null && !this .d .isEmpty ()) {
8080 list .add (this .d );
8181 }
82- if (this .p != null && !this .p .isEmpty ()) {
82+ if (this .p != null && !this .p .isEmpty ()) {
8383 list .add (this .p );
84- if (this .q != null && !this .q .isEmpty ()) {
84+ if (this .q != null && !this .q .isEmpty ()) {
8585 list .add (this .q );
8686 }
8787 this .key = RSA .construct (tuple (list )); //TODO
@@ -91,44 +91,44 @@ public void deserialize() throws DeserializationNotPossible {
9191 } else if (this .x5c != null ) {
9292 Base64 .decode ((int ) this .x5c .getBytes ()[0 ]);
9393
94- if (this .x5t != null ) {
95- if (Base64 .decode () != )
94+ if (this .x5t != null ) {
95+ if (Base64 .decode () != )
9696
9797 }
9898
9999 this .key =;
100100 this .split ();
101- if (this .x5c .length () > 1 ) {
101+ if (this .x5c .length () > 1 ) {
102102
103103 }
104104 } else {
105105 throw new DeserializationNotPossible ();
106106 }
107107 }
108108
109- public Map <String ,String > serialize (boolean isPrivate ) throws SerializationNotPossible {
110- if (this .key == null ) {
109+ public Map <String , String > serialize (boolean isPrivate ) throws SerializationNotPossible {
110+ if (this .key == null ) {
111111 throw new SerializationNotPossible ();
112112 }
113113
114114 Map <String , String > args = common ();
115115
116116 publicMembers .addAll (longs );
117117 List <String > publicLongs = new ArrayList <>(publicMembers );
118- for (String param : publicLongs ) {
118+ for (String param : publicLongs ) {
119119 try {
120120 Object item = this .getClass ().getField (param ).get (this );
121- if (item != null ) {
121+ if (item != null ) {
122122 args .put (param , longToBase64 (item ));
123123 }
124124 } catch (Exception e1 ) {
125125 logger .error ("Field " + param + " doesn't exist" );
126126 }
127127 }
128128
129- if (isPrivate ) {
130- for (String param : longs ) {
131- if (!isPrivate && new ArrayList <>(Arrays .asList ("d" , "p" , "q" , "dp" , "dq" , "di" ,
129+ if (isPrivate ) {
130+ for (String param : longs ) {
131+ if (!isPrivate && new ArrayList <>(Arrays .asList ("d" , "p" , "q" , "dp" , "dq" , "di" ,
132132 "qi" )).contains (param )) {
133133 continue ;
134134 }
@@ -151,34 +151,31 @@ private void split() {
151151 this .n = this .key .n ;
152152 this .e = this .key .e ;
153153
154- try {
155- this .d = this .key .d ;
156- } catch (AttributeError e ) {
157-
158- } finally {
159- Object item = null ;
160- for (String param : new ArrayList <>(Arrays .asList ("p" , "q" ))) {
161- try {
162- item = this .getClass ().getField (param ).get (this );
163- } catch (Exception e1 ) {
164- logger .error ("Field " + param + " doesn't exist" );
165- } finally {
166- if (item != null ) {
167- //set attribute (which is in the form of a string) to a value
168- }
154+ this .d = this .key .d ;
155+ Object item = null ;
156+ for (String param : new ArrayList <>(Arrays .asList ("p" , "q" ))) {
157+ try {
158+ item = this .getClass ().getField (param ).get (this );
159+ } catch (Exception e1 ) {
160+ logger .error ("Field " + param + " doesn't exist" );
161+ } finally {
162+ if (item != null ) {
163+ //set attribute (which is in the form of a string) to a value
169164 }
170165 }
171166 }
172167 }
173168
174- public RSAKey loadKey (Key key ) {
169+ }
170+
171+ public RSAKey loadKey (RSAKey key ) {
175172 this .key = key ;
176173 this .split ();
177174 return key ;
178175 }
179176
180177 public Key encryptionKey () {
181- if (this .key == null ) {
178+ if (this .key == null ) {
182179 deserialize ();
183180 }
184181
@@ -191,9 +188,4 @@ private String longToBase64(Object item) {
191188 public Map <String , String > serialize () {
192189 return serialize (false );
193190 }
194-
195- private void split () {
196-
197- }
198-
199191}
0 commit comments