/** * Create a BinarySecurityToken via a CallbackHandler * @param callbackHandler * @throws WSSecurityException */ public BinarySecurity(CallbackHandler callbackHandler) throws WSSecurityException { if (callbackHandler == null) { LOG.debug("Trying to create a BinarySecurityToken via a null CallbackHandler"); throw new WSSecurityException(WSSecurityException.FAILURE); } TokenElementCallback[] callback = new TokenElementCallback[] { new TokenElementCallback() }; try { callbackHandler.handle(callback); } catch (IOException e) { throw new IllegalStateException( "IOException while creating a token element", e ); } catch (UnsupportedCallbackException e) { throw new IllegalStateException( "UnsupportedCallbackException while creating a token element", e ); } element = callback[0].getTokenElement(); if (element == null) { LOG.debug("CallbackHandler did not return a token element"); throw new WSSecurityException(WSSecurityException.FAILURE); } }
/** * Create a BinarySecurityToken via a CallbackHandler * @param callbackHandler * @throws WSSecurityException */ public BinarySecurity(CallbackHandler callbackHandler) throws WSSecurityException { if (callbackHandler == null) { LOG.debug("Trying to create a BinarySecurityToken via a null CallbackHandler"); throw new WSSecurityException(WSSecurityException.FAILURE); } TokenElementCallback[] callback = new TokenElementCallback[] { new TokenElementCallback() }; try { callbackHandler.handle(callback); } catch (IOException e) { throw new IllegalStateException( "IOException while creating a token element", e ); } catch (UnsupportedCallbackException e) { throw new IllegalStateException( "UnsupportedCallbackException while creating a token element", e ); } element = callback[0].getTokenElement(); if (element == null) { LOG.debug("CallbackHandler did not return a token element"); throw new WSSecurityException(WSSecurityException.FAILURE); } }