List of usage examples for org.apache.commons.httpclient Credentials getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.twinsoft.convertigo.engine.enums.AuthenticationMode.java
private int compare(Credentials cred1, Credentials cred2) { if (cred1 == null && cred2 == null) { return 0; } else if (cred2 == null) { return -1; } else if (cred1 == null) { return 1; }/*from w w w . j a va 2 s .c o m*/ if (!cred1.getClass().equals(cred2.getClass())) { return 1; } else if (cred1.equals(cred2)) { return 0; } else { return 1; } }
From source file:com.owncloud.android.oc_framework.network.BearerAuthScheme.java
/** * Produces bearer authorization string for the given set of * {@link Credentials}.//from w w w . ja v a 2s . c om * * @param credentials The set of credentials to be used for authentication * @param method Method name is ignored by the bearer authentication scheme * @param uri URI is ignored by the bearer authentication scheme * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable * for this authentication scheme * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure * @return A bearer authorization string * * @deprecated Use {@link #authenticate(Credentials, HttpMethod)} */ public String authenticate(Credentials credentials, String method, String uri) throws AuthenticationException { Log.d(TAG, "enter BearerScheme.authenticate(Credentials, String, String)"); BearerCredentials bearer = null; try { bearer = (BearerCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for bearer authentication: " + credentials.getClass().getName()); } return BearerAuthScheme.authenticate(bearer); }
From source file:com.cerema.cloud2.lib.common.network.BearerAuthScheme.java
/** * Produces bearer authorization string for the given set of * {@link Credentials}.//from www . ja v a2 s . co m * * @param credentials The set of credentials to be used for authentication * @param method Method name is ignored by the bearer authentication scheme * @param uri URI is ignored by the bearer authentication scheme * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable * for this authentication scheme * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure * @return A bearer authorization string * * @deprecated Use {@link #authenticate(Credentials, HttpMethod)} */ public String authenticate(Credentials credentials, String method, String uri) throws AuthenticationException { Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, String, String)"); BearerCredentials bearer = null; try { bearer = (BearerCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for bearer authentication: " + credentials.getClass().getName()); } return BearerAuthScheme.authenticate(bearer); }
From source file:davmail.http.NTLMv2Scheme.java
/** * Produces NTLM authorization string for the given set of * {@link Credentials}.//from w w w . ja va 2 s. c o m * * @param credentials The set of credentials to be used for authentication * @param httpMethod The method being authenticated * @return an NTLM authorization string * @throws InvalidCredentialsException if authentication credentials * are not valid or not applicable for this authentication scheme * @throws AuthenticationException if authorization string cannot * be generated due to an authentication failure */ public String authenticate(Credentials credentials, HttpMethod httpMethod) throws AuthenticationException { if (this.state == UNINITIATED) { throw new IllegalStateException("NTLM authentication process has not been initiated"); } NTCredentials ntcredentials; try { ntcredentials = (NTCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for NTLM authentication: " + credentials.getClass().getName()); } String response; if (this.state == INITIATED || this.state == FAILED) { int flags = NtlmFlags.NTLMSSP_NEGOTIATE_NTLM2 | NtlmFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN | NtlmFlags.NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED | NtlmFlags.NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED | NtlmFlags.NTLMSSP_NEGOTIATE_NTLM | NtlmFlags.NTLMSSP_REQUEST_TARGET | NtlmFlags.NTLMSSP_NEGOTIATE_OEM | NtlmFlags.NTLMSSP_NEGOTIATE_UNICODE | NtlmFlags.NTLMSSP_NEGOTIATE_56 | NtlmFlags.NTLMSSP_NEGOTIATE_128; Type1Message type1Message = new Type1Message(flags, ntcredentials.getDomain(), ntcredentials.getHost()); response = EncodingUtil.getAsciiString(Base64.encodeBase64(type1Message.toByteArray())); this.state = TYPE1_MSG_GENERATED; } else { int flags = NtlmFlags.NTLMSSP_NEGOTIATE_NTLM2 | NtlmFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN | NtlmFlags.NTLMSSP_NEGOTIATE_NTLM | NtlmFlags.NTLMSSP_NEGOTIATE_UNICODE; Type3Message type3Message = new Type3Message(type2Message, ntcredentials.getPassword(), ntcredentials.getDomain(), ntcredentials.getUserName(), ntcredentials.getHost(), flags); response = EncodingUtil.getAsciiString(Base64.encodeBase64(type3Message.toByteArray())); this.state = TYPE3_MSG_GENERATED; } return "NTLM " + response; }
From source file:it.greenvulcano.gvesb.http.ntlm.JCIFS_NTLMScheme.java
@Override public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { if (this.state == UNINITIATED) { throw new IllegalStateException("NTLM authentication process has not been initiated"); }//from www. ja v a 2s. c o m NTCredentials ntcredentials = null; try { ntcredentials = (NTCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for NTLM authentication: " + credentials.getClass().getName()); } NTLM ntlm = new NTLM(); ntlm.setCredentialCharset(method.getParams().getCredentialCharset()); String response = null; if ((this.state == INITIATED) || (this.state == FAILED)) { response = ntlm.generateType1Msg(ntcredentials.getHost(), ntcredentials.getDomain()); this.state = TYPE1_MSG_GENERATED; } else { response = ntlm.generateType3Msg(ntcredentials.getUserName(), ntcredentials.getPassword(), ntcredentials.getHost(), ntcredentials.getDomain(), this.ntlmchallenge); this.state = TYPE3_MSG_GENERATED; } return "NTLM " + response; }
From source file:com.owncloud.android.oc_framework.network.BearerAuthScheme.java
/** * Produces bearer authorization string for the given set of {@link Credentials}. * // w ww. j a v a 2 s . co m * @param credentials The set of credentials to be used for authentication * @param method The method being authenticated * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable for this authentication * scheme. * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure. * * @return a basic authorization string */ public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { Log.d(TAG, "enter BearerScheme.authenticate(Credentials, HttpMethod)"); if (method == null) { throw new IllegalArgumentException("Method may not be null"); } BearerCredentials bearer = null; try { bearer = (BearerCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for bearer authentication: " + credentials.getClass().getName()); } return BearerAuthScheme.authenticate(bearer, method.getParams().getCredentialCharset()); }
From source file:com.cerema.cloud2.lib.common.network.BearerAuthScheme.java
/** * Produces bearer authorization string for the given set of {@link Credentials}. * //from w w w . j a v a2s .c o m * @param credentials The set of credentials to be used for authentication * @param method The method being authenticated * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable for this authentication * scheme. * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure. * * @return a basic authorization string */ public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, HttpMethod)"); if (method == null) { throw new IllegalArgumentException("Method may not be null"); } BearerCredentials bearer = null; try { bearer = (BearerCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for bearer authentication: " + credentials.getClass().getName()); } return BearerAuthScheme.authenticate(bearer, method.getParams().getCredentialCharset()); }
From source file:com.mobilehelix.appserver.auth.JCIFS_NTLMScheme.java
@Override public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { LOG.log(Level.FINEST, "Enter JCIFS_NTLMScheme.authenticate(Credentials, HttpMethod)"); if (this.state == UNINITIATED) { throw new IllegalStateException("NTLM authentication process has not been initiated"); }//from w w w .java2 s . c o m NTCredentials ntcredentials = null; try { ntcredentials = (NTCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for NTLM authentication: " + credentials.getClass().getName()); } NTLM ntlm = new NTLM(); ntlm.setCredentialCharset(method.getParams().getCredentialCharset()); String response = null; if (this.state == INITIATED || this.state == FAILED) { response = ntlm.generateType1Msg(ntcredentials.getHost(), ntcredentials.getDomain()); this.state = TYPE1_MSG_GENERATED; } else { response = ntlm.generateType3Msg(ntcredentials.getUserName(), ntcredentials.getPassword(), ntcredentials.getHost(), ntcredentials.getDomain(), this.ntlmchallenge); this.state = TYPE3_MSG_GENERATED; } return "NTLM " + response; }
From source file:org.jetbrains.tfsIntegration.webservice.auth.NTLM2Scheme.java
/** * Produces NTLM authorization string for the given set of * {@link Credentials}.// w w w. ja va 2 s. c om * * @param credentials The set of credentials to be used for athentication * @param method The method being authenticated * * @throws InvalidCredentialsException if authentication credentials * are not valid or not applicable for this authentication scheme * @throws AuthenticationException if authorization string cannot * be generated due to an authentication failure * * @return an NTLM authorization string * * @since 3.0 */ public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { if (state == UNINITIATED) { throw new IllegalStateException("NTLM authentication process was not initiated"); } NTCredentials ntcredentials = null; try { ntcredentials = (NTCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for NTLM authentication: " + credentials.getClass().getName()); } String response; if (state == INITIATED || state == FAILED) { response = getType1MessageResponse(ntcredentials, method.getParams()); state = TYPE1_MSG_GENERATED; } else { response = getType3MessageResponse(ntlmchallenge, ntcredentials, method.getParams()); state = TYPE3_MSG_GENERATED; } return "NTLM " + response; }
From source file:org.mule.transport.http.ntlm.NTLMScheme.java
private NTCredentials getNTCredentials(Credentials credentials) throws InvalidCredentialsException { try {// w w w. j ava 2 s . c om return (NTCredentials) credentials; } catch (ClassCastException e) { throw new InvalidCredentialsException( "Credentials cannot be used for NTLM authentication: " + credentials.getClass().getName()); } }