0 Replies Latest reply on Feb 1, 2015 11:21 PM by valsaraj viswanathan

    Unable to retrieve credential of type user defined class from Subject in WildFly

    valsaraj viswanathan Master

      Hi,

       

      Unable to retrieve credential of type user defined class from Subject in WildFly. Built in types like String, PrivateKey are working fine.

       

      Here is the code:

      Subject subject;

              try {

                  subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");

                  if (subject == null) {

                      throw new IllegalStateException("No Subject found in PolicyContext while aquiring privateKey");

                  }

              } catch (PolicyContextException e) {

                  throw new RuntimeException("PolicyContext Exception while aquiring privateKey", e);

              }

       

      and this code not working because it is a user defined class:

      Set<MyPrivateKey> myPrivateKeys = subject.getPrivateCredentials(MyPrivateKey.class);

       

      When this is replaced with built in class, it is working:

      Set<PrivateKey> privateKeys = subject.getPrivateCredentials(PrivateKey.class);

       

      Please let me know if you have any idea.

       

      Thanks!