private void checkForUTOKENNotFoundError ( Subject subj ) throws ResourceException { // A Subject without a UTOKEN genericCredential can // legitimately occur in the case where the resource // adapter has indicated Thread Identity Support // is "ALLOWED, but a valid Container-managed alias // was specified. On the other hand, at this ponit, if // either of the following two cases exist when there is // no UTOKEN genericCredential, then we have an // unexpected error and need to throw an exception: // // 1. The resource adapter REQUIRES that Thread Identity // be used. // // 2. The Subject has no private credentials at all // // Check if ThreadIdentitySupport is "REQUIRED" if ( m_ThreadIdentitySupport == AbstractConnectionFactoryService . THREAD_IDENTITY_REQUIRED ) { // ThreadIdentitySupport indicates that the use of thread // identity is "REQUIRED" by the connector, but the // Subject doesn't contain a UTOKEN GenericCredential. // This should not ever occur because finalizeSubject() // should have created a Subject with a UTOKEN // GenericCredential when ThreadidentitySupport is // "REQUIRED". Thus, throw an exception to terminate // processing right here. // try { IllegalStateException e = new IllegalStateException ( "ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject not setup for using thread identity, but the connector requires thread identity be used." ) ; Object [ ] parms = new Object [ ] { "ThreadIdentitySecurityHelper.beforeGettingConnection()" , e } ; Tr . error ( tc , "ILLEGAL_STATE_EXCEPTION_J2CA0079" , parms ) ; throw e ; } catch ( IllegalStateException ise ) { ResourceException re = new ResourceException ( "ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject with illegal state" ) ; re . initCause ( ise ) ; throw re ; } } // end if m_ThreadIdentitySupport.equals REQUIRED // Check if Subject has at least one a private credential Set privateCredentials = subj . getPrivateCredentials ( ) ; Iterator privateIterator = privateCredentials . iterator ( ) ; if ( ! privateIterator . hasNext ( ) ) { // if no private credentials // There is not only no UTOKEN generic credential, but // also, there are no private credentials at all. This // should not happen. If there are no private credentials, // the finalizeSubject() processing should have built // a UTOKEN generic credential. // try { IllegalStateException e = new IllegalStateException ( "ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject with no credentials." ) ; Object [ ] parms = new Object [ ] { "ThreadIdentitySecurityHelper.beforeGettingConnection()" , e } ; Tr . error ( tc , "ILLEGAL_STATE_EXCEPTION_J2CA0079" , parms ) ; throw e ; } catch ( IllegalStateException ise ) { ResourceException re = new ResourceException ( "ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject with illegal state" ) ; re . initCause ( ise ) ; throw re ; } } // end if no private credentials }
Check for an unexpected condition when a UTOKEN is not found in the Subject .