@Override public void prepare(PresentableState state) throws Throwable { super.prepare(state); if (state.getState() == AUTHORIZATION_ACTION_START) { state.getRequest().setAttribute(AUTHORIZATION_REFRESH_TOKEN_LIFETIME_KEY, AUTHORIZATION_REFRESH_TOKEN_LIFETIME_KEY); } if (state.getState() == AUTHORIZATION_ACTION_OK) { AuthorizedState authorizedState = (AuthorizedState) state; ((OA2ServiceTransaction) authorizedState.getTransaction()).setAuthTime(new Date()); } }
public void prepare(PresentableState state) throws Throwable { preprocess(new TransactionState(state.getRequest(), state.getResponse(), null, null)); switch (state.getState()) { case INITIAL_STATE: HttpServletRequest request = state.getRequest(); info("Processing new client registration request."); request.setAttribute(CLIENT_NAME, CLIENT_NAME); request.setAttribute(CLIENT_PUBLIC_KEY, CLIENT_PUBLIC_KEY); request.setAttribute(CLIENT_HOME_URL, CLIENT_HOME_URL); request.setAttribute(CLIENT_ERROR_URL, CLIENT_ERROR_URL); request.setAttribute(CLIENT_EMAIL, CLIENT_EMAIL); request.setAttribute(CLIENT_PROXY_LIMITED, CLIENT_PROXY_LIMITED); request.setAttribute(CLIENT_ACTION_KEY, CLIENT_ACTION_KEY); request.setAttribute(CLIENT_ACTION_REQUEST_VALUE, CLIENT_ACTION_REQUEST_VALUE); request.setAttribute("actionToTake", request.getContextPath() + "/register"); break; case REQUEST_STATE: // nothing to do. return; case ERROR_STATE: default: warn("Error: unknown action request."); } }
@Override public void prepare(PresentableState state) throws Throwable { super.prepare(state); HttpServletRequest request = state.getRequest(); if (state.getState() == INITIAL_STATE) { String[] scopes = new String[getOA2SE().getScopes().size()]; getOA2SE().getScopes().toArray(scopes); request.setAttribute(SCOPES_NAME, scopes); request.setAttribute(VO_NAME, VO_NAME); request.setAttribute(LDAP_NAME, LDAP_NAME); request.setAttribute(ISSUER_NAME, ISSUER_NAME); request.setAttribute(CALLBACK_URI, CALLBACK_URI); request.setAttribute(getValueTag(CLIENT_CALLBACK_URI), "Put your callbacks here, one per line."); request.setAttribute(REFRESH_TOKEN_LIFETIME, REFRESH_TOKEN_LIFETIME); if (getOA2SE().isRefreshTokenEnabled()) { request.setAttribute(REFRESH_TOKEN_FIELD_VISIBLE, " "); // it's visible } else { request.setAttribute(REFRESH_TOKEN_FIELD_VISIBLE, " style=\"display: none;\""); // it's not } } }
public void present(PresentableState state) throws Throwable { postprocess(new TransactionState(state.getRequest(), state.getResponse(), null, null)); switch (state.getState()) { case INITIAL_STATE: JSPUtil.fwd(state.getRequest(), state.getResponse(), INIT_PAGE); break; case REQUEST_STATE: if (state instanceof ClientState) { ClientState cState = (ClientState) state; state.getRequest().setAttribute("client", cState.getClient()); JSPUtil.fwd(state.getRequest(), state.getResponse(), OK_PAGE); } else { throw new IllegalStateException("Error: An instance of ClientState was expected, but got an instance of \"" + state.getClass().getName() + "\""); } break; case ERROR_STATE: default: } }
/** * We override this to set the client secret to be displayed at registration time. * * @param state * @throws Throwable */ @Override public void present(PresentableState state) throws Throwable { super.present(state); // after all is done, do not store the secret in the database, just a hash of it. if (state.getState() == REQUEST_STATE) { if (state instanceof ClientState) { // we should not store the client secret in the database, just a hash of it. ClientState cState = (ClientState) state; String secret = DigestUtils.sha1Hex(cState.getClient().getSecret()); cState.getClient().setSecret(secret); getServiceEnvironment().getClientStore().save(cState.getClient()); } else { throw new IllegalStateException("Error: An instance of ClientState was expected, but got an instance of \"" + state.getClass().getName() + "\""); } } }