/** * Get the derived key. * * After the <code>prepare()</code> method was called use this method * to compute a derived key. The generation of this secret key is according * to the UsernameTokenProfile 1.1 specification (section 4 - Key Derivation). * * @return Return the derived key of this token or null if <code>prepare()</code> * was not called before. */ public byte[] getDerivedKey() throws WSSecurityException { if (ut == null || !useDerivedKey) { return null; } if (passwordsAreEncoded) { return UsernameToken.generateDerivedKey(Base64.decode(password), saltValue, iteration); } else { return UsernameToken.generateDerivedKey(password, saltValue, iteration); } }
/** * Get the derived key. * * After the <code>prepare()</code> method was called use this method * to compute a derived key. The generation of this secret key is according * to the UsernameTokenProfile 1.1 specification (section 4 - Key Derivation). * * @return Return the derived key of this token or null if <code>prepare()</code> * was not called before. */ public byte[] getDerivedKey() throws WSSecurityException { if (ut == null || !useDerivedKey) { return null; } if (passwordsAreEncoded) { return UsernameToken.generateDerivedKey(Base64.decode(password), saltValue, iteration); } else { return UsernameToken.generateDerivedKey(password, saltValue, iteration); } }
/** * This static method generates a derived key as defined in WSS Username * Token Profile. * * @param password The password to include in the key generation * @param salt The Salt value * @param iteration The Iteration value. If zero (0) is given the method uses the * default value * @return Returns the derived key a byte array * @throws WSSecurityException */ public static byte[] generateDerivedKey( String password, byte[] salt, int iteration ) throws WSSecurityException { try { return generateDerivedKey(password.getBytes("UTF-8"), salt, iteration); } catch (final java.io.UnsupportedEncodingException e) { if (DO_DEBUG) { LOG.debug(e.getMessage(), e); } throw new WSSecurityException("Unable to convert password to UTF-8", e); } }
/** * Get the derived secret key. * * After the <code>prepare()</code> method was called use this method * to compute a derived secret key. If "useDerivedKey" is set, then the returned secret * key is derived as per the UsernameToken 1.1 specification. Otherwise, the generation * of this secret key is according to the WS-Trust specifications. * * @return Return the derived secret key of this token or null if <code>prepare()</code> * was not called before. */ public byte[] getSecretKey() throws WSSecurityException { if (ut == null) { return null; } if (useDerivedKey) { if (passwordsAreEncoded) { return UsernameToken.generateDerivedKey(Base64.decode(password), saltValue, iteration); } else { return UsernameToken.generateDerivedKey(password, saltValue, iteration); } } return ut.getSecretKey(secretKeyLength); }
/** * This static method generates a derived key as defined in WSS Username * Token Profile. * * @param password The password to include in the key generation * @param salt The Salt value * @param iteration The Iteration value. If zero (0) is given the method uses the * default value * @return Returns the derived key a byte array * @throws WSSecurityException */ public static byte[] generateDerivedKey( String password, byte[] salt, int iteration ) throws WSSecurityException { try { return generateDerivedKey(password.getBytes("UTF-8"), salt, iteration); } catch (final java.io.UnsupportedEncodingException e) { if (DO_DEBUG) { LOG.debug(e.getMessage(), e); } throw new WSSecurityException("Unable to convert password to UTF-8", e); } }
/** * Get the derived secret key. * * After the <code>prepare()</code> method was called use this method * to compute a derived secret key. If "useDerivedKey" is set, then the returned secret * key is derived as per the UsernameToken 1.1 specification. Otherwise, the generation * of this secret key is according to the WS-Trust specifications. * * @return Return the derived secret key of this token or null if <code>prepare()</code> * was not called before. */ public byte[] getSecretKey() throws WSSecurityException { if (ut == null) { return null; } if (useDerivedKey) { if (passwordsAreEncoded) { return UsernameToken.generateDerivedKey(Base64.decode(password), saltValue, iteration); } else { return UsernameToken.generateDerivedKey(password, saltValue, iteration); } } return ut.getSecretKey(secretKeyLength); }
/** * This method gets a derived key as defined in WSS Username Token Profile. * * @return Returns the derived key as a byte array * @throws WSSecurityException */ public byte[] getDerivedKey() throws WSSecurityException { if (rawPassword == null || !bspCompliantDerivedKey) { LOG.debug("The raw password was null or the Username Token is not BSP compliant"); throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION); } int iteration = getIteration(); byte[] salt = getSalt(); if (passwordsAreEncoded) { return generateDerivedKey(Base64.decode(rawPassword), salt, iteration); } else { return generateDerivedKey(rawPassword, salt, iteration); } }
/** * This method gets a derived key as defined in WSS Username Token Profile. * * @return Returns the derived key as a byte array * @throws WSSecurityException */ public byte[] getDerivedKey() throws WSSecurityException { if (rawPassword == null || !bspCompliantDerivedKey) { LOG.debug("The raw password was null or the Username Token is not BSP compliant"); throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION); } int iteration = getIteration(); byte[] salt = getSalt(); if (passwordsAreEncoded) { return generateDerivedKey(Base64.decode(rawPassword), salt, iteration); } else { return generateDerivedKey(rawPassword, salt, iteration); } }