jcifs.util.Base64 Java Examples
The following examples show how to use
jcifs.util.Base64.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpnegoCredentialsAction.java From cas4.0.x-server-wechat with Apache License 2.0 | 6 votes |
private void setResponseHeader(final RequestContext context, final Credential credential) { if (credential == null) { return; } final HttpServletResponse response = WebUtils .getHttpServletResponse(context); final SpnegoCredential spnegoCredentials = (SpnegoCredential) credential; final byte[] nextToken = spnegoCredentials.getNextToken(); if (nextToken != null) { if (logger.isDebugEnabled()) { logger.debug("Obtained output token: " + new String(nextToken)); } response.setHeader(SpnegoConstants.HEADER_AUTHENTICATE, (this.ntlm ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE) + " " + Base64.encode(nextToken)); } else { logger.debug("Unable to obtain the output token required."); } if (spnegoCredentials.getPrincipal() == null && send401OnAuthenticationFailure) { logger.debug("Setting HTTP Status to 401"); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } }
Example #2
Source File: NTLMSchemeFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Type2Message decodeType2Message(String challenge) throws NTLMEngineException { try { return new Type2Message(Base64.decode(challenge)); } catch (final IOException exception) { throw new NTLMEngineException("Invalid Type2 message", exception); } }
Example #3
Source File: NTLMSchemeFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Type2Message decodeType2Message(String challenge) throws NTLMEngineException { try { return new Type2Message(Base64.decode(challenge)); } catch (final IOException exception) { throw new NTLMEngineException("Invalid Type2 message", exception); } }
Example #4
Source File: NTLMSchemeFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Type2Message decodeType2Message(String challenge) throws NTLMEngineException { try { return new Type2Message(Base64.decode(challenge)); } catch (final IOException exception) { throw new NTLMEngineException("Invalid Type2 message", exception); } }
Example #5
Source File: SpnegoCredentialsAction.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Override protected Credential constructCredentialsFromRequest( final RequestContext context) { final HttpServletRequest request = WebUtils .getHttpServletRequest(context); final String authorizationHeader = request .getHeader(SpnegoConstants.HEADER_AUTHORIZATION); if (StringUtils.hasText(authorizationHeader) && authorizationHeader.startsWith(this.messageBeginPrefix) && authorizationHeader.length() > this.messageBeginPrefix.length()) { if (logger.isDebugEnabled()) { logger.debug("SPNEGO Authorization header found with " + (authorizationHeader.length() - this.messageBeginPrefix .length()) + " bytes"); } final byte[] token = Base64.decode(authorizationHeader .substring(this.messageBeginPrefix.length())); if (logger.isDebugEnabled()) { logger.debug("Obtained token: " + new String(token)); } return new SpnegoCredential(token); } return null; }
Example #6
Source File: NTLMSchemeFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Type2Message decodeType2Message(String challenge) throws NTLMEngineException { try { return new Type2Message(Base64.decode(challenge)); } catch (final IOException exception) { throw new NTLMEngineException("Invalid Type2 message", exception); } }
Example #7
Source File: NTLMSchemeFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType1Msg(String domain, String workstation) throws NTLMEngineException { Type1Message type1Message = new Type1Message(Type1Message.getDefaultFlags(), domain, workstation); return Base64.encode(type1Message.toByteArray()); }
Example #8
Source File: WebServiceNtlmSender.java From iaf with Apache License 2.0 | 4 votes |
@Override public String generateType1Msg(final String domain, final String workstation) throws NTLMEngineException { final Type1Message type1Message = new Type1Message(TYPE_1_FLAGS, domain, workstation); return Base64.encode(type1Message.toByteArray()); }
Example #9
Source File: JCIFSEngine.java From cs-actions with Apache License 2.0 | 4 votes |
public String generateType1Msg(final String domain, final String workstation) throws NTLMEngineException { final Type1Message type1Message = new Type1Message(TYPE_1_FLAGS, domain, workstation); return Base64.encode(type1Message.toByteArray()); }
Example #10
Source File: URLFetcher.java From PADListener with GNU General Public License v2.0 | 4 votes |
private String constructAuthenticationHeader(String[] challenges, String credentials, String url, String method) { /* credentials string looks like: * Basic BASE64(username:password) * or * Digest BASE64(username:password * or) * NTLM BASE64(domain\ username:password) */ // _logger.info("Constructing auth header from " + credentials); if (credentials == null) return null; if (credentials.startsWith("Basic")) { return credentials; } if (credentials.startsWith("Digest") && challenges != null && challenges.length > 0){ // digest handshake String proxyAuthHeader = challenges[0]; int i = proxyAuthHeader.indexOf(' '); String authParameters = proxyAuthHeader.substring(i + 1); String realm = ""; String nonce = ""; String QOP = ""; String algorithm = ""; String opaque = ""; boolean stale; if (authParameters != null) { int parPos; do { parPos = authParameters.indexOf(','); if (parPos < 0) { // have only one parameter // parseParameter(authParameters); } else { String tokenVal = authParameters.substring(0,parPos); int tokenValPos = tokenVal.indexOf('='); if (tokenValPos >= 0) { String token = tokenVal.substring(0, tokenValPos).trim(); String value = AuthDigestManager.trimDoubleQuotesIfAny(tokenVal.substring(tokenValPos + 1).trim()); if (token.equalsIgnoreCase(AuthDigestManager.REALM_TOKEN)) { realm = value; } if (token.equalsIgnoreCase(AuthDigestManager.NONCE_TOKEN)) { nonce = value; } if (token.equalsIgnoreCase(AuthDigestManager.STALE_TOKEN)) { if (value.equalsIgnoreCase("true")) { stale = true; } } if (token.equalsIgnoreCase(AuthDigestManager.OPAQUE_TOKEN)) { opaque = value; } if (token.equalsIgnoreCase(AuthDigestManager.QOP_TOKEN)) { QOP = value.toLowerCase(); } if (token.equalsIgnoreCase(AuthDigestManager.ALGORITHM_TOKEN)) { algorithm = value.toLowerCase(); } authParameters = authParameters.substring(parPos + 1); } } } while (parPos >= 0); } String userNamePassword = credentials.substring(credentials.indexOf(" ") + 1); userNamePassword = new String(Base64.decode(userNamePassword)); // decode the base64 String username = userNamePassword.substring(0, userNamePassword.indexOf(":")); String password = userNamePassword.substring(username.length() + 1); return "Digest " + AuthDigestManager.computeDigestAuthResponse(username, password, realm, nonce, QOP, algorithm, opaque, method, url); } if (challenges != null) { for (int i=0; i<challenges.length; i++) { if (LOGD) _logger.fine("Challenge: " + challenges[i]); if (challenges[i].startsWith("NTLM") && credentials.startsWith("NTLM")) { return attemptNegotiation(challenges[i], credentials); } if (challenges[i].startsWith("Negotiate") && credentials.startsWith("Negotiate")) { if (LOGD) _logger.fine("Attempting 'Negotiate' Authentication"); return attemptNegotiation(challenges[i], credentials); } if (LOGD) _logger.info("Can't do auth for " + challenges[i]); } } return credentials; }
Example #11
Source File: NTLMSchemeFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType3Msg(String username, String password, String domain, String workstation, String challenge) throws NTLMEngineException { Type2Message type2Message = decodeType2Message(challenge); Type3Message type3Message = new Type3Message(type2Message, password, domain, username, workstation, Type3Message.getDefaultFlags()); return Base64.encode(type3Message.toByteArray()); }
Example #12
Source File: NTLMSchemeFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType1Msg(String domain, String workstation) throws NTLMEngineException { Type1Message type1Message = new Type1Message(Type1Message.getDefaultFlags(), domain, workstation); return Base64.encode(type1Message.toByteArray()); }
Example #13
Source File: NTLMSchemeFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType3Msg(String username, String password, String domain, String workstation, String challenge) throws NTLMEngineException { Type2Message type2Message = decodeType2Message(challenge); Type3Message type3Message = new Type3Message(type2Message, password, domain, username, workstation, Type3Message.getDefaultFlags()); return Base64.encode(type3Message.toByteArray()); }
Example #14
Source File: NTLMSchemeFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType1Msg(String domain, String workstation) throws NTLMEngineException { Type1Message type1Message = new Type1Message(Type1Message.getDefaultFlags(), domain, workstation); return Base64.encode(type1Message.toByteArray()); }
Example #15
Source File: JCIFSEngine.java From davmail with GNU General Public License v2.0 | 4 votes |
public String generateType1Msg(final String domain, final String workstation) { final Type1Message type1Message = new Type1Message(TYPE_1_FLAGS, domain, workstation); return Base64.encode(type1Message.toByteArray()); }
Example #16
Source File: NTLMSchemeFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType3Msg(String username, String password, String domain, String workstation, String challenge) throws NTLMEngineException { Type2Message type2Message = decodeType2Message(challenge); Type3Message type3Message = new Type3Message(type2Message, password, domain, username, workstation, Type3Message.getDefaultFlags()); return Base64.encode(type3Message.toByteArray()); }
Example #17
Source File: NTLMSchemeFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType1Msg(String domain, String workstation) throws NTLMEngineException { Type1Message type1Message = new Type1Message(Type1Message.getDefaultFlags(), domain, workstation); return Base64.encode(type1Message.toByteArray()); }
Example #18
Source File: NTLMSchemeFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public String generateType3Msg(String username, String password, String domain, String workstation, String challenge) throws NTLMEngineException { Type2Message type2Message = decodeType2Message(challenge); Type3Message type3Message = new Type3Message(type2Message, password, domain, username, workstation, Type3Message.getDefaultFlags()); return Base64.encode(type3Message.toByteArray()); }