/** * Creates a default nonce that is 32 bytes long. * @return */ public static String createNonce() { return createNonce(32); } public static String createNonce(int length) {
@Override public void preRequestCert(Asset asset, Map parameters) { // do nothing here in this case. Protocol says add cert req before getCert. if (!parameters.containsKey(getEnvironment().getConstants().get(CALLBACK_URI_KEY))) { parameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), getEnvironment().getCallback().toString()); } OA2Asset a = (OA2Asset) asset; a.setState(NonceHerder.createNonce()); a.setNonce(NonceHerder.createNonce()); // Next is for testing exception handling on the server. This creates an unsupported request which should fail everytime. //parameters.put(OA2Constants.REQUEST, "My_request"); parameters.put(OA2Constants.RESPONSE_TYPE, OA2Constants.AUTHORIZATION_CODE); //parameters.put(OA2Constants.CLIENT_ID, delegationRequest.getClient().getIdentifierString()); parameters.put(OA2Constants.SCOPE, getRequestedScopes()); //parameters.put(OA2Constants.REDIRECT_URI, delegationRequest.getParameters().get(OA2Constants.REDIRECT_URI)); parameters.put(OA2Constants.STATE, a.getState()); // random state is ok. parameters.put(OA2Constants.NONCE, a.getNonce()); parameters.put(OA2Constants.PROMPT, OA2Constants.PROMPT_LOGIN); }
String nonce = NonceHerder.createNonce(); HashMap m = new HashMap(); m.put(OA2Constants.RESPONSE_TYPE, OA2Constants.AUTHORIZATION_CODE);