ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/websocket/BasicAuthenticator.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/websocket/BasicAuthenticator.java
Status
scanned
Type
file
Name
BasicAuthenticator.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2256 (2.2 KB)
MD5
a8fb19d4f94d2c287d0076c70d6b32cd
SHA1
1dc2165b5456922a557147f7367c2df80af4ecda
SHA256
01e95ca4996f88ccc0dfb4874a244d08650d5ece9e7336e0957754b419558607
SHA512

      
    
SHA1_git
2a3aa477cd3b775cb91fde0c2c7be416a279df48
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
BasicAuthenticator.java | 2.2 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.websocket; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Map; /** * Authenticator supporting the BASIC authentication method. */ public class BasicAuthenticator extends Authenticator { public static final String schemeName = "basic"; public static final String charsetparam = "charset"; @Override public String getAuthorization(String requestUri, String authenticateHeader, String userName, String userPassword, String userRealm) throws AuthenticationException { validateUsername(userName); validatePassword(userPassword); Map<String,String> parameterMap = parseAuthenticateHeader(authenticateHeader); String realm = parameterMap.get("realm"); validateRealm(userRealm, realm); String userPass = userName + ":" + userPassword; Charset charset; if (parameterMap.get(charsetparam) != null && parameterMap.get(charsetparam).equalsIgnoreCase("UTF-8")) { charset = StandardCharsets.UTF_8; } else { charset = StandardCharsets.ISO_8859_1; } String base64 = Base64.getEncoder().encodeToString(userPass.getBytes(charset)); return " Basic " + base64; } @Override public String getSchemeName() { return schemeName; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
49.17
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9