SecurityScheme securityScheme = new SecurityScheme(); if (endpoint != null) { if (ChallengeScheme.HTTP_BASIC.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.HTTP_BASIC.getName()); securitySchemes.put(ChallengeScheme.HTTP_BASIC.getName(), securityScheme); } else if (ChallengeScheme.HTTP_OAUTH.equals(endpoint .getAuthenticationProtocol()) || ChallengeScheme.HTTP_OAUTH_BEARER.equals(endpoint .getAuthenticationProtocol()) || ChallengeScheme.HTTP_OAUTH_MAC.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType("Oauth 2.0"); securitySchemes.put("oauth_2_0", securityScheme); } else if (ChallengeScheme.HTTP_DIGEST.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.HTTP_DIGEST.getName()); securitySchemes.put(ChallengeScheme.HTTP_DIGEST.getName(), securityScheme); } else if (ChallengeScheme.CUSTOM.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.CUSTOM.getName()); securitySchemes.put(ChallengeScheme.CUSTOM.getName(), securityScheme);
if (name.equalsIgnoreCase(CUSTOM.getName())) { result = CUSTOM; } else if (name.equalsIgnoreCase(HTTP_AWS.getName())) { result = HTTP_AWS; } else if (name.equalsIgnoreCase(HTTP_AWS_S3.getName())) { result = HTTP_AWS_S3; } else if (name.equalsIgnoreCase(HTTP_BASIC.getName())) { result = HTTP_BASIC; } else if (name.equalsIgnoreCase(HTTP_DIGEST.getName())) { result = HTTP_DIGEST; } else if (name.equalsIgnoreCase(HTTP_NTLM.getName())) { result = HTTP_NTLM; } else if (name.equalsIgnoreCase(POP_BASIC.getName())) { result = POP_BASIC; } else if (name.equalsIgnoreCase(POP_DIGEST.getName())) { result = POP_DIGEST; } else if (name.equalsIgnoreCase(SMTP_PLAIN.getName())) { result = SMTP_PLAIN; } else if (name.equalsIgnoreCase(POP_BASIC.getName())) { result = POP_BASIC; } else if (name.equalsIgnoreCase(POP_DIGEST.getName())) { result = POP_DIGEST; } else { result = new ChallengeScheme(name, null, null);
/** * Returns the name. * * @return The name. */ @Override public String toString() { return getName(); }
private static ChallengeRequest getDigestChallengeRequest(ClientResource cr) { ChallengeRequest c1 = null; for (ChallengeRequest challengeRequest : cr.getChallengeRequests()) { if (ChallengeScheme.HTTP_DIGEST .equals(challengeRequest.getScheme())) { c1 = challengeRequest; break; } } return c1; } }
public HttpNxBasicHelper() { super( new ChallengeScheme( "HTTP_NxBasic", "NxBasic", "Nexus modified HTTP Basic" ), true, true ); }
Context.getCurrentLogger().warning( "A challenge response must have a scheme defined."); } else if (challenge.getScheme().getTechnicalName() == null) { Context.getCurrentLogger().warning( "A challenge scheme must have a technical name defined."); } else { ChallengeWriter cw = new ChallengeWriter(); cw.append(challenge.getScheme().getTechnicalName()).appendSpace(); int cwInitialLength = cw.getBuffer().length();
/** * Finds the authenticator helper supporting the given scheme. * * @param challengeScheme * The challenge scheme to match. * @param clientSide * Indicates if client side support is required. * @param serverSide * Indicates if server side support is required. * @return The authenticator helper or null. */ public org.restlet.engine.security.AuthenticatorHelper findHelper( ChallengeScheme challengeScheme, boolean clientSide, boolean serverSide) { org.restlet.engine.security.AuthenticatorHelper result = null; List<org.restlet.engine.security.AuthenticatorHelper> helpers = getRegisteredAuthenticators(); org.restlet.engine.security.AuthenticatorHelper current; for (int i = 0; (result == null) && (i < helpers.size()); i++) { current = helpers.get(i); if (current.getChallengeScheme().equals(challengeScheme) && ((clientSide && current.isClientSide()) || !clientSide) && ((serverSide && current.isServerSide()) || !serverSide)) { result = helpers.get(i); } } return result; }
/** * Returns the challenge scheme associated to a scheme name. If an existing * constant exists then it is returned, otherwise a new instance is created. * * @param name * The scheme name. * @return The associated challenge scheme. */ public static ChallengeScheme valueOf(final String name) { if (name == null) { throw new IllegalArgumentException( "ChallengeScheme.valueOf(name) name must not be null"); } ChallengeScheme result = SCHEMES.get(name.toLowerCase()); if (result == null) { result = new ChallengeScheme(name, null, null); } return result; }
Context.getCurrentLogger().warning( "A challenge response must have a scheme defined."); } else if (challenge.getScheme().getTechnicalName() == null) { Context.getCurrentLogger().warning( "A challenge scheme must have a technical name defined."); } else { ChallengeWriter cw = new ChallengeWriter(); cw.append(challenge.getScheme().getTechnicalName()).appendSpace(); int cwInitialLength = cw.getBuffer().length();
SecurityScheme securityScheme = new SecurityScheme(); if (endpoint != null) { if (ChallengeScheme.HTTP_BASIC.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.HTTP_BASIC.getName()); securitySchemes.put(ChallengeScheme.HTTP_BASIC.getName(), securityScheme); } else if (ChallengeScheme.HTTP_OAUTH.equals(endpoint .getAuthenticationProtocol()) || ChallengeScheme.HTTP_OAUTH_BEARER.equals(endpoint .getAuthenticationProtocol()) || ChallengeScheme.HTTP_OAUTH_MAC.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType("Oauth 2.0"); securitySchemes.put("oauth_2_0", securityScheme); } else if (ChallengeScheme.HTTP_DIGEST.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.HTTP_DIGEST.getName()); securitySchemes.put(ChallengeScheme.HTTP_DIGEST.getName(), securityScheme); } else if (ChallengeScheme.CUSTOM.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.CUSTOM.getName()); securitySchemes.put(ChallengeScheme.CUSTOM.getName(), securityScheme);
public static ChallengeResponse getTestChallengeResponse(final List<ChallengeRequest> list, final ChallengeScheme httpDigest, final Response response, final String userName, final char[] password) { ChallengeRequest c1 = null; for(final ChallengeRequest challengeRequest : list) { if(ChallengeScheme.HTTP_DIGEST.equals(challengeRequest.getScheme())) { c1 = challengeRequest; break; } } // 2- Create the Challenge response used by the client to authenticate its requests. final ChallengeResponse challengeResponse = new ChallengeResponse(c1, response, userName, password); return challengeResponse; }
// JSON payload and Content-Type header JSONObject jsonObj = (...) JsonRepresentation repr = new JsonRepresentation(jsonObj); // Authorization header String pAccessToken = "some token"; ChallengeResponse challengeResponse = new ChallengeResponse( new ChallengeScheme("", "")); challengeResponse.setRawValue(pAccessToken); resource.setChallengeResponse(challengeResponse); // Request and Accept header resource.post(jsonObj, MediaType.APPLICATION_JSON);
.getChallengeResponse(); if (cr != null && cr.getScheme() != null) { result = cr.getScheme().getTechnicalName();
SecurityScheme securityScheme = new SecurityScheme(); if (endpoint != null) { if (ChallengeScheme.HTTP_BASIC.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.HTTP_BASIC.getName()); securitySchemes.put(ChallengeScheme.HTTP_BASIC.getName(), securityScheme); } else if (ChallengeScheme.HTTP_OAUTH.equals(endpoint .getAuthenticationProtocol()) || ChallengeScheme.HTTP_OAUTH_BEARER.equals(endpoint .getAuthenticationProtocol()) || ChallengeScheme.HTTP_OAUTH_MAC.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType("Oauth 2.0"); securitySchemes.put("oauth_2_0", securityScheme); } else if (ChallengeScheme.HTTP_DIGEST.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.HTTP_DIGEST.getName()); securitySchemes.put(ChallengeScheme.HTTP_DIGEST.getName(), securityScheme); } else if (ChallengeScheme.CUSTOM.equals(endpoint .getAuthenticationProtocol())) { securityScheme.setType(ChallengeScheme.CUSTOM.getName()); securitySchemes.put(ChallengeScheme.CUSTOM.getName(), securityScheme);
} else if (ChallengeScheme.HTTP_OAUTH_BEARER.equals(cr.getScheme())) { logger.config("Verify: Bearer"); final String bearer = cr.getRawValue();
ChallengeResponse cred = new ChallengeResponse(new ChallengeScheme("","")); cred.setRawValue("12345");
return (cr != null) ? cr.getIdentifier() : null; case "crs": return (cr != null && cr.getScheme() != null) ? cr.getScheme().getTechnicalName() : null; case "d": return DateUtils.format(new Date(), FORMAT_RFC_1123.get(0));