public String composeOtpAttribute(OTPUserRecord otpUserRecord) throws PwmUnrecoverableException {
  String value="";
  if (otpUserRecord != null) {
    final Configuration config=pwmApplication.getConfig();
    final OTPStorageFormat format=config.readSettingAsEnum(PwmSetting.OTP_SECRET_STORAGEFORMAT,OTPStorageFormat.class);
switch (format) {
case PWM:
      value=JsonUtil.serialize(otpUserRecord);
    break;
case OTPURL:
  value=OTPUrlUtil.composeOtpUrl(otpUserRecord);
break;
case BASE32SECRET:
value=otpUserRecord.getSecret();
break;
case PAM:
value=OTPPamUtil.composePamData(otpUserRecord);
break;
default :
String errorStr=String.format("Unsupported storage format: ",format.toString());
ErrorInformation error=new ErrorInformation(PwmError.ERROR_INVALID_CONFIG,errorStr);
throw new PwmUnrecoverableException(error);
}
}
return value;
}

public String composeOtpAttribute ( OTPUserRecord otpUserRecord ) throws PwmUnrecoverableException { String value = "" ; if ( otpUserRecord != null ) { final Configuration config = pwmApplication . getConfig ( ) ; final OTPStorageFormat format = config . readSettingAsEnum ( PwmSetting . OTP_SECRET_STORAGEFORMAT , OTPStorageFormat . class ) ; switch ( format ) { case PWM : value = JsonUtil . serialize ( otpUserRecord ) ; break ; case OTPURL : value = OTPUrlUtil . composeOtpUrl ( otpUserRecord ) ; break ; case BASE32SECRET : value = otpUserRecord . getSecret ( ) ; break ; case PAM : value = OTPPamUtil . composePamData ( otpUserRecord ) ; break ; default : String errorStr = String . format ( "Unsupported storage format: " , format . toString ( ) ) ; ErrorInformation error = new ErrorInformation ( PwmError . ERROR_INVALID_CONFIG , errorStr ) ; throw new PwmUnrecoverableException ( error ) ; } } return value ; }
compose a single line of otp information .
