##
## Velocity Template for Attended Startup Unlock Utility
##
## Velocity context will contain the following properties:
## flowRequestContext - the Spring Web Flow RequestContext
## request - HttpServletRequest
## response - HttpServletResponse
## profileRequestContext
## environment - Spring Environment object for property resolution
## custom - arbitrary object injected by deployer
##
#set ($title = $springMacroRequestContext.getMessage("idp.title", "Web Login Service"))
#set ($titleSuffix = $springMacroRequestContext.getMessage("idp.unlock-keys.title", "Attended Restart Key Unlock"))
#set ($eventId = $profileRequestContext.getSubcontext("org.opensaml.profile.context.EventContext").getEvent())
#set ($state = $flowRequestContext.getCurrentState().getId())
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <title>$title - $titleSuffix</title>
        <link rel="stylesheet" type="text/css" href="$request.getContextPath()/css/main.css">
    </head>
    
    <body>
    <div class="wrapper">
        <div class="container">
            <header>
                <img src="$request.getContextPath()#springMessage("idp.logo")" alt="#springMessageText("idp.logo.alt-text", "logo")">
                <h3>$title - $titleSuffix</h3>
            </header>
        
            <div class="content">
            #if ($state == "end")
                <strong>#springMessageText("idp.unlock-keys.complete", "The system is unlocked and ready for use.")</strong>
                <p><a href="$request.getContextPath()/profile/SAML2/Unsolicited/SSO?providerId=https://sp.example.org/shibboleth">Validation Link</a></p>
            #else
                #if ($eventId == "InvalidMessage")
                    <p class="form-element form-error">
                    #springMessageText("idp.unlock-keys.error", "Unlock failed; check log for specific message.")
                    </p>
                    <br/><br/>
                #end
            
                <form action="$flowExecutionUrl" method="post">
                
                  <!--
                  If you have multiple key strategies defined, you'll need multiple pairs of form fields for
                  the passwords, labeled in the order they're fed into the shibboleth.unlock-keys.KeyStrategies
                  bean. If you have none, remove the fields.
                  -->

                  <div class="form-element-wrapper">
                    <label for="password">#springMessageText("idp.unlock-keys.keystorePassword", "DataSealer Keystore Password")</label>
                    <input class="form-element form-field" id="password" name="keystorePassword" type="password">
                  </div>

                  <div class="form-element-wrapper">
                    <label for="password">#springMessageText("idp.unlock-keys.keyPassword", "DataSealer Key Password")</label>
                    <input class="form-element form-field" id="password" name="keyPassword" type="password">
                  </div>

                  <!--
                  If you have multiple private keys defined, you'll need a form field for each passwords, labeled in the order
                  they're fed into the shibboleth.unlock-keys.Credentials/PrivateKeys beans. If you have none, remove the fields.
                  -->

                  <div class="form-element-wrapper">
                    <label for="password">#springMessageText("idp.unlock-keys.privateKeyPassword", "Private Key Password")</label>
                    <input class="form-element form-field" id="password" name="privateKeyPassword" type="password">
                  </div>
                  
                  <div class="form-element-wrapper">
                    <button class="form-element form-button" type="submit" name="_eventId_proceed"
                        >#springMessageText("idp.unlock-keys.unlock", "Unlock")</button>
                  </div>

                  <div class="form-element-wrapper">
                    <button class="form-element form-button" type="submit" name="_eventId_cancel"
                        >#springMessageText("idp.unlock-keys.cancel", "Cancel")</button>
                  </div>
                  
                </form>
            #end
            </div>
        </div>

        <footer>
            <div class="container container-footer">
                <p class="footer-text">#springMessageText("idp.footer", "Insert your footer text here.")</p>
            </div>
        </footer>
        
    </div>
    </body>
</html>